diff --git a/Cargo.lock b/Cargo.lock index 69b164f..f71f738 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,16 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + [[package]] name = "aes" version = "0.8.4" @@ -19,6 +29,20 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + [[package]] name = "ahash" version = "0.7.8" @@ -51,6 +75,23 @@ dependencies = [ "memchr", ] +[[package]] +name = "android_log-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" + +[[package]] +name = "android_logger" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b07e8e73d720a1f2e4b6014766e6039fd2e96a4fa44e2a78d0e1fa2ff49826" +dependencies = [ + "android_log-sys", + "env_filter", + "log", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -395,19 +436,23 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "bitkitcore" -version = "0.1.38" +version = "0.1.40" dependencies = [ + "android_logger", "async-trait", "base64 0.22.1", "bdk", "bip39", "bitcoin 0.32.7", "bitcoin-address-generator", + "btleplug", "chrono", "hex", + "jni", "lazy-regex", "lightning-invoice", "lnurl-rs", + "log", "once_cell", "openssl", "r2d2", @@ -423,8 +468,9 @@ dependencies = [ "serial_test", "tempfile", "test-case", - "thiserror", + "thiserror 2.0.17", "tokio", + "trezor-connect-rs", "uniffi", "url", "uuid", @@ -460,6 +506,44 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2", +] + +[[package]] +name = "bluez-async" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84ae4213cc2a8dc663acecac67bbdad05142be4d8ef372b6903abf878b0c690a" +dependencies = [ + "bitflags 2.10.0", + "bluez-generated", + "dbus", + "dbus-tokio", + "futures", + "itertools", + "log", + "serde", + "serde-xml-rs", + "thiserror 2.0.17", + "tokio", + "uuid", +] + +[[package]] +name = "bluez-generated" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9676783265eadd6f11829982792c6f303f3854d014edfba384685dcf237dd062" +dependencies = [ + "dbus", +] + [[package]] name = "borsh" version = "1.5.7" @@ -492,6 +576,34 @@ dependencies = [ "sha2", ] +[[package]] +name = "btleplug" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a11621cb2c8c024e444734292482b1ad86fb50ded066cf46252e46643c8748" +dependencies = [ + "async-trait", + "bitflags 2.10.0", + "bluez-async", + "dashmap 6.1.0", + "dbus", + "futures", + "jni", + "jni-utils", + "log", + "objc2", + "objc2-core-bluetooth", + "objc2-foundation", + "once_cell", + "static_assertions", + "thiserror 2.0.17", + "tokio", + "tokio-stream", + "uuid", + "windows", + "windows-future", +] + [[package]] name = "bumpalo" version = "3.19.0" @@ -561,7 +673,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -583,6 +695,12 @@ dependencies = [ "shlex", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.4" @@ -606,7 +724,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -658,6 +776,16 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -742,9 +870,96 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core 0.6.4", "typenum", ] +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core 0.9.12", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core 0.9.12", +] + +[[package]] +name = "dbus" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b3aa68d7e7abee336255bd7248ea965cc393f3e70411135a6f6a4b651345d4" +dependencies = [ + "futures-channel", + "futures-util", + "libc", + "libdbus-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "dbus-tokio" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "007688d459bc677131c063a3a77fb899526e17b7980f390b69644bdbc41fad13" +dependencies = [ + "dbus", + "libc", + "tokio", +] + [[package]] name = "der" version = "0.7.10" @@ -791,6 +1006,12 @@ dependencies = [ "signature", ] +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + [[package]] name = "electrum-client" version = "0.18.0" @@ -837,6 +1058,16 @@ dependencies = [ "serde", ] +[[package]] +name = "env_filter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" +dependencies = [ + "log", + "regex", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -881,12 +1112,24 @@ dependencies = [ "subtle", ] +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "find-msvc-tools" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff" +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + [[package]] name = "flate2" version = "1.1.5" @@ -1000,6 +1243,17 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", +] + [[package]] name = "futures-sink" version = "0.3.31" @@ -1021,6 +1275,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-io", + "futures-macro", "futures-sink", "futures-task", "memchr", @@ -1076,6 +1331,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + [[package]] name = "glob" version = "0.3.3" @@ -1170,6 +1435,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + [[package]] name = "hmac" version = "0.12.1" @@ -1310,7 +1584,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core", + "windows-core 0.62.2", ] [[package]] @@ -1469,12 +1743,56 @@ dependencies = [ "serde", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jni" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jni-utils" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "259e9f2c3ead61de911f147000660511f07ab00adeed1d84f5ac4d0386e7a6c4" +dependencies = [ + "dashmap 5.5.3", + "futures", + "jni", + "log", + "once_cell", + "static_assertions", + "uuid", +] + [[package]] name = "js-sys" version = "0.3.82" @@ -1526,6 +1844,15 @@ version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +[[package]] +name = "libdbus-sys" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043" +dependencies = [ + "pkg-config", +] + [[package]] name = "libsqlite3-sys" version = "0.30.1" @@ -1537,6 +1864,18 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libusb1-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da050ade7ac4ff1ba5379af847a10a10a8e284181e060105bf8d86960ce9ce0f" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "lightning-invoice" version = "0.32.0" @@ -1656,6 +1995,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + [[package]] name = "native-tls" version = "0.2.14" @@ -1683,13 +2028,77 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ - "autocfg", + "autocfg", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2-core-bluetooth" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a644b62ffb826a5277f536cf0f701493de420b13d40e700c452c36567771111" +dependencies = [ + "bitflags 2.10.0", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.10.0", + "block2", + "libc", + "objc2", ] [[package]] @@ -1698,6 +2107,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + [[package]] name = "openssl" version = "0.10.74" @@ -1797,7 +2212,7 @@ dependencies = [ "libc", "redox_syscall 0.5.18", "smallvec", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -1816,6 +2231,16 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1840,6 +2265,18 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + [[package]] name = "potential_utf" version = "0.1.4" @@ -1858,6 +2295,16 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.109", +] + [[package]] name = "proc-macro-crate" version = "3.4.0" @@ -1876,6 +2323,58 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 2.0.109", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.109", +] + +[[package]] +name = "prost-types" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" +dependencies = [ + "prost", +] + [[package]] name = "ptr_meta" version = "0.1.4" @@ -1910,7 +2409,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.35", "socket2", - "thiserror", + "thiserror 2.0.17", "tokio", "tracing", "web-time", @@ -1931,7 +2430,7 @@ dependencies = [ "rustls 0.23.35", "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.17", "tinyvec", "tracing", "web-time", @@ -2213,6 +2712,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rusb" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9f9ff05b63a786553a4c02943b74b34a988448671001e9a27e2f0565cc05a4" +dependencies = [ + "libc", + "libusb1-sys", +] + [[package]] name = "rusqlite" version = "0.32.1" @@ -2237,7 +2746,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", "tokio", "url", ] @@ -2264,6 +2773,15 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "1.1.2" @@ -2358,6 +2876,15 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scc" version = "2.4.0" @@ -2555,6 +3082,18 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-xml-rs" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2215ce3e6a77550b80a1c37251b7d294febaf42e36e21b7b411e0bf54d540d" +dependencies = [ + "log", + "serde", + "thiserror 2.0.17", + "xml", +] + [[package]] name = "serde_core" version = "1.0.228" @@ -2861,13 +3400,33 @@ dependencies = [ "smawk", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", ] [[package]] @@ -2954,6 +3513,31 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.11" @@ -3045,9 +3629,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", +] + [[package]] name = "tracing-core" version = "0.1.34" @@ -3057,6 +3653,40 @@ dependencies = [ "once_cell", ] +[[package]] +name = "trezor-connect-rs" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d1fb22b5b5d47cdf083ce5a02e3b50c625fdc81333278999e75f8ef5ad6320" +dependencies = [ + "aes-gcm", + "async-trait", + "base64 0.22.1", + "bitcoin 0.32.7", + "btleplug", + "bytes", + "futures", + "hex", + "hkdf", + "hmac", + "log", + "num-bigint", + "num-traits", + "prost", + "prost-build", + "rand 0.8.5", + "rusb", + "serde", + "serde_json", + "sha2", + "thiserror 1.0.69", + "tokio", + "tracing", + "uuid", + "x25519-dalek", + "zeroize", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -3205,6 +3835,16 @@ dependencies = [ "weedle2", ] +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + [[package]] name = "untrusted" version = "0.9.0" @@ -3272,6 +3912,16 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -3433,12 +4083,56 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.61.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + [[package]] name = "windows-core" version = "0.62.2" @@ -3447,9 +4141,20 @@ checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", - "windows-link", - "windows-result", - "windows-strings", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading", ] [[package]] @@ -3474,19 +4179,53 @@ dependencies = [ "syn 2.0.109", ] +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows-result" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link", + "windows-link 0.2.1", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", ] [[package]] @@ -3495,7 +4234,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -3507,6 +4246,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.60.2" @@ -3522,7 +4270,7 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -3547,7 +4295,7 @@ version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link", + "windows-link 0.2.1", "windows_aarch64_gnullvm 0.53.1", "windows_aarch64_msvc 0.53.1", "windows_i686_gnu 0.53.1", @@ -3558,6 +4306,15 @@ dependencies = [ "windows_x86_64_msvc 0.53.1", ] +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -3684,6 +4441,24 @@ dependencies = [ "tap", ] +[[package]] +name = "x25519-dalek" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +dependencies = [ + "curve25519-dalek", + "rand_core 0.6.4", + "serde", + "zeroize", +] + +[[package]] +name = "xml" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8aa498d22c9bbaf482329839bc5620c46be275a19a812e9a22a2b07529a642a" + [[package]] name = "yoke" version = "0.8.1" @@ -3753,6 +4528,20 @@ name = "zeroize" version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", +] [[package]] name = "zerotrie" diff --git a/Cargo.toml b/Cargo.toml index 9f09ea8..3d6f2e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitkitcore" -version = "0.1.38" +version = "0.1.40" edition = "2021" [lib] @@ -36,6 +36,24 @@ hex = "0.4.3" bip39 = "2.0" bdk = { version = "0.30.2", features = ["all-keys"] } base64 = "0.22" +log = "0.4" + +# Bluetooth (for Android JNI initialization) +# btleplug is also pulled in transitively by trezor-connect-rs +btleplug = "0.11" + +# Trezor connect library - non-iOS platforms get USB + Bluetooth +[target.'cfg(not(target_os = "ios"))'.dependencies] +trezor-connect-rs = { version = "0.2.2", features = ["psbt"] } + +# iOS: Bluetooth only (libusb has no iOS backend, so no USB support) +[target.'cfg(target_os = "ios")'.dependencies] +trezor-connect-rs = { version = "0.2.2", default-features = false, features = ["bluetooth", "psbt"] } + +# JNI for Android (must match btleplug's jni version) +[target.'cfg(target_os = "android")'.dependencies] +jni = "0.19" +android_logger = "0.14" [dev-dependencies] tokio = { version = "1.40.0", features = ["full"] } diff --git a/Package.swift b/Package.swift index 5b9eb98..64c2736 100644 --- a/Package.swift +++ b/Package.swift @@ -3,8 +3,8 @@ import PackageDescription -let tag = "v0.1.38" -let checksum = "9ce93a2e33d94842bfbe625314c6785410e34d187f9fe5af521daee4610f5eda" +let tag = "v0.1.40" +let checksum = "b495e8cb4b1b74ba171a7490fbc4892395c8d5d8758b21caa130562f141e9c29" 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 44812f0..b85c530 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.1.38 +version=0.1.40 diff --git a/bindings/android/lib/src/main/jniLibs/arm64-v8a/libbitkitcore.so b/bindings/android/lib/src/main/jniLibs/arm64-v8a/libbitkitcore.so index 7b39d02..56146d5 100755 Binary files a/bindings/android/lib/src/main/jniLibs/arm64-v8a/libbitkitcore.so and b/bindings/android/lib/src/main/jniLibs/arm64-v8a/libbitkitcore.so differ diff --git a/bindings/android/lib/src/main/jniLibs/armeabi-v7a/libbitkitcore.so b/bindings/android/lib/src/main/jniLibs/armeabi-v7a/libbitkitcore.so index 96236ed..b900154 100755 Binary files a/bindings/android/lib/src/main/jniLibs/armeabi-v7a/libbitkitcore.so and b/bindings/android/lib/src/main/jniLibs/armeabi-v7a/libbitkitcore.so differ diff --git a/bindings/android/lib/src/main/jniLibs/x86/libbitkitcore.so b/bindings/android/lib/src/main/jniLibs/x86/libbitkitcore.so index 85e6b34..5138b76 100755 Binary files a/bindings/android/lib/src/main/jniLibs/x86/libbitkitcore.so and b/bindings/android/lib/src/main/jniLibs/x86/libbitkitcore.so differ diff --git a/bindings/android/lib/src/main/jniLibs/x86_64/libbitkitcore.so b/bindings/android/lib/src/main/jniLibs/x86_64/libbitkitcore.so index 138a39d..0942fc6 100755 Binary files a/bindings/android/lib/src/main/jniLibs/x86_64/libbitkitcore.so and b/bindings/android/lib/src/main/jniLibs/x86_64/libbitkitcore.so differ 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 378b478..0c57e31 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 @@ -19,6 +19,8 @@ package com.synonym.bitkitcore import com.sun.jna.Library import com.sun.jna.Native import com.sun.jna.Structure +import android.os.Build +import androidx.annotation.RequiresApi import kotlin.coroutines.resume import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.DelicateCoroutinesApi @@ -896,6 +898,229 @@ internal typealias UniffiForeignFutureStructVoidUniffiByValue = UniffiForeignFut internal interface UniffiForeignFutureCompleteVoid: com.sun.jna.Callback { public fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructVoidUniffiByValue,) } +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod0: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod1: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod2: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod3: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod4: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`data`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod5: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`uniffiOutReturn`: IntByReference,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod6: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`messageType`: Short,`data`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod7: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod8: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`deviceId`: RustBufferByValue,`credentialJson`: RustBufferByValue,`uniffiOutReturn`: ByteByReference,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod9: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`deviceId`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod10: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`tag`: RustBufferByValue,`message`: RustBufferByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorUiCallbackMethod0: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceTrezorUiCallbackMethod1: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`onDevice`: Byte,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +@Structure.FieldOrder("enumerateDevices", "openDevice", "closeDevice", "readChunk", "writeChunk", "getChunkSize", "callMessage", "getPairingCode", "saveThpCredential", "loadThpCredential", "logDebug", "uniffiFree") +internal open class UniffiVTableCallbackInterfaceTrezorTransportCallbackStruct( + @JvmField public var `enumerateDevices`: UniffiCallbackInterfaceTrezorTransportCallbackMethod0?, + @JvmField public var `openDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod1?, + @JvmField public var `closeDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod2?, + @JvmField public var `readChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod3?, + @JvmField public var `writeChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod4?, + @JvmField public var `getChunkSize`: UniffiCallbackInterfaceTrezorTransportCallbackMethod5?, + @JvmField public var `callMessage`: UniffiCallbackInterfaceTrezorTransportCallbackMethod6?, + @JvmField public var `getPairingCode`: UniffiCallbackInterfaceTrezorTransportCallbackMethod7?, + @JvmField public var `saveThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod8?, + @JvmField public var `loadThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod9?, + @JvmField public var `logDebug`: UniffiCallbackInterfaceTrezorTransportCallbackMethod10?, + @JvmField public var `uniffiFree`: UniffiCallbackInterfaceFree?, +) : com.sun.jna.Structure() { + internal constructor(): this( + + `enumerateDevices` = null, + + `openDevice` = null, + + `closeDevice` = null, + + `readChunk` = null, + + `writeChunk` = null, + + `getChunkSize` = null, + + `callMessage` = null, + + `getPairingCode` = null, + + `saveThpCredential` = null, + + `loadThpCredential` = null, + + `logDebug` = null, + + `uniffiFree` = null, + + ) + + internal class UniffiByValue( + `enumerateDevices`: UniffiCallbackInterfaceTrezorTransportCallbackMethod0?, + `openDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod1?, + `closeDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod2?, + `readChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod3?, + `writeChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod4?, + `getChunkSize`: UniffiCallbackInterfaceTrezorTransportCallbackMethod5?, + `callMessage`: UniffiCallbackInterfaceTrezorTransportCallbackMethod6?, + `getPairingCode`: UniffiCallbackInterfaceTrezorTransportCallbackMethod7?, + `saveThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod8?, + `loadThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod9?, + `logDebug`: UniffiCallbackInterfaceTrezorTransportCallbackMethod10?, + `uniffiFree`: UniffiCallbackInterfaceFree?, + ): UniffiVTableCallbackInterfaceTrezorTransportCallback(`enumerateDevices`,`openDevice`,`closeDevice`,`readChunk`,`writeChunk`,`getChunkSize`,`callMessage`,`getPairingCode`,`saveThpCredential`,`loadThpCredential`,`logDebug`,`uniffiFree`,), Structure.ByValue +} + +internal typealias UniffiVTableCallbackInterfaceTrezorTransportCallback = UniffiVTableCallbackInterfaceTrezorTransportCallbackStruct + +internal fun UniffiVTableCallbackInterfaceTrezorTransportCallback.uniffiSetValue(other: UniffiVTableCallbackInterfaceTrezorTransportCallback) { + `enumerateDevices` = other.`enumerateDevices` + `openDevice` = other.`openDevice` + `closeDevice` = other.`closeDevice` + `readChunk` = other.`readChunk` + `writeChunk` = other.`writeChunk` + `getChunkSize` = other.`getChunkSize` + `callMessage` = other.`callMessage` + `getPairingCode` = other.`getPairingCode` + `saveThpCredential` = other.`saveThpCredential` + `loadThpCredential` = other.`loadThpCredential` + `logDebug` = other.`logDebug` + `uniffiFree` = other.`uniffiFree` +} +internal fun UniffiVTableCallbackInterfaceTrezorTransportCallback.uniffiSetValue(other: UniffiVTableCallbackInterfaceTrezorTransportCallbackUniffiByValue) { + `enumerateDevices` = other.`enumerateDevices` + `openDevice` = other.`openDevice` + `closeDevice` = other.`closeDevice` + `readChunk` = other.`readChunk` + `writeChunk` = other.`writeChunk` + `getChunkSize` = other.`getChunkSize` + `callMessage` = other.`callMessage` + `getPairingCode` = other.`getPairingCode` + `saveThpCredential` = other.`saveThpCredential` + `loadThpCredential` = other.`loadThpCredential` + `logDebug` = other.`logDebug` + `uniffiFree` = other.`uniffiFree` +} + +internal typealias UniffiVTableCallbackInterfaceTrezorTransportCallbackUniffiByValue = UniffiVTableCallbackInterfaceTrezorTransportCallbackStruct.UniffiByValue +@Structure.FieldOrder("onPinRequest", "onPassphraseRequest", "uniffiFree") +internal open class UniffiVTableCallbackInterfaceTrezorUiCallbackStruct( + @JvmField public var `onPinRequest`: UniffiCallbackInterfaceTrezorUiCallbackMethod0?, + @JvmField public var `onPassphraseRequest`: UniffiCallbackInterfaceTrezorUiCallbackMethod1?, + @JvmField public var `uniffiFree`: UniffiCallbackInterfaceFree?, +) : com.sun.jna.Structure() { + internal constructor(): this( + + `onPinRequest` = null, + + `onPassphraseRequest` = null, + + `uniffiFree` = null, + + ) + + internal class UniffiByValue( + `onPinRequest`: UniffiCallbackInterfaceTrezorUiCallbackMethod0?, + `onPassphraseRequest`: UniffiCallbackInterfaceTrezorUiCallbackMethod1?, + `uniffiFree`: UniffiCallbackInterfaceFree?, + ): UniffiVTableCallbackInterfaceTrezorUiCallback(`onPinRequest`,`onPassphraseRequest`,`uniffiFree`,), Structure.ByValue +} + +internal typealias UniffiVTableCallbackInterfaceTrezorUiCallback = UniffiVTableCallbackInterfaceTrezorUiCallbackStruct + +internal fun UniffiVTableCallbackInterfaceTrezorUiCallback.uniffiSetValue(other: UniffiVTableCallbackInterfaceTrezorUiCallback) { + `onPinRequest` = other.`onPinRequest` + `onPassphraseRequest` = other.`onPassphraseRequest` + `uniffiFree` = other.`uniffiFree` +} +internal fun UniffiVTableCallbackInterfaceTrezorUiCallback.uniffiSetValue(other: UniffiVTableCallbackInterfaceTrezorUiCallbackUniffiByValue) { + `onPinRequest` = other.`onPinRequest` + `onPassphraseRequest` = other.`onPassphraseRequest` + `uniffiFree` = other.`uniffiFree` +} + +internal typealias UniffiVTableCallbackInterfaceTrezorUiCallbackUniffiByValue = UniffiVTableCallbackInterfaceTrezorUiCallbackStruct.UniffiByValue + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1412,28 +1637,64 @@ internal object IntegrityCheckingUniffiLib : Library { if (uniffi_bitkitcore_checksum_func_test_notification() != 32857.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_compose_transaction() != 25990.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_clear_credentials() != 41940.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_connect() != 6551.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_disconnect() != 48780.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_get_address() != 12910.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_get_connected_device() != 48383.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint() != 20344.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_get_account_info() != 14813.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_get_features() != 13970.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_get_address() != 42202.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_get_public_key() != 13743.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_get_features() != 52582.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_initialize() != 16053.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_handle_deep_link() != 32721.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_is_ble_available() != 12897.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_sign_message() != 18023.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_is_connected() != 42092.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_sign_transaction() != 59932.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_is_initialized() != 59329.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (uniffi_bitkitcore_checksum_func_trezor_verify_message() != 44040.toShort()) { + if (uniffi_bitkitcore_checksum_func_trezor_list_devices() != 32859.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_scan() != 54763.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_set_transport_callback() != 30209.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_set_ui_callback() != 52321.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_sign_message() != 2925.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_sign_tx() != 42467.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt() != 18852.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_trezor_verify_message() != 50739.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (uniffi_bitkitcore_checksum_func_update_activity() != 42510.toShort()) { @@ -1493,6 +1754,45 @@ internal object IntegrityCheckingUniffiLib : Library { if (uniffi_bitkitcore_checksum_func_wipe_all_transaction_details() != 65339.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices() != 18766.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device() != 44156.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device() != 47933.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk() != 7645.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk() != 55967.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size() != 4994.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message() != 19414.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code() != 43475.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential() != 16694.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential() != 48790.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug() != 44848.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request() != 50474.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request() != 63487.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } } // Integrity check functions only @@ -1716,25 +2016,61 @@ internal object IntegrityCheckingUniffiLib : Library { external fun uniffi_bitkitcore_checksum_func_test_notification( ): Short @JvmStatic - external fun uniffi_bitkitcore_checksum_func_trezor_compose_transaction( + external fun uniffi_bitkitcore_checksum_func_trezor_clear_credentials( ): Short @JvmStatic - external fun uniffi_bitkitcore_checksum_func_trezor_get_account_info( + external fun uniffi_bitkitcore_checksum_func_trezor_connect( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_disconnect( ): Short @JvmStatic external fun uniffi_bitkitcore_checksum_func_trezor_get_address( ): Short @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_get_connected_device( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint( + ): Short + @JvmStatic external fun uniffi_bitkitcore_checksum_func_trezor_get_features( ): Short @JvmStatic - external fun uniffi_bitkitcore_checksum_func_trezor_handle_deep_link( + external fun uniffi_bitkitcore_checksum_func_trezor_get_public_key( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_initialize( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_is_ble_available( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_is_connected( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_is_initialized( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_list_devices( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_scan( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_set_transport_callback( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_set_ui_callback( ): Short @JvmStatic external fun uniffi_bitkitcore_checksum_func_trezor_sign_message( ): Short @JvmStatic - external fun uniffi_bitkitcore_checksum_func_trezor_sign_transaction( + external fun uniffi_bitkitcore_checksum_func_trezor_sign_tx( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt( ): Short @JvmStatic external fun uniffi_bitkitcore_checksum_func_trezor_verify_message( @@ -1797,6 +2133,45 @@ internal object IntegrityCheckingUniffiLib : Library { external fun uniffi_bitkitcore_checksum_func_wipe_all_transaction_details( ): Short @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request( + ): Short + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request( + ): Short + @JvmStatic external fun ffi_bitkitcore_uniffi_contract_version( ): Int } @@ -1810,68 +2185,182 @@ internal object UniffiLib : Library { Native.register(UniffiLib::class.java, findLibraryName("bitkitcore")) // No need to check the contract version and checksums, since // we already did that with `IntegrityCheckingUniffiLib` above. + uniffiCallbackInterfaceTrezorTransportCallback.register(this) + uniffiCallbackInterfaceTrezorUiCallback.register(this) + } + // The Cleaner for the whole library + internal val CLEANER: UniffiCleaner by lazy { + UniffiCleaner.create() } @JvmStatic - external fun uniffi_bitkitcore_fn_func_activity_wipe_all( + external fun uniffi_bitkitcore_fn_clone_trezortransportcallback( + `ptr`: Pointer?, uniffiCallStatus: UniffiRustCallStatus, - ): Unit + ): Pointer? @JvmStatic - external fun uniffi_bitkitcore_fn_func_add_pre_activity_metadata( - `preActivityMetadata`: RustBufferByValue, + external fun uniffi_bitkitcore_fn_free_trezortransportcallback( + `ptr`: Pointer?, uniffiCallStatus: UniffiRustCallStatus, ): Unit @JvmStatic - external fun uniffi_bitkitcore_fn_func_add_pre_activity_metadata_tags( - `paymentId`: RustBufferByValue, - `tags`: RustBufferByValue, - uniffiCallStatus: UniffiRustCallStatus, + external fun uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback( + `vtable`: UniffiVTableCallbackInterfaceTrezorTransportCallback, ): Unit @JvmStatic - external fun uniffi_bitkitcore_fn_func_add_tags( - `activityId`: RustBufferByValue, - `tags`: RustBufferByValue, + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices( + `ptr`: Pointer?, uniffiCallStatus: UniffiRustCallStatus, - ): Unit - @JvmStatic - external fun uniffi_bitkitcore_fn_func_blocktank_remove_all_cjit_entries( - ): Long - @JvmStatic - external fun uniffi_bitkitcore_fn_func_blocktank_remove_all_orders( - ): Long - @JvmStatic - external fun uniffi_bitkitcore_fn_func_blocktank_wipe_all( - ): Long + ): RustBufferByValue @JvmStatic - external fun uniffi_bitkitcore_fn_func_broadcast_sweep_transaction( - `psbt`: RustBufferByValue, - `mnemonicPhrase`: RustBufferByValue, - `network`: RustBufferByValue, - `bip39Passphrase`: RustBufferByValue, - `electrumUrl`: RustBufferByValue, - ): Long + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_open_device( + `ptr`: Pointer?, + `path`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue @JvmStatic - external fun uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options( - `params`: RustBufferByValue, + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_close_device( + `ptr`: Pointer?, + `path`: RustBufferByValue, uniffiCallStatus: UniffiRustCallStatus, ): RustBufferByValue @JvmStatic - external fun uniffi_bitkitcore_fn_func_check_sweepable_balances( - `mnemonicPhrase`: RustBufferByValue, - `network`: RustBufferByValue, - `bip39Passphrase`: RustBufferByValue, - `electrumUrl`: RustBufferByValue, - ): Long + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk( + `ptr`: Pointer?, + `path`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue @JvmStatic - external fun uniffi_bitkitcore_fn_func_create_channel_request_url( - `k1`: RustBufferByValue, - `callback`: RustBufferByValue, - `localNodeId`: RustBufferByValue, - `isPrivate`: Byte, - `cancel`: Byte, + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk( + `ptr`: Pointer?, + `path`: RustBufferByValue, + `data`: RustBufferByValue, uniffiCallStatus: UniffiRustCallStatus, ): RustBufferByValue @JvmStatic - external fun uniffi_bitkitcore_fn_func_create_cjit_entry( + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size( + `ptr`: Pointer?, + `path`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): Int + @JvmStatic + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_call_message( + `ptr`: Pointer?, + `path`: RustBufferByValue, + `messageType`: Short, + `data`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code( + `ptr`: Pointer?, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential( + `ptr`: Pointer?, + `deviceId`: RustBufferByValue, + `credentialJson`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): Byte + @JvmStatic + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential( + `ptr`: Pointer?, + `deviceId`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug( + `ptr`: Pointer?, + `tag`: RustBufferByValue, + `message`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_clone_trezoruicallback( + `ptr`: Pointer?, + uniffiCallStatus: UniffiRustCallStatus, + ): Pointer? + @JvmStatic + external fun uniffi_bitkitcore_fn_free_trezoruicallback( + `ptr`: Pointer?, + uniffiCallStatus: UniffiRustCallStatus, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback( + `vtable`: UniffiVTableCallbackInterfaceTrezorUiCallback, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request( + `ptr`: Pointer?, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request( + `ptr`: Pointer?, + `onDevice`: Byte, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_func_activity_wipe_all( + uniffiCallStatus: UniffiRustCallStatus, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_func_add_pre_activity_metadata( + `preActivityMetadata`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_func_add_pre_activity_metadata_tags( + `paymentId`: RustBufferByValue, + `tags`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_func_add_tags( + `activityId`: RustBufferByValue, + `tags`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_func_blocktank_remove_all_cjit_entries( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_blocktank_remove_all_orders( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_blocktank_wipe_all( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_broadcast_sweep_transaction( + `psbt`: RustBufferByValue, + `mnemonicPhrase`: RustBufferByValue, + `network`: RustBufferByValue, + `bip39Passphrase`: RustBufferByValue, + `electrumUrl`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options( + `params`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_func_check_sweepable_balances( + `mnemonicPhrase`: RustBufferByValue, + `network`: RustBufferByValue, + `bip39Passphrase`: RustBufferByValue, + `electrumUrl`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_create_channel_request_url( + `k1`: RustBufferByValue, + `callback`: RustBufferByValue, + `localNodeId`: RustBufferByValue, + `isPrivate`: Byte, + `cancel`: Byte, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_func_create_cjit_entry( `channelSizeSat`: Long, `invoiceSat`: Long, `invoiceDescription`: RustBufferByValue, @@ -2219,123 +2708,80 @@ internal object UniffiLib : Library { `customUrl`: RustBufferByValue, ): Long @JvmStatic - external fun uniffi_bitkitcore_fn_func_trezor_compose_transaction( - `outputs`: RustBufferByValue, - `coin`: RustBufferByValue, - `callbackUrl`: RustBufferByValue, - `requestId`: RustBufferByValue, - `trezorEnvironment`: RustBufferByValue, - `push`: RustBufferByValue, - `sequence`: RustBufferByValue, - `account`: RustBufferByValue, - `feeLevels`: RustBufferByValue, - `skipPermutation`: RustBufferByValue, - `common`: RustBufferByValue, - uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + external fun uniffi_bitkitcore_fn_func_trezor_clear_credentials( + `deviceId`: RustBufferByValue, + ): Long @JvmStatic - external fun uniffi_bitkitcore_fn_func_trezor_get_account_info( - `coin`: RustBufferByValue, - `callbackUrl`: RustBufferByValue, - `requestId`: RustBufferByValue, - `trezorEnvironment`: RustBufferByValue, - `path`: RustBufferByValue, - `descriptor`: RustBufferByValue, - `details`: RustBufferByValue, - `tokens`: RustBufferByValue, - `page`: RustBufferByValue, - `pageSize`: RustBufferByValue, - `from`: RustBufferByValue, - `to`: RustBufferByValue, - `gap`: RustBufferByValue, - `contractFilter`: RustBufferByValue, - `marker`: RustBufferByValue, - `defaultAccountType`: RustBufferByValue, - `suppressBackupWarning`: RustBufferByValue, - `common`: RustBufferByValue, - uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + external fun uniffi_bitkitcore_fn_func_trezor_connect( + `deviceId`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_disconnect( + ): Long @JvmStatic external fun uniffi_bitkitcore_fn_func_trezor_get_address( - `path`: RustBufferByValue, - `callbackUrl`: RustBufferByValue, - `requestId`: RustBufferByValue, - `trezorEnvironment`: RustBufferByValue, - `address`: RustBufferByValue, - `showOnTrezor`: RustBufferByValue, - `chunkify`: RustBufferByValue, - `useEventListener`: RustBufferByValue, - `coin`: RustBufferByValue, - `crossChain`: RustBufferByValue, - `multisig`: RustBufferByValue, - `scriptType`: RustBufferByValue, - `unlockPath`: RustBufferByValue, - `common`: RustBufferByValue, - uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + `params`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_get_connected_device( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint( + ): Long @JvmStatic external fun uniffi_bitkitcore_fn_func_trezor_get_features( - `callbackUrl`: RustBufferByValue, - `requestId`: RustBufferByValue, - `trezorEnvironment`: RustBufferByValue, - uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_get_public_key( + `params`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_initialize( + `credentialPath`: RustBufferByValue, + ): Long @JvmStatic - external fun uniffi_bitkitcore_fn_func_trezor_handle_deep_link( - `callbackUrl`: RustBufferByValue, + external fun uniffi_bitkitcore_fn_func_trezor_is_ble_available( uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + ): Byte @JvmStatic - external fun uniffi_bitkitcore_fn_func_trezor_sign_message( - `path`: RustBufferByValue, - `message`: RustBufferByValue, - `callbackUrl`: RustBufferByValue, - `requestId`: RustBufferByValue, - `trezorEnvironment`: RustBufferByValue, - `coin`: RustBufferByValue, - `hex`: RustBufferByValue, - `noScriptType`: RustBufferByValue, - `common`: RustBufferByValue, + external fun uniffi_bitkitcore_fn_func_trezor_is_connected( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_is_initialized( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_list_devices( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_scan( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_set_transport_callback( + `callback`: Pointer?, uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + ): Unit @JvmStatic - external fun uniffi_bitkitcore_fn_func_trezor_sign_transaction( - `coin`: RustBufferByValue, - `inputs`: RustBufferByValue, - `outputs`: RustBufferByValue, - `callbackUrl`: RustBufferByValue, - `requestId`: RustBufferByValue, - `trezorEnvironment`: RustBufferByValue, - `refTxs`: RustBufferByValue, - `paymentRequests`: RustBufferByValue, - `locktime`: RustBufferByValue, - `version`: RustBufferByValue, - `expiry`: RustBufferByValue, - `versionGroupId`: RustBufferByValue, - `overwintered`: RustBufferByValue, - `timestamp`: RustBufferByValue, - `branchId`: RustBufferByValue, - `push`: RustBufferByValue, - `amountUnit`: RustBufferByValue, - `unlockPath`: RustBufferByValue, - `serialize`: RustBufferByValue, - `chunkify`: RustBufferByValue, - `common`: RustBufferByValue, + external fun uniffi_bitkitcore_fn_func_trezor_set_ui_callback( + `callback`: Pointer?, uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_sign_message( + `params`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_sign_tx( + `params`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt( + `psbtBase64`: RustBufferByValue, + `network`: RustBufferByValue, + ): Long @JvmStatic external fun uniffi_bitkitcore_fn_func_trezor_verify_message( - `address`: RustBufferByValue, - `signature`: RustBufferByValue, - `message`: RustBufferByValue, - `coin`: RustBufferByValue, - `callbackUrl`: RustBufferByValue, - `requestId`: RustBufferByValue, - `trezorEnvironment`: RustBufferByValue, - `hex`: RustBufferByValue, - `common`: RustBufferByValue, - uniffiCallStatus: UniffiRustCallStatus, - ): RustBufferByValue + `params`: RustBufferByValue, + ): Long @JvmStatic external fun uniffi_bitkitcore_fn_func_update_activity( `activityId`: RustBufferByValue, @@ -2700,25 +3146,115 @@ public fun uniffiEnsureInitialized() { // Public interface members begin here. +internal const val IDX_CALLBACK_FREE = 0 +// Callback return codes +internal const val UNIFFI_CALLBACK_SUCCESS = 0 +internal const val UNIFFI_CALLBACK_ERROR = 1 +internal const val UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2 +public abstract class FfiConverterCallbackInterface: FfiConverter { + internal val handleMap = UniffiHandleMap() -public object FfiConverterUByte: FfiConverter { - override fun lift(value: Byte): UByte { - return value.toUByte() + internal fun drop(handle: Long) { + handleMap.remove(handle) } - override fun read(buf: ByteBuffer): UByte { - return lift(buf.get()) + override fun lift(value: Long): CallbackInterface { + return handleMap.get(value) + } + + override fun read(buf: ByteBuffer): CallbackInterface = lift(buf.getLong()) + + override fun lower(value: CallbackInterface): Long = handleMap.insert(value) + + override fun allocationSize(value: CallbackInterface): ULong = 8UL + + override fun write(value: CallbackInterface, buf: ByteBuffer) { + buf.putLong(lower(value)) + } +} +// The cleaner interface for Object finalization code to run. +// This is the entry point to any implementation that we're using. +// +// The cleaner registers disposables and returns cleanables, so now we are +// defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the +// different implementations available at compile time. +public interface UniffiCleaner { + public interface Cleanable { + public fun clean() + } + + public fun register(resource: Any, disposable: Disposable): UniffiCleaner.Cleanable + + public companion object +} +// The fallback Jna cleaner, which is available for both Android, and the JVM. +private class UniffiJnaCleaner : UniffiCleaner { + private val cleaner = com.sun.jna.internal.Cleaner.getCleaner() + + override fun register(resource: Any, disposable: Disposable): UniffiCleaner.Cleanable = + UniffiJnaCleanable(cleaner.register(resource, UniffiCleanerAction(disposable))) +} + +private class UniffiJnaCleanable( + private val cleanable: com.sun.jna.internal.Cleaner.Cleanable, +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + +private class UniffiCleanerAction(private val disposable: Disposable): Runnable { + override fun run() { + disposable.destroy() + } +} + +// The SystemCleaner, available from API Level 33. +// Some API Level 33 OSes do not support using it, so we require API Level 34. +@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) +private class AndroidSystemCleaner : UniffiCleaner { + private val cleaner = android.system.SystemCleaner.cleaner() + + override fun register(resource: Any, disposable: Disposable): UniffiCleaner.Cleanable = + AndroidSystemCleanable(cleaner.register(resource, UniffiCleanerAction(disposable))) +} + +@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) +private class AndroidSystemCleanable( + private val cleanable: java.lang.ref.Cleaner.Cleanable, +) : UniffiCleaner.Cleanable { + override fun clean() = cleanable.clean() +} + +private fun UniffiCleaner.Companion.create(): UniffiCleaner { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + try { + return AndroidSystemCleaner() + } catch (_: IllegalAccessError) { + // (For Compose preview) Fallback to UniffiJnaCleaner if AndroidSystemCleaner is + // unavailable, even for API level 34 or higher. + } + } + return UniffiJnaCleaner() +} + + +public object FfiConverterUShort: FfiConverter { + override fun lift(value: Short): UShort { + return value.toUShort() + } + + override fun read(buf: ByteBuffer): UShort { + return lift(buf.getShort()) } - override fun lower(value: UByte): Byte { - return value.toByte() + override fun lower(value: UShort): Short { + return value.toShort() } - override fun allocationSize(value: UByte): ULong = 1UL + override fun allocationSize(value: UShort): ULong = 2UL - override fun write(value: UByte, buf: ByteBuffer) { - buf.put(value.toByte()) + override fun write(value: UShort, buf: ByteBuffer) { + buf.putShort(value.toShort()) } } @@ -2894,169 +3430,876 @@ public object FfiConverterByteArray: FfiConverterRustBuffer { +/** + * Callback interface for native Trezor transport operations + * + * 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 TrezorTransportCallbackImpl: Disposable, TrezorTransportCallback { -public object FfiConverterTypeAccountAddresses: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AccountAddresses { - return AccountAddresses( - FfiConverterSequenceTypeAddressInfo.read(buf), - FfiConverterSequenceTypeAddressInfo.read(buf), - FfiConverterSequenceTypeAddressInfo.read(buf), - ) + public constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiPointerDestroyer(pointer)) } - override fun allocationSize(value: AccountAddresses): ULong = ( - FfiConverterSequenceTypeAddressInfo.allocationSize(value.`used`) + - FfiConverterSequenceTypeAddressInfo.allocationSize(value.`unused`) + - FfiConverterSequenceTypeAddressInfo.allocationSize(value.`change`) - ) - - override fun write(value: AccountAddresses, buf: ByteBuffer) { - FfiConverterSequenceTypeAddressInfo.write(value.`used`, buf) - FfiConverterSequenceTypeAddressInfo.write(value.`unused`, buf) - FfiConverterSequenceTypeAddressInfo.write(value.`change`, buf) + /** + * 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() -public object FfiConverterTypeAccountInfoResponse: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AccountInfoResponse { - return AccountInfoResponse( - FfiConverterUInt.read(buf), - FfiConverterString.read(buf), - FfiConverterString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterString.read(buf), - FfiConverterString.read(buf), - ) + private fun synchronized(block: () -> T): T { + lock.lock() + try { + return block() + } finally { + lock.unlock() + } } - override fun allocationSize(value: AccountInfoResponse): ULong = ( - FfiConverterUInt.allocationSize(value.`id`) + - FfiConverterString.allocationSize(value.`path`) + - FfiConverterString.allocationSize(value.`descriptor`) + - FfiConverterOptionalString.allocationSize(value.`legacyXpub`) + - FfiConverterString.allocationSize(value.`balance`) + - FfiConverterString.allocationSize(value.`availableBalance`) - ) - - override fun write(value: AccountInfoResponse, buf: ByteBuffer) { - FfiConverterUInt.write(value.`id`, buf) - FfiConverterString.write(value.`path`, buf) - FfiConverterString.write(value.`descriptor`, buf) - FfiConverterOptionalString.write(value.`legacyXpub`, buf) - FfiConverterString.write(value.`balance`, buf) - FfiConverterString.write(value.`availableBalance`, buf) + 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() + } + } } -} - - - -public object FfiConverterTypeAccountUtxo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AccountUtxo { - return AccountUtxo( - FfiConverterString.read(buf), - FfiConverterUInt.read(buf), - FfiConverterString.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterString.read(buf), - FfiConverterString.read(buf), - FfiConverterOptionalUInt.read(buf), - ) + override fun close() { + synchronized { this.destroy() } } - override fun allocationSize(value: AccountUtxo): ULong = ( - FfiConverterString.allocationSize(value.`txid`) + - FfiConverterUInt.allocationSize(value.`vout`) + - FfiConverterString.allocationSize(value.`amount`) + - FfiConverterOptionalUInt.allocationSize(value.`blockHeight`) + - FfiConverterString.allocationSize(value.`address`) + - FfiConverterString.allocationSize(value.`path`) + - FfiConverterOptionalUInt.allocationSize(value.`confirmations`) - ) - - override fun write(value: AccountUtxo, buf: ByteBuffer) { - FfiConverterString.write(value.`txid`, buf) - FfiConverterUInt.write(value.`vout`, buf) - FfiConverterString.write(value.`amount`, buf) - FfiConverterOptionalUInt.write(value.`blockHeight`, buf) - FfiConverterString.write(value.`address`, buf) - FfiConverterString.write(value.`path`, buf) - FfiConverterOptionalUInt.write(value.`confirmations`, buf) + 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_trezortransportcallback(ptr, status) + } + } + } + } + public fun uniffiClonePointer(): Pointer { + return uniffiRustCall { status -> + UniffiLib.uniffi_bitkitcore_fn_clone_trezortransportcallback(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, + ) + } + }) + } -public object FfiConverterTypeActivityTags: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ActivityTags { - return ActivityTags( - FfiConverterString.read(buf), - FfiConverterSequenceString.read(buf), - ) + /** + * Open a connection to a device + */ + public override fun `openDevice`(`path`: kotlin.String): TrezorTransportWriteResult { + return FfiConverterTypeTrezorTransportWriteResult.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_open_device( + it, + FfiConverterString.lower(`path`), + uniffiRustCallStatus, + ) + } + }) } - override fun allocationSize(value: ActivityTags): ULong = ( - FfiConverterString.allocationSize(value.`activityId`) + - FfiConverterSequenceString.allocationSize(value.`tags`) + /** + * 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, + ) + } + }) + } + + /** + * 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, + ) + } + }) + } + + /** + * 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, + ) + } + }) + } + + /** + * 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, ) - override fun write(value: ActivityTags, buf: ByteBuffer) { - FfiConverterString.write(value.`activityId`, buf) - FfiConverterSequenceString.write(value.`tags`, buf) + 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. + * + * Methods return `String`: + * - Empty string (`""`) = cancel the request + * - Non-empty string = the user's input (PIN or passphrase) + * + * This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. + */ +public open class TrezorUiCallbackImpl: Disposable, TrezorUiCallback { -public object FfiConverterTypeAddressInfo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AddressInfo { - return AddressInfo( - FfiConverterString.read(buf), - FfiConverterString.read(buf), - FfiConverterUInt.read(buf), - ) + public constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiPointerDestroyer(pointer)) } - override fun allocationSize(value: AddressInfo): ULong = ( - FfiConverterString.allocationSize(value.`address`) + - FfiConverterString.allocationSize(value.`path`) + - FfiConverterUInt.allocationSize(value.`transfers`) + /** + * 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 user should enter on the Trezor itself — + * return any non-empty string (e.g., "ok") to acknowledge. + * + * If `on_device` is false, show a passphrase input UI and return the value. + * Return empty string to cancel. + */ + public override fun `onPassphraseRequest`(`onDevice`: kotlin.Boolean): kotlin.String { + return FfiConverterString.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()) + } +} + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTrezorUiCallback { + internal object `onPinRequest`: UniffiCallbackInterfaceTrezorUiCallbackMethod0 { + override fun callback ( + `uniffiHandle`: Long, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorUiCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onPinRequest`( + ) + } + val writeReturn = { uniffiResultValue: kotlin.String -> + uniffiOutReturn.setValue(FfiConverterString.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `onPassphraseRequest`: UniffiCallbackInterfaceTrezorUiCallbackMethod1 { + override fun callback ( + `uniffiHandle`: Long, + `onDevice`: Byte, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorUiCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onPassphraseRequest`( + FfiConverterBoolean.lift(`onDevice`), + ) + } + val writeReturn = { uniffiResultValue: kotlin.String -> + uniffiOutReturn.setValue(FfiConverterString.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTrezorUiCallback.handleMap.remove(handle) + } + } + + internal val vtable = UniffiVTableCallbackInterfaceTrezorUiCallback( + `onPinRequest`, + `onPassphraseRequest`, + uniffiFree, ) - override fun write(value: AddressInfo, buf: ByteBuffer) { - FfiConverterString.write(value.`address`, buf) - FfiConverterString.write(value.`path`, buf) - FfiConverterUInt.write(value.`transfers`, buf) + internal fun register(lib: UniffiLib) { + lib.uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(vtable) } } -public object FfiConverterTypeAddressResponse: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AddressResponse { - return AddressResponse( - FfiConverterString.read(buf), - FfiConverterSequenceUInt.read(buf), +public object FfiConverterTypeActivityTags: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActivityTags { + return ActivityTags( FfiConverterString.read(buf), + FfiConverterSequenceString.read(buf), ) } - override fun allocationSize(value: AddressResponse): ULong = ( - FfiConverterString.allocationSize(value.`address`) + - FfiConverterSequenceUInt.allocationSize(value.`path`) + - FfiConverterString.allocationSize(value.`serializedPath`) + override fun allocationSize(value: ActivityTags): ULong = ( + FfiConverterString.allocationSize(value.`activityId`) + + FfiConverterSequenceString.allocationSize(value.`tags`) ) - override fun write(value: AddressResponse, buf: ByteBuffer) { - FfiConverterString.write(value.`address`, buf) - FfiConverterSequenceUInt.write(value.`path`, buf) - FfiConverterString.write(value.`serializedPath`, buf) + override fun write(value: ActivityTags, buf: ByteBuffer) { + FfiConverterString.write(value.`activityId`, buf) + FfiConverterSequenceString.write(value.`tags`, buf) } } @@ -3180,92 +4423,11 @@ public object FfiConverterTypeClosedChannelDetails: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CoinPurchaseMemo { - return CoinPurchaseMemo( - FfiConverterUInt.read(buf), - FfiConverterULong.read(buf), - FfiConverterString.read(buf), - FfiConverterString.read(buf), - ) - } - - override fun allocationSize(value: CoinPurchaseMemo): ULong = ( - FfiConverterUInt.allocationSize(value.`coinType`) + - FfiConverterULong.allocationSize(value.`amount`) + - FfiConverterString.allocationSize(value.`address`) + - FfiConverterString.allocationSize(value.`mac`) - ) - - override fun write(value: CoinPurchaseMemo, buf: ByteBuffer) { - FfiConverterUInt.write(value.`coinType`, buf) - FfiConverterULong.write(value.`amount`, buf) - FfiConverterString.write(value.`address`, buf) - FfiConverterString.write(value.`mac`, buf) - } -} - - - - -public object FfiConverterTypeCommonParams: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CommonParams { - return CommonParams( - FfiConverterOptionalTypeDeviceParams.read(buf), - FfiConverterOptionalBoolean.read(buf), - FfiConverterOptionalBoolean.read(buf), - FfiConverterOptionalBoolean.read(buf), - ) - } - - override fun allocationSize(value: CommonParams): ULong = ( - FfiConverterOptionalTypeDeviceParams.allocationSize(value.`device`) + - FfiConverterOptionalBoolean.allocationSize(value.`useEmptyPassphrase`) + - FfiConverterOptionalBoolean.allocationSize(value.`allowSeedlessDevice`) + - FfiConverterOptionalBoolean.allocationSize(value.`skipFinalReload`) - ) - - override fun write(value: CommonParams, buf: ByteBuffer) { - FfiConverterOptionalTypeDeviceParams.write(value.`device`, buf) - FfiConverterOptionalBoolean.write(value.`useEmptyPassphrase`, buf) - FfiConverterOptionalBoolean.write(value.`allowSeedlessDevice`, buf) - FfiConverterOptionalBoolean.write(value.`skipFinalReload`, buf) - } -} - - - - -public object FfiConverterTypeComposeAccount: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ComposeAccount { - return ComposeAccount( - FfiConverterString.read(buf), - FfiConverterTypeAccountAddresses.read(buf), - FfiConverterSequenceTypeAccountUtxo.read(buf), - ) - } - - override fun allocationSize(value: ComposeAccount): ULong = ( - FfiConverterString.allocationSize(value.`path`) + - FfiConverterTypeAccountAddresses.allocationSize(value.`addresses`) + - FfiConverterSequenceTypeAccountUtxo.allocationSize(value.`utxo`) - ) - - override fun write(value: ComposeAccount, buf: ByteBuffer) { - FfiConverterString.write(value.`path`, buf) - FfiConverterTypeAccountAddresses.write(value.`addresses`, buf) - FfiConverterSequenceTypeAccountUtxo.write(value.`utxo`, buf) - } -} - - - - -public object FfiConverterTypeCreateCjitOptions: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CreateCjitOptions { - return CreateCjitOptions( - FfiConverterOptionalString.read(buf), - FfiConverterOptionalString.read(buf), +public object FfiConverterTypeCreateCjitOptions: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CreateCjitOptions { + return CreateCjitOptions( + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), ) } @@ -3338,28 +4500,6 @@ public object FfiConverterTypeCreateOrderOptions: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): DeepLinkResult { - return DeepLinkResult( - FfiConverterString.read(buf), - FfiConverterString.read(buf), - ) - } - - override fun allocationSize(value: DeepLinkResult): ULong = ( - FfiConverterString.allocationSize(value.`url`) + - FfiConverterString.allocationSize(value.`requestId`) - ) - - override fun write(value: DeepLinkResult, buf: ByteBuffer) { - FfiConverterString.write(value.`url`, buf) - FfiConverterString.write(value.`requestId`, buf) - } -} - - - - public object FfiConverterTypeDefaultLspBalanceParams: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): DefaultLspBalanceParams { return DefaultLspBalanceParams( @@ -3385,28 +4525,6 @@ public object FfiConverterTypeDefaultLspBalanceParams: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): DeviceParams { - return DeviceParams( - FfiConverterOptionalString.read(buf), - FfiConverterOptionalUInt.read(buf), - ) - } - - override fun allocationSize(value: DeviceParams): ULong = ( - FfiConverterOptionalString.allocationSize(value.`path`) + - FfiConverterOptionalUInt.allocationSize(value.`instance`) - ) - - override fun write(value: DeviceParams, buf: ByteBuffer) { - FfiConverterOptionalString.write(value.`path`, buf) - FfiConverterOptionalUInt.write(value.`instance`, buf) - } -} - - - - public object FfiConverterTypeErrorData: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): ErrorData { return ErrorData( @@ -3426,65 +4544,6 @@ public object FfiConverterTypeErrorData: FfiConverterRustBuffer { -public object FfiConverterTypeFeatureResponse: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): FeatureResponse { - return FeatureResponse( - FfiConverterString.read(buf), - FfiConverterUInt.read(buf), - FfiConverterUInt.read(buf), - FfiConverterUInt.read(buf), - FfiConverterString.read(buf), - FfiConverterOptionalSequenceString.read(buf), - ) - } - - override fun allocationSize(value: FeatureResponse): ULong = ( - FfiConverterString.allocationSize(value.`vendor`) + - FfiConverterUInt.allocationSize(value.`majorVersion`) + - FfiConverterUInt.allocationSize(value.`minorVersion`) + - FfiConverterUInt.allocationSize(value.`patchVersion`) + - FfiConverterString.allocationSize(value.`deviceId`) + - FfiConverterOptionalSequenceString.allocationSize(value.`capabilities`) - ) - - override fun write(value: FeatureResponse, buf: ByteBuffer) { - FfiConverterString.write(value.`vendor`, buf) - FfiConverterUInt.write(value.`majorVersion`, buf) - FfiConverterUInt.write(value.`minorVersion`, buf) - FfiConverterUInt.write(value.`patchVersion`, buf) - FfiConverterString.write(value.`deviceId`, buf) - FfiConverterOptionalSequenceString.write(value.`capabilities`, buf) - } -} - - - - -public object FfiConverterTypeFeeLevel: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): FeeLevel { - return FeeLevel( - FfiConverterString.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalBoolean.read(buf), - ) - } - - override fun allocationSize(value: FeeLevel): ULong = ( - FfiConverterString.allocationSize(value.`feePerUnit`) + - FfiConverterOptionalUInt.allocationSize(value.`baseFee`) + - FfiConverterOptionalBoolean.allocationSize(value.`floorBaseFee`) - ) - - override fun write(value: FeeLevel, buf: ByteBuffer) { - FfiConverterString.write(value.`feePerUnit`, buf) - FfiConverterOptionalUInt.write(value.`baseFee`, buf) - FfiConverterOptionalBoolean.write(value.`floorBaseFee`, buf) - } -} - - - - public object FfiConverterTypeFeeRates: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): FeeRates { return FeeRates( @@ -3576,65 +4635,6 @@ public object FfiConverterTypeGetAddressesResponse: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): HdNodePathType { - return HdNodePathType( - FfiConverterTypeHDNodeTypeOrString.read(buf), - FfiConverterSequenceUInt.read(buf), - ) - } - - override fun allocationSize(value: HdNodePathType): ULong = ( - FfiConverterTypeHDNodeTypeOrString.allocationSize(value.`node`) + - FfiConverterSequenceUInt.allocationSize(value.`addressN`) - ) - - override fun write(value: HdNodePathType, buf: ByteBuffer) { - FfiConverterTypeHDNodeTypeOrString.write(value.`node`, buf) - FfiConverterSequenceUInt.write(value.`addressN`, buf) - } -} - - - - -public object FfiConverterTypeHDNodeType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): HdNodeType { - return HdNodeType( - FfiConverterUInt.read(buf), - FfiConverterUInt.read(buf), - FfiConverterUInt.read(buf), - FfiConverterString.read(buf), - FfiConverterString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterOptionalSequenceUInt.read(buf), - ) - } - - override fun allocationSize(value: HdNodeType): ULong = ( - FfiConverterUInt.allocationSize(value.`depth`) + - FfiConverterUInt.allocationSize(value.`fingerprint`) + - FfiConverterUInt.allocationSize(value.`childNum`) + - FfiConverterString.allocationSize(value.`chainCode`) + - FfiConverterString.allocationSize(value.`publicKey`) + - FfiConverterOptionalString.allocationSize(value.`privateKey`) + - FfiConverterOptionalSequenceUInt.allocationSize(value.`addressN`) - ) - - override fun write(value: HdNodeType, buf: ByteBuffer) { - FfiConverterUInt.write(value.`depth`, buf) - FfiConverterUInt.write(value.`fingerprint`, buf) - FfiConverterUInt.write(value.`childNum`, buf) - FfiConverterString.write(value.`chainCode`, buf) - FfiConverterString.write(value.`publicKey`, buf) - FfiConverterOptionalString.write(value.`privateKey`, buf) - FfiConverterOptionalSequenceUInt.write(value.`addressN`, buf) - } -} - - - - public object FfiConverterTypeIBt0ConfMinTxFeeWindow: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): IBt0ConfMinTxFeeWindow { return IBt0ConfMinTxFeeWindow( @@ -4888,53 +5888,31 @@ public object FfiConverterTypeLnurlWithdrawData: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): MessageSignatureResponse { - return MessageSignatureResponse( +public object FfiConverterTypeNativeDeviceInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): NativeDeviceInfo { + return NativeDeviceInfo( FfiConverterString.read(buf), FfiConverterString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalUShort.read(buf), + FfiConverterOptionalUShort.read(buf), ) } - override fun allocationSize(value: MessageSignatureResponse): ULong = ( - FfiConverterString.allocationSize(value.`address`) + - FfiConverterString.allocationSize(value.`signature`) - ) - - override fun write(value: MessageSignatureResponse, buf: ByteBuffer) { - FfiConverterString.write(value.`address`, buf) - FfiConverterString.write(value.`signature`, buf) - } -} - - - - -public object FfiConverterTypeMultisigRedeemScriptType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): MultisigRedeemScriptType { - return MultisigRedeemScriptType( - FfiConverterSequenceTypeHDNodePathType.read(buf), - FfiConverterSequenceString.read(buf), - FfiConverterUInt.read(buf), - FfiConverterOptionalSequenceTypeHDNodeType.read(buf), - FfiConverterOptionalUByte.read(buf), - ) - } - - override fun allocationSize(value: MultisigRedeemScriptType): ULong = ( - FfiConverterSequenceTypeHDNodePathType.allocationSize(value.`pubkeys`) + - FfiConverterSequenceString.allocationSize(value.`signatures`) + - FfiConverterUInt.allocationSize(value.`m`) + - FfiConverterOptionalSequenceTypeHDNodeType.allocationSize(value.`nodes`) + - FfiConverterOptionalUByte.allocationSize(value.`pubkeysOrder`) + override fun allocationSize(value: NativeDeviceInfo): ULong = ( + FfiConverterString.allocationSize(value.`path`) + + FfiConverterString.allocationSize(value.`transportType`) + + FfiConverterOptionalString.allocationSize(value.`name`) + + FfiConverterOptionalUShort.allocationSize(value.`vendorId`) + + FfiConverterOptionalUShort.allocationSize(value.`productId`) ) - override fun write(value: MultisigRedeemScriptType, buf: ByteBuffer) { - FfiConverterSequenceTypeHDNodePathType.write(value.`pubkeys`, buf) - FfiConverterSequenceString.write(value.`signatures`, buf) - FfiConverterUInt.write(value.`m`, buf) - FfiConverterOptionalSequenceTypeHDNodeType.write(value.`nodes`, buf) - FfiConverterOptionalUByte.write(value.`pubkeysOrder`, buf) + override fun write(value: NativeDeviceInfo, buf: ByteBuffer) { + FfiConverterString.write(value.`path`, buf) + FfiConverterString.write(value.`transportType`, buf) + FfiConverterOptionalString.write(value.`name`, buf) + FfiConverterOptionalUShort.write(value.`vendorId`, buf) + FfiConverterOptionalUShort.write(value.`productId`, buf) } } @@ -5045,31 +6023,6 @@ public object FfiConverterTypeOnchainActivity: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PaymentRequestMemo { - return PaymentRequestMemo( - FfiConverterOptionalTypeTextMemo.read(buf), - FfiConverterOptionalTypeRefundMemo.read(buf), - FfiConverterOptionalTypeCoinPurchaseMemo.read(buf), - ) - } - - override fun allocationSize(value: PaymentRequestMemo): ULong = ( - FfiConverterOptionalTypeTextMemo.allocationSize(value.`textMemo`) + - FfiConverterOptionalTypeRefundMemo.allocationSize(value.`refundMemo`) + - FfiConverterOptionalTypeCoinPurchaseMemo.allocationSize(value.`coinPurchaseMemo`) - ) - - override fun write(value: PaymentRequestMemo, buf: ByteBuffer) { - FfiConverterOptionalTypeTextMemo.write(value.`textMemo`, buf) - FfiConverterOptionalTypeRefundMemo.write(value.`refundMemo`, buf) - FfiConverterOptionalTypeCoinPurchaseMemo.write(value.`coinPurchaseMemo`, buf) - } -} - - - - public object FfiConverterTypePreActivityMetadata: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): PreActivityMetadata { return PreActivityMetadata( @@ -5116,765 +6069,801 @@ public object FfiConverterTypePreActivityMetadata: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PrecomposedInput { - return PrecomposedInput( - FfiConverterSequenceUInt.read(buf), - FfiConverterString.read(buf), +public object FfiConverterTypePubkyAuth: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PubkyAuth { + return PubkyAuth( FfiConverterString.read(buf), - FfiConverterUInt.read(buf), - FfiConverterTypeScriptType.read(buf), ) } - override fun allocationSize(value: PrecomposedInput): ULong = ( - FfiConverterSequenceUInt.allocationSize(value.`addressN`) + - FfiConverterString.allocationSize(value.`amount`) + - FfiConverterString.allocationSize(value.`prevHash`) + - FfiConverterUInt.allocationSize(value.`prevIndex`) + - FfiConverterTypeScriptType.allocationSize(value.`scriptType`) + override fun allocationSize(value: PubkyAuth): ULong = ( + FfiConverterString.allocationSize(value.`data`) ) - override fun write(value: PrecomposedInput, buf: ByteBuffer) { - FfiConverterSequenceUInt.write(value.`addressN`, buf) - FfiConverterString.write(value.`amount`, buf) - FfiConverterString.write(value.`prevHash`, buf) - FfiConverterUInt.write(value.`prevIndex`, buf) - FfiConverterTypeScriptType.write(value.`scriptType`, buf) + override fun write(value: PubkyAuth, buf: ByteBuffer) { + FfiConverterString.write(value.`data`, buf) } } -public object FfiConverterTypePrecomposedOutput: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PrecomposedOutput { - return PrecomposedOutput( - FfiConverterOptionalSequenceUInt.read(buf), +public object FfiConverterTypeSweepResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SweepResult { + return SweepResult( FfiConverterString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterTypeScriptType.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterUInt.read(buf), ) } - override fun allocationSize(value: PrecomposedOutput): ULong = ( - FfiConverterOptionalSequenceUInt.allocationSize(value.`addressN`) + - FfiConverterString.allocationSize(value.`amount`) + - FfiConverterOptionalString.allocationSize(value.`address`) + - FfiConverterTypeScriptType.allocationSize(value.`scriptType`) + override fun allocationSize(value: SweepResult): ULong = ( + FfiConverterString.allocationSize(value.`txid`) + + FfiConverterULong.allocationSize(value.`amountSwept`) + + FfiConverterULong.allocationSize(value.`feePaid`) + + FfiConverterUInt.allocationSize(value.`utxosSwept`) ) - override fun write(value: PrecomposedOutput, buf: ByteBuffer) { - FfiConverterOptionalSequenceUInt.write(value.`addressN`, buf) - FfiConverterString.write(value.`amount`, buf) - FfiConverterOptionalString.write(value.`address`, buf) - FfiConverterTypeScriptType.write(value.`scriptType`, buf) + override fun write(value: SweepResult, buf: ByteBuffer) { + FfiConverterString.write(value.`txid`, buf) + FfiConverterULong.write(value.`amountSwept`, buf) + FfiConverterULong.write(value.`feePaid`, buf) + FfiConverterUInt.write(value.`utxosSwept`, buf) } } -public object FfiConverterTypePrecomposedTransaction: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PrecomposedTransaction { - return PrecomposedTransaction( +public object FfiConverterTypeSweepTransactionPreview: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SweepTransactionPreview { + return SweepTransactionPreview( FfiConverterString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalSequenceTypePrecomposedInput.read(buf), - FfiConverterOptionalSequenceTypePrecomposedOutput.read(buf), - FfiConverterOptionalSequenceUInt.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterUInt.read(buf), + FfiConverterString.read(buf), + FfiConverterULong.read(buf), ) } - override fun allocationSize(value: PrecomposedTransaction): ULong = ( - FfiConverterString.allocationSize(value.`txType`) + - FfiConverterOptionalString.allocationSize(value.`totalSpent`) + - FfiConverterOptionalString.allocationSize(value.`fee`) + - FfiConverterOptionalString.allocationSize(value.`feePerByte`) + - FfiConverterOptionalUInt.allocationSize(value.`bytes`) + - FfiConverterOptionalSequenceTypePrecomposedInput.allocationSize(value.`inputs`) + - FfiConverterOptionalSequenceTypePrecomposedOutput.allocationSize(value.`outputs`) + - FfiConverterOptionalSequenceUInt.allocationSize(value.`outputsPermutation`) + override fun allocationSize(value: SweepTransactionPreview): ULong = ( + FfiConverterString.allocationSize(value.`psbt`) + + FfiConverterULong.allocationSize(value.`totalAmount`) + + FfiConverterULong.allocationSize(value.`estimatedFee`) + + FfiConverterULong.allocationSize(value.`estimatedVsize`) + + FfiConverterUInt.allocationSize(value.`utxosCount`) + + FfiConverterString.allocationSize(value.`destinationAddress`) + + FfiConverterULong.allocationSize(value.`amountAfterFees`) ) - override fun write(value: PrecomposedTransaction, buf: ByteBuffer) { - FfiConverterString.write(value.`txType`, buf) - FfiConverterOptionalString.write(value.`totalSpent`, buf) - FfiConverterOptionalString.write(value.`fee`, buf) - FfiConverterOptionalString.write(value.`feePerByte`, buf) - FfiConverterOptionalUInt.write(value.`bytes`, buf) - FfiConverterOptionalSequenceTypePrecomposedInput.write(value.`inputs`, buf) - FfiConverterOptionalSequenceTypePrecomposedOutput.write(value.`outputs`, buf) - FfiConverterOptionalSequenceUInt.write(value.`outputsPermutation`, buf) + override fun write(value: SweepTransactionPreview, buf: ByteBuffer) { + FfiConverterString.write(value.`psbt`, buf) + FfiConverterULong.write(value.`totalAmount`, buf) + FfiConverterULong.write(value.`estimatedFee`, buf) + FfiConverterULong.write(value.`estimatedVsize`, buf) + FfiConverterUInt.write(value.`utxosCount`, buf) + FfiConverterString.write(value.`destinationAddress`, buf) + FfiConverterULong.write(value.`amountAfterFees`, buf) } } -public object FfiConverterTypePubkyAuth: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PubkyAuth { - return PubkyAuth( - FfiConverterString.read(buf), +public object FfiConverterTypeSweepableBalances: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SweepableBalances { + return SweepableBalances( + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), ) } - override fun allocationSize(value: PubkyAuth): ULong = ( - FfiConverterString.allocationSize(value.`data`) - ) - - override fun write(value: PubkyAuth, buf: ByteBuffer) { - FfiConverterString.write(value.`data`, buf) + override fun allocationSize(value: SweepableBalances): ULong = ( + FfiConverterULong.allocationSize(value.`legacyBalance`) + + FfiConverterULong.allocationSize(value.`p2shBalance`) + + FfiConverterULong.allocationSize(value.`taprootBalance`) + + FfiConverterULong.allocationSize(value.`totalBalance`) + + FfiConverterUInt.allocationSize(value.`legacyUtxosCount`) + + FfiConverterUInt.allocationSize(value.`p2shUtxosCount`) + + FfiConverterUInt.allocationSize(value.`taprootUtxosCount`) + + FfiConverterUInt.allocationSize(value.`totalUtxosCount`) + ) + + override fun write(value: SweepableBalances, buf: ByteBuffer) { + FfiConverterULong.write(value.`legacyBalance`, buf) + FfiConverterULong.write(value.`p2shBalance`, buf) + FfiConverterULong.write(value.`taprootBalance`, buf) + FfiConverterULong.write(value.`totalBalance`, buf) + FfiConverterUInt.write(value.`legacyUtxosCount`, buf) + FfiConverterUInt.write(value.`p2shUtxosCount`, buf) + FfiConverterUInt.write(value.`taprootUtxosCount`, buf) + FfiConverterUInt.write(value.`totalUtxosCount`, buf) } } -public object FfiConverterTypePublicKeyResponse: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PublicKeyResponse { - return PublicKeyResponse( - FfiConverterSequenceUInt.read(buf), - FfiConverterString.read(buf), - FfiConverterString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterString.read(buf), - FfiConverterUInt.read(buf), +public object FfiConverterTypeTransactionDetails: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionDetails { + return TransactionDetails( FfiConverterString.read(buf), - FfiConverterUInt.read(buf), - FfiConverterUInt.read(buf), - FfiConverterOptionalString.read(buf), + FfiConverterLong.read(buf), + FfiConverterSequenceTypeTxInput.read(buf), + FfiConverterSequenceTypeTxOutput.read(buf), ) } - override fun allocationSize(value: PublicKeyResponse): ULong = ( - FfiConverterSequenceUInt.allocationSize(value.`path`) + - FfiConverterString.allocationSize(value.`serializedPath`) + - FfiConverterString.allocationSize(value.`xpub`) + - FfiConverterOptionalString.allocationSize(value.`xpubSegwit`) + - FfiConverterString.allocationSize(value.`chainCode`) + - FfiConverterUInt.allocationSize(value.`childNum`) + - FfiConverterString.allocationSize(value.`publicKey`) + - FfiConverterUInt.allocationSize(value.`fingerprint`) + - FfiConverterUInt.allocationSize(value.`depth`) + - FfiConverterOptionalString.allocationSize(value.`descriptor`) + override fun allocationSize(value: TransactionDetails): ULong = ( + FfiConverterString.allocationSize(value.`txId`) + + FfiConverterLong.allocationSize(value.`amountSats`) + + FfiConverterSequenceTypeTxInput.allocationSize(value.`inputs`) + + FfiConverterSequenceTypeTxOutput.allocationSize(value.`outputs`) ) - override fun write(value: PublicKeyResponse, buf: ByteBuffer) { - FfiConverterSequenceUInt.write(value.`path`, buf) - FfiConverterString.write(value.`serializedPath`, buf) - FfiConverterString.write(value.`xpub`, buf) - FfiConverterOptionalString.write(value.`xpubSegwit`, buf) - FfiConverterString.write(value.`chainCode`, buf) - FfiConverterUInt.write(value.`childNum`, buf) - FfiConverterString.write(value.`publicKey`, buf) - FfiConverterUInt.write(value.`fingerprint`, buf) - FfiConverterUInt.write(value.`depth`, buf) - FfiConverterOptionalString.write(value.`descriptor`, buf) + override fun write(value: TransactionDetails, buf: ByteBuffer) { + FfiConverterString.write(value.`txId`, buf) + FfiConverterLong.write(value.`amountSats`, buf) + FfiConverterSequenceTypeTxInput.write(value.`inputs`, buf) + FfiConverterSequenceTypeTxOutput.write(value.`outputs`, buf) } } -public object FfiConverterTypeRefTransaction: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): RefTransaction { - return RefTransaction( +public object FfiConverterTypeTrezorAddressResponse: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorAddressResponse { + return TrezorAddressResponse( + FfiConverterString.read(buf), FfiConverterString.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterSequenceTypeRefTxInput.read(buf), - FfiConverterSequenceTypeRefTxOutput.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalBoolean.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalString.read(buf), ) } - override fun allocationSize(value: RefTransaction): ULong = ( - FfiConverterString.allocationSize(value.`hash`) + - FfiConverterOptionalUInt.allocationSize(value.`version`) + - FfiConverterSequenceTypeRefTxInput.allocationSize(value.`inputs`) + - FfiConverterSequenceTypeRefTxOutput.allocationSize(value.`binOutputs`) + - FfiConverterOptionalUInt.allocationSize(value.`lockTime`) + - FfiConverterOptionalUInt.allocationSize(value.`expiry`) + - FfiConverterOptionalUInt.allocationSize(value.`versionGroupId`) + - FfiConverterOptionalBoolean.allocationSize(value.`overwintered`) + - FfiConverterOptionalUInt.allocationSize(value.`timestamp`) + - FfiConverterOptionalUInt.allocationSize(value.`branchId`) + - FfiConverterOptionalString.allocationSize(value.`extraData`) + override fun allocationSize(value: TrezorAddressResponse): ULong = ( + FfiConverterString.allocationSize(value.`address`) + + FfiConverterString.allocationSize(value.`path`) ) - override fun write(value: RefTransaction, buf: ByteBuffer) { - FfiConverterString.write(value.`hash`, buf) - FfiConverterOptionalUInt.write(value.`version`, buf) - FfiConverterSequenceTypeRefTxInput.write(value.`inputs`, buf) - FfiConverterSequenceTypeRefTxOutput.write(value.`binOutputs`, buf) - FfiConverterOptionalUInt.write(value.`lockTime`, buf) - FfiConverterOptionalUInt.write(value.`expiry`, buf) - FfiConverterOptionalUInt.write(value.`versionGroupId`, buf) - FfiConverterOptionalBoolean.write(value.`overwintered`, buf) - FfiConverterOptionalUInt.write(value.`timestamp`, buf) - FfiConverterOptionalUInt.write(value.`branchId`, buf) - FfiConverterOptionalString.write(value.`extraData`, buf) + override fun write(value: TrezorAddressResponse, buf: ByteBuffer) { + FfiConverterString.write(value.`address`, buf) + FfiConverterString.write(value.`path`, buf) } } -public object FfiConverterTypeRefTxInput: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): RefTxInput { - return RefTxInput( - FfiConverterString.read(buf), - FfiConverterUInt.read(buf), +public object FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorCallMessageResult { + return TrezorCallMessageResult( + FfiConverterBoolean.read(buf), + FfiConverterUShort.read(buf), + FfiConverterByteArray.read(buf), FfiConverterString.read(buf), - FfiConverterUInt.read(buf), ) } - override fun allocationSize(value: RefTxInput): ULong = ( - FfiConverterString.allocationSize(value.`prevHash`) + - FfiConverterUInt.allocationSize(value.`prevIndex`) + - FfiConverterString.allocationSize(value.`scriptSig`) + - FfiConverterUInt.allocationSize(value.`sequence`) + override fun allocationSize(value: TrezorCallMessageResult): ULong = ( + FfiConverterBoolean.allocationSize(value.`success`) + + FfiConverterUShort.allocationSize(value.`messageType`) + + FfiConverterByteArray.allocationSize(value.`data`) + + FfiConverterString.allocationSize(value.`error`) ) - override fun write(value: RefTxInput, buf: ByteBuffer) { - FfiConverterString.write(value.`prevHash`, buf) - FfiConverterUInt.write(value.`prevIndex`, buf) - FfiConverterString.write(value.`scriptSig`, buf) - FfiConverterUInt.write(value.`sequence`, buf) + override fun write(value: TrezorCallMessageResult, buf: ByteBuffer) { + FfiConverterBoolean.write(value.`success`, buf) + FfiConverterUShort.write(value.`messageType`, buf) + FfiConverterByteArray.write(value.`data`, buf) + FfiConverterString.write(value.`error`, buf) } } -public object FfiConverterTypeRefTxOutput: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): RefTxOutput { - return RefTxOutput( - FfiConverterULong.read(buf), +public object FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorDeviceInfo { + return TrezorDeviceInfo( + FfiConverterString.read(buf), + FfiConverterTypeTrezorTransportType.read(buf), + FfiConverterOptionalString.read(buf), FfiConverterString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterBoolean.read(buf), ) } - override fun allocationSize(value: RefTxOutput): ULong = ( - FfiConverterULong.allocationSize(value.`amount`) + - FfiConverterString.allocationSize(value.`scriptPubkey`) + override fun allocationSize(value: TrezorDeviceInfo): ULong = ( + FfiConverterString.allocationSize(value.`id`) + + FfiConverterTypeTrezorTransportType.allocationSize(value.`transportType`) + + FfiConverterOptionalString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`path`) + + FfiConverterOptionalString.allocationSize(value.`label`) + + FfiConverterOptionalString.allocationSize(value.`model`) + + FfiConverterBoolean.allocationSize(value.`isBootloader`) ) - override fun write(value: RefTxOutput, buf: ByteBuffer) { - FfiConverterULong.write(value.`amount`, buf) - FfiConverterString.write(value.`scriptPubkey`, buf) + override fun write(value: TrezorDeviceInfo, buf: ByteBuffer) { + FfiConverterString.write(value.`id`, buf) + FfiConverterTypeTrezorTransportType.write(value.`transportType`, buf) + FfiConverterOptionalString.write(value.`name`, buf) + FfiConverterString.write(value.`path`, buf) + FfiConverterOptionalString.write(value.`label`, buf) + FfiConverterOptionalString.write(value.`model`, buf) + FfiConverterBoolean.write(value.`isBootloader`, buf) } } -public object FfiConverterTypeRefundMemo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): RefundMemo { - return RefundMemo( - FfiConverterString.read(buf), - FfiConverterString.read(buf), +public object FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorFeatures { + return TrezorFeatures( + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterOptionalBoolean.read(buf), + FfiConverterOptionalBoolean.read(buf), + FfiConverterOptionalBoolean.read(buf), + FfiConverterOptionalBoolean.read(buf), ) } - override fun allocationSize(value: RefundMemo): ULong = ( - FfiConverterString.allocationSize(value.`address`) + - FfiConverterString.allocationSize(value.`mac`) - ) - - override fun write(value: RefundMemo, buf: ByteBuffer) { - FfiConverterString.write(value.`address`, buf) - FfiConverterString.write(value.`mac`, buf) + override fun allocationSize(value: TrezorFeatures): ULong = ( + FfiConverterOptionalString.allocationSize(value.`vendor`) + + FfiConverterOptionalString.allocationSize(value.`model`) + + FfiConverterOptionalString.allocationSize(value.`label`) + + FfiConverterOptionalString.allocationSize(value.`deviceId`) + + FfiConverterOptionalUInt.allocationSize(value.`majorVersion`) + + FfiConverterOptionalUInt.allocationSize(value.`minorVersion`) + + FfiConverterOptionalUInt.allocationSize(value.`patchVersion`) + + FfiConverterOptionalBoolean.allocationSize(value.`pinProtection`) + + FfiConverterOptionalBoolean.allocationSize(value.`passphraseProtection`) + + FfiConverterOptionalBoolean.allocationSize(value.`initialized`) + + FfiConverterOptionalBoolean.allocationSize(value.`needsBackup`) + ) + + override fun write(value: TrezorFeatures, buf: ByteBuffer) { + FfiConverterOptionalString.write(value.`vendor`, buf) + FfiConverterOptionalString.write(value.`model`, buf) + FfiConverterOptionalString.write(value.`label`, buf) + FfiConverterOptionalString.write(value.`deviceId`, buf) + FfiConverterOptionalUInt.write(value.`majorVersion`, buf) + FfiConverterOptionalUInt.write(value.`minorVersion`, buf) + FfiConverterOptionalUInt.write(value.`patchVersion`, buf) + FfiConverterOptionalBoolean.write(value.`pinProtection`, buf) + FfiConverterOptionalBoolean.write(value.`passphraseProtection`, buf) + FfiConverterOptionalBoolean.write(value.`initialized`, buf) + FfiConverterOptionalBoolean.write(value.`needsBackup`, buf) } } -public object FfiConverterTypeSignedTransactionResponse: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): SignedTransactionResponse { - return SignedTransactionResponse( - FfiConverterSequenceString.read(buf), +public object FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorGetAddressParams { + return TrezorGetAddressParams( FfiConverterString.read(buf), - FfiConverterOptionalString.read(buf), + FfiConverterOptionalTypeTrezorCoinType.read(buf), + FfiConverterBoolean.read(buf), + FfiConverterOptionalTypeTrezorScriptType.read(buf), ) } - override fun allocationSize(value: SignedTransactionResponse): ULong = ( - FfiConverterSequenceString.allocationSize(value.`signatures`) + - FfiConverterString.allocationSize(value.`serializedTx`) + - FfiConverterOptionalString.allocationSize(value.`txid`) + override fun allocationSize(value: TrezorGetAddressParams): ULong = ( + FfiConverterString.allocationSize(value.`path`) + + FfiConverterOptionalTypeTrezorCoinType.allocationSize(value.`coin`) + + FfiConverterBoolean.allocationSize(value.`showOnTrezor`) + + FfiConverterOptionalTypeTrezorScriptType.allocationSize(value.`scriptType`) ) - override fun write(value: SignedTransactionResponse, buf: ByteBuffer) { - FfiConverterSequenceString.write(value.`signatures`, buf) - FfiConverterString.write(value.`serializedTx`, buf) - FfiConverterOptionalString.write(value.`txid`, buf) + override fun write(value: TrezorGetAddressParams, buf: ByteBuffer) { + FfiConverterString.write(value.`path`, buf) + FfiConverterOptionalTypeTrezorCoinType.write(value.`coin`, buf) + FfiConverterBoolean.write(value.`showOnTrezor`, buf) + FfiConverterOptionalTypeTrezorScriptType.write(value.`scriptType`, buf) } } -public object FfiConverterTypeSweepResult: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): SweepResult { - return SweepResult( +public object FfiConverterTypeTrezorGetPublicKeyParams: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorGetPublicKeyParams { + return TrezorGetPublicKeyParams( FfiConverterString.read(buf), - FfiConverterULong.read(buf), - FfiConverterULong.read(buf), - FfiConverterUInt.read(buf), + FfiConverterOptionalTypeTrezorCoinType.read(buf), + FfiConverterBoolean.read(buf), ) } - override fun allocationSize(value: SweepResult): ULong = ( - FfiConverterString.allocationSize(value.`txid`) + - FfiConverterULong.allocationSize(value.`amountSwept`) + - FfiConverterULong.allocationSize(value.`feePaid`) + - FfiConverterUInt.allocationSize(value.`utxosSwept`) + override fun allocationSize(value: TrezorGetPublicKeyParams): ULong = ( + FfiConverterString.allocationSize(value.`path`) + + FfiConverterOptionalTypeTrezorCoinType.allocationSize(value.`coin`) + + FfiConverterBoolean.allocationSize(value.`showOnTrezor`) ) - override fun write(value: SweepResult, buf: ByteBuffer) { - FfiConverterString.write(value.`txid`, buf) - FfiConverterULong.write(value.`amountSwept`, buf) - FfiConverterULong.write(value.`feePaid`, buf) - FfiConverterUInt.write(value.`utxosSwept`, buf) + override fun write(value: TrezorGetPublicKeyParams, buf: ByteBuffer) { + FfiConverterString.write(value.`path`, buf) + FfiConverterOptionalTypeTrezorCoinType.write(value.`coin`, buf) + FfiConverterBoolean.write(value.`showOnTrezor`, buf) } } -public object FfiConverterTypeSweepTransactionPreview: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): SweepTransactionPreview { - return SweepTransactionPreview( +public object FfiConverterTypeTrezorPrevTx: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorPrevTx { + return TrezorPrevTx( FfiConverterString.read(buf), - FfiConverterULong.read(buf), - FfiConverterULong.read(buf), - FfiConverterULong.read(buf), FfiConverterUInt.read(buf), - FfiConverterString.read(buf), - FfiConverterULong.read(buf), + FfiConverterUInt.read(buf), + FfiConverterSequenceTypeTrezorPrevTxInput.read(buf), + FfiConverterSequenceTypeTrezorPrevTxOutput.read(buf), ) } - override fun allocationSize(value: SweepTransactionPreview): ULong = ( - FfiConverterString.allocationSize(value.`psbt`) + - FfiConverterULong.allocationSize(value.`totalAmount`) + - FfiConverterULong.allocationSize(value.`estimatedFee`) + - FfiConverterULong.allocationSize(value.`estimatedVsize`) + - FfiConverterUInt.allocationSize(value.`utxosCount`) + - FfiConverterString.allocationSize(value.`destinationAddress`) + - FfiConverterULong.allocationSize(value.`amountAfterFees`) + override fun allocationSize(value: TrezorPrevTx): ULong = ( + FfiConverterString.allocationSize(value.`hash`) + + FfiConverterUInt.allocationSize(value.`version`) + + FfiConverterUInt.allocationSize(value.`lockTime`) + + FfiConverterSequenceTypeTrezorPrevTxInput.allocationSize(value.`inputs`) + + FfiConverterSequenceTypeTrezorPrevTxOutput.allocationSize(value.`outputs`) ) - override fun write(value: SweepTransactionPreview, buf: ByteBuffer) { - FfiConverterString.write(value.`psbt`, buf) - FfiConverterULong.write(value.`totalAmount`, buf) - FfiConverterULong.write(value.`estimatedFee`, buf) - FfiConverterULong.write(value.`estimatedVsize`, buf) - FfiConverterUInt.write(value.`utxosCount`, buf) - FfiConverterString.write(value.`destinationAddress`, buf) - FfiConverterULong.write(value.`amountAfterFees`, buf) + override fun write(value: TrezorPrevTx, buf: ByteBuffer) { + FfiConverterString.write(value.`hash`, buf) + FfiConverterUInt.write(value.`version`, buf) + FfiConverterUInt.write(value.`lockTime`, buf) + FfiConverterSequenceTypeTrezorPrevTxInput.write(value.`inputs`, buf) + FfiConverterSequenceTypeTrezorPrevTxOutput.write(value.`outputs`, buf) } } -public object FfiConverterTypeSweepableBalances: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): SweepableBalances { - return SweepableBalances( - FfiConverterULong.read(buf), - FfiConverterULong.read(buf), - FfiConverterULong.read(buf), - FfiConverterULong.read(buf), - FfiConverterUInt.read(buf), - FfiConverterUInt.read(buf), +public object FfiConverterTypeTrezorPrevTxInput: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorPrevTxInput { + return TrezorPrevTxInput( + FfiConverterString.read(buf), FfiConverterUInt.read(buf), + FfiConverterString.read(buf), FfiConverterUInt.read(buf), ) } - override fun allocationSize(value: SweepableBalances): ULong = ( - FfiConverterULong.allocationSize(value.`legacyBalance`) + - FfiConverterULong.allocationSize(value.`p2shBalance`) + - FfiConverterULong.allocationSize(value.`taprootBalance`) + - FfiConverterULong.allocationSize(value.`totalBalance`) + - FfiConverterUInt.allocationSize(value.`legacyUtxosCount`) + - FfiConverterUInt.allocationSize(value.`p2shUtxosCount`) + - FfiConverterUInt.allocationSize(value.`taprootUtxosCount`) + - FfiConverterUInt.allocationSize(value.`totalUtxosCount`) + override fun allocationSize(value: TrezorPrevTxInput): ULong = ( + FfiConverterString.allocationSize(value.`prevHash`) + + FfiConverterUInt.allocationSize(value.`prevIndex`) + + FfiConverterString.allocationSize(value.`scriptSig`) + + FfiConverterUInt.allocationSize(value.`sequence`) ) - override fun write(value: SweepableBalances, buf: ByteBuffer) { - FfiConverterULong.write(value.`legacyBalance`, buf) - FfiConverterULong.write(value.`p2shBalance`, buf) - FfiConverterULong.write(value.`taprootBalance`, buf) - FfiConverterULong.write(value.`totalBalance`, buf) - FfiConverterUInt.write(value.`legacyUtxosCount`, buf) - FfiConverterUInt.write(value.`p2shUtxosCount`, buf) - FfiConverterUInt.write(value.`taprootUtxosCount`, buf) - FfiConverterUInt.write(value.`totalUtxosCount`, buf) + override fun write(value: TrezorPrevTxInput, buf: ByteBuffer) { + FfiConverterString.write(value.`prevHash`, buf) + FfiConverterUInt.write(value.`prevIndex`, buf) + FfiConverterString.write(value.`scriptSig`, buf) + FfiConverterUInt.write(value.`sequence`, buf) } } -public object FfiConverterTypeTextMemo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TextMemo { - return TextMemo( +public object FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorPrevTxOutput { + return TrezorPrevTxOutput( + FfiConverterULong.read(buf), FfiConverterString.read(buf), ) } - override fun allocationSize(value: TextMemo): ULong = ( - FfiConverterString.allocationSize(value.`text`) + override fun allocationSize(value: TrezorPrevTxOutput): ULong = ( + FfiConverterULong.allocationSize(value.`amount`) + + FfiConverterString.allocationSize(value.`scriptPubkey`) ) - override fun write(value: TextMemo, buf: ByteBuffer) { - FfiConverterString.write(value.`text`, buf) + override fun write(value: TrezorPrevTxOutput, buf: ByteBuffer) { + FfiConverterULong.write(value.`amount`, buf) + FfiConverterString.write(value.`scriptPubkey`, buf) } } -public object FfiConverterTypeTransactionDetails: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TransactionDetails { - return TransactionDetails( +public object FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorPublicKeyResponse { + return TrezorPublicKeyResponse( FfiConverterString.read(buf), - FfiConverterLong.read(buf), - FfiConverterSequenceTypeTxInput.read(buf), - FfiConverterSequenceTypeTxOutput.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterUInt.read(buf), + FfiConverterOptionalUInt.read(buf), ) } - override fun allocationSize(value: TransactionDetails): ULong = ( - FfiConverterString.allocationSize(value.`txId`) + - FfiConverterLong.allocationSize(value.`amountSats`) + - FfiConverterSequenceTypeTxInput.allocationSize(value.`inputs`) + - FfiConverterSequenceTypeTxOutput.allocationSize(value.`outputs`) + override fun allocationSize(value: TrezorPublicKeyResponse): ULong = ( + FfiConverterString.allocationSize(value.`xpub`) + + FfiConverterString.allocationSize(value.`path`) + + FfiConverterString.allocationSize(value.`publicKey`) + + FfiConverterString.allocationSize(value.`chainCode`) + + FfiConverterUInt.allocationSize(value.`fingerprint`) + + FfiConverterUInt.allocationSize(value.`depth`) + + FfiConverterOptionalUInt.allocationSize(value.`rootFingerprint`) ) - override fun write(value: TransactionDetails, buf: ByteBuffer) { - FfiConverterString.write(value.`txId`, buf) - FfiConverterLong.write(value.`amountSats`, buf) - FfiConverterSequenceTypeTxInput.write(value.`inputs`, buf) - FfiConverterSequenceTypeTxOutput.write(value.`outputs`, buf) + override fun write(value: TrezorPublicKeyResponse, buf: ByteBuffer) { + FfiConverterString.write(value.`xpub`, buf) + FfiConverterString.write(value.`path`, buf) + FfiConverterString.write(value.`publicKey`, buf) + FfiConverterString.write(value.`chainCode`, buf) + FfiConverterUInt.write(value.`fingerprint`, buf) + FfiConverterUInt.write(value.`depth`, buf) + FfiConverterOptionalUInt.write(value.`rootFingerprint`, buf) } } -public object FfiConverterTypeTxAckPaymentRequest: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TxAckPaymentRequest { - return TxAckPaymentRequest( - FfiConverterOptionalString.read(buf), +public object FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorSignMessageParams { + return TrezorSignMessageParams( FfiConverterString.read(buf), - FfiConverterOptionalSequenceTypePaymentRequestMemo.read(buf), - FfiConverterOptionalULong.read(buf), FfiConverterString.read(buf), + FfiConverterOptionalTypeTrezorCoinType.read(buf), ) } - override fun allocationSize(value: TxAckPaymentRequest): ULong = ( - FfiConverterOptionalString.allocationSize(value.`nonce`) + - FfiConverterString.allocationSize(value.`recipientName`) + - FfiConverterOptionalSequenceTypePaymentRequestMemo.allocationSize(value.`memos`) + - FfiConverterOptionalULong.allocationSize(value.`amount`) + - FfiConverterString.allocationSize(value.`signature`) - ) + override fun allocationSize(value: TrezorSignMessageParams): ULong = ( + FfiConverterString.allocationSize(value.`path`) + + FfiConverterString.allocationSize(value.`message`) + + FfiConverterOptionalTypeTrezorCoinType.allocationSize(value.`coin`) + ) - override fun write(value: TxAckPaymentRequest, buf: ByteBuffer) { - FfiConverterOptionalString.write(value.`nonce`, buf) - FfiConverterString.write(value.`recipientName`, buf) - FfiConverterOptionalSequenceTypePaymentRequestMemo.write(value.`memos`, buf) - FfiConverterOptionalULong.write(value.`amount`, buf) - FfiConverterString.write(value.`signature`, buf) + override fun write(value: TrezorSignMessageParams, buf: ByteBuffer) { + FfiConverterString.write(value.`path`, buf) + FfiConverterString.write(value.`message`, buf) + FfiConverterOptionalTypeTrezorCoinType.write(value.`coin`, buf) } } -public object FfiConverterTypeTxInput: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TxInput { - return TxInput( +public object FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorSignTxParams { + return TrezorSignTxParams( + FfiConverterSequenceTypeTrezorTxInput.read(buf), + FfiConverterSequenceTypeTrezorTxOutput.read(buf), + FfiConverterOptionalTypeTrezorCoinType.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterSequenceTypeTrezorPrevTx.read(buf), + ) + } + + override fun allocationSize(value: TrezorSignTxParams): ULong = ( + FfiConverterSequenceTypeTrezorTxInput.allocationSize(value.`inputs`) + + FfiConverterSequenceTypeTrezorTxOutput.allocationSize(value.`outputs`) + + FfiConverterOptionalTypeTrezorCoinType.allocationSize(value.`coin`) + + FfiConverterOptionalUInt.allocationSize(value.`lockTime`) + + FfiConverterOptionalUInt.allocationSize(value.`version`) + + FfiConverterSequenceTypeTrezorPrevTx.allocationSize(value.`prevTxs`) + ) + + override fun write(value: TrezorSignTxParams, buf: ByteBuffer) { + FfiConverterSequenceTypeTrezorTxInput.write(value.`inputs`, buf) + FfiConverterSequenceTypeTrezorTxOutput.write(value.`outputs`, buf) + FfiConverterOptionalTypeTrezorCoinType.write(value.`coin`, buf) + FfiConverterOptionalUInt.write(value.`lockTime`, buf) + FfiConverterOptionalUInt.write(value.`version`, buf) + FfiConverterSequenceTypeTrezorPrevTx.write(value.`prevTxs`, buf) + } +} + + + + +public object FfiConverterTypeTrezorSignedMessageResponse: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorSignedMessageResponse { + return TrezorSignedMessageResponse( FfiConverterString.read(buf), - FfiConverterUInt.read(buf), FfiConverterString.read(buf), + ) + } + + override fun allocationSize(value: TrezorSignedMessageResponse): ULong = ( + FfiConverterString.allocationSize(value.`address`) + + FfiConverterString.allocationSize(value.`signature`) + ) + + override fun write(value: TrezorSignedMessageResponse, buf: ByteBuffer) { + FfiConverterString.write(value.`address`, buf) + FfiConverterString.write(value.`signature`, buf) + } +} + + + + +public object FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorSignedTx { + return TrezorSignedTx( FfiConverterSequenceString.read(buf), - FfiConverterUInt.read(buf), + FfiConverterString.read(buf), ) } - override fun allocationSize(value: TxInput): ULong = ( - FfiConverterString.allocationSize(value.`txid`) + - FfiConverterUInt.allocationSize(value.`vout`) + - FfiConverterString.allocationSize(value.`scriptsig`) + - FfiConverterSequenceString.allocationSize(value.`witness`) + - FfiConverterUInt.allocationSize(value.`sequence`) + override fun allocationSize(value: TrezorSignedTx): ULong = ( + FfiConverterSequenceString.allocationSize(value.`signatures`) + + FfiConverterString.allocationSize(value.`serializedTx`) ) - override fun write(value: TxInput, buf: ByteBuffer) { - FfiConverterString.write(value.`txid`, buf) - FfiConverterUInt.write(value.`vout`, buf) - FfiConverterString.write(value.`scriptsig`, buf) - FfiConverterSequenceString.write(value.`witness`, buf) - FfiConverterUInt.write(value.`sequence`, buf) + override fun write(value: TrezorSignedTx, buf: ByteBuffer) { + FfiConverterSequenceString.write(value.`signatures`, buf) + FfiConverterString.write(value.`serializedTx`, buf) } } -public object FfiConverterTypeTxInputType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TxInputType { - return TxInputType( +public object FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorTransportReadResult { + return TrezorTransportReadResult( + FfiConverterBoolean.read(buf), + FfiConverterByteArray.read(buf), FfiConverterString.read(buf), - FfiConverterUInt.read(buf), - FfiConverterULong.read(buf), - FfiConverterOptionalUInt.read(buf), - FfiConverterOptionalSequenceUInt.read(buf), - FfiConverterOptionalTypeScriptType.read(buf), - FfiConverterOptionalTypeMultisigRedeemScriptType.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: TxInputType): ULong = ( - FfiConverterString.allocationSize(value.`prevHash`) + - FfiConverterUInt.allocationSize(value.`prevIndex`) + - FfiConverterULong.allocationSize(value.`amount`) + - FfiConverterOptionalUInt.allocationSize(value.`sequence`) + - FfiConverterOptionalSequenceUInt.allocationSize(value.`addressN`) + - FfiConverterOptionalTypeScriptType.allocationSize(value.`scriptType`) + - FfiConverterOptionalTypeMultisigRedeemScriptType.allocationSize(value.`multisig`) + - FfiConverterOptionalString.allocationSize(value.`scriptPubkey`) + - FfiConverterOptionalString.allocationSize(value.`scriptSig`) + - FfiConverterOptionalString.allocationSize(value.`witness`) + - FfiConverterOptionalString.allocationSize(value.`ownershipProof`) + - FfiConverterOptionalString.allocationSize(value.`commitmentData`) + - FfiConverterOptionalString.allocationSize(value.`origHash`) + - FfiConverterOptionalUInt.allocationSize(value.`origIndex`) + - FfiConverterOptionalUInt.allocationSize(value.`coinjoinFlags`) + override fun allocationSize(value: TrezorTransportReadResult): ULong = ( + FfiConverterBoolean.allocationSize(value.`success`) + + FfiConverterByteArray.allocationSize(value.`data`) + + FfiConverterString.allocationSize(value.`error`) ) - override fun write(value: TxInputType, buf: ByteBuffer) { - FfiConverterString.write(value.`prevHash`, buf) - FfiConverterUInt.write(value.`prevIndex`, buf) - FfiConverterULong.write(value.`amount`, buf) - FfiConverterOptionalUInt.write(value.`sequence`, buf) - FfiConverterOptionalSequenceUInt.write(value.`addressN`, buf) - FfiConverterOptionalTypeScriptType.write(value.`scriptType`, buf) - FfiConverterOptionalTypeMultisigRedeemScriptType.write(value.`multisig`, buf) - FfiConverterOptionalString.write(value.`scriptPubkey`, buf) - FfiConverterOptionalString.write(value.`scriptSig`, buf) - FfiConverterOptionalString.write(value.`witness`, buf) - FfiConverterOptionalString.write(value.`ownershipProof`, buf) - FfiConverterOptionalString.write(value.`commitmentData`, buf) - FfiConverterOptionalString.write(value.`origHash`, buf) - FfiConverterOptionalUInt.write(value.`origIndex`, buf) - FfiConverterOptionalUInt.write(value.`coinjoinFlags`, buf) + override fun write(value: TrezorTransportReadResult, buf: ByteBuffer) { + FfiConverterBoolean.write(value.`success`, buf) + FfiConverterByteArray.write(value.`data`, buf) + FfiConverterString.write(value.`error`, buf) } } -public object FfiConverterTypeTxOutput: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TxOutput { - return TxOutput( +public object FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorTransportWriteResult { + return TrezorTransportWriteResult( + FfiConverterBoolean.read(buf), FfiConverterString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterLong.read(buf), - FfiConverterUInt.read(buf), ) } - override fun allocationSize(value: TxOutput): ULong = ( - FfiConverterString.allocationSize(value.`scriptpubkey`) + - FfiConverterOptionalString.allocationSize(value.`scriptpubkeyType`) + - FfiConverterOptionalString.allocationSize(value.`scriptpubkeyAddress`) + - FfiConverterLong.allocationSize(value.`value`) + - FfiConverterUInt.allocationSize(value.`n`) + override fun allocationSize(value: TrezorTransportWriteResult): ULong = ( + FfiConverterBoolean.allocationSize(value.`success`) + + FfiConverterString.allocationSize(value.`error`) ) - override fun write(value: TxOutput, buf: ByteBuffer) { - FfiConverterString.write(value.`scriptpubkey`, buf) - FfiConverterOptionalString.write(value.`scriptpubkeyType`, buf) - FfiConverterOptionalString.write(value.`scriptpubkeyAddress`, buf) - FfiConverterLong.write(value.`value`, buf) - FfiConverterUInt.write(value.`n`, buf) + override fun write(value: TrezorTransportWriteResult, buf: ByteBuffer) { + FfiConverterBoolean.write(value.`success`, buf) + FfiConverterString.write(value.`error`, buf) } } -public object FfiConverterTypeTxOutputType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TxOutputType { - return TxOutputType( - FfiConverterOptionalString.read(buf), - FfiConverterOptionalSequenceUInt.read(buf), +public object FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorTxInput { + return TrezorTxInput( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterString.read(buf), FfiConverterULong.read(buf), - FfiConverterTypeScriptType.read(buf), - FfiConverterOptionalTypeMultisigRedeemScriptType.read(buf), - FfiConverterOptionalString.read(buf), - FfiConverterOptionalString.read(buf), + FfiConverterTypeTrezorScriptType.read(buf), FfiConverterOptionalUInt.read(buf), + FfiConverterOptionalString.read(buf), FfiConverterOptionalUInt.read(buf), ) } - override fun allocationSize(value: TxOutputType): ULong = ( - FfiConverterOptionalString.allocationSize(value.`address`) + - FfiConverterOptionalSequenceUInt.allocationSize(value.`addressN`) + + override fun allocationSize(value: TrezorTxInput): ULong = ( + FfiConverterString.allocationSize(value.`prevHash`) + + FfiConverterUInt.allocationSize(value.`prevIndex`) + + FfiConverterString.allocationSize(value.`path`) + FfiConverterULong.allocationSize(value.`amount`) + - FfiConverterTypeScriptType.allocationSize(value.`scriptType`) + - FfiConverterOptionalTypeMultisigRedeemScriptType.allocationSize(value.`multisig`) + - FfiConverterOptionalString.allocationSize(value.`opReturnData`) + + FfiConverterTypeTrezorScriptType.allocationSize(value.`scriptType`) + + FfiConverterOptionalUInt.allocationSize(value.`sequence`) + FfiConverterOptionalString.allocationSize(value.`origHash`) + - FfiConverterOptionalUInt.allocationSize(value.`origIndex`) + - FfiConverterOptionalUInt.allocationSize(value.`paymentReqIndex`) + FfiConverterOptionalUInt.allocationSize(value.`origIndex`) ) - override fun write(value: TxOutputType, buf: ByteBuffer) { - FfiConverterOptionalString.write(value.`address`, buf) - FfiConverterOptionalSequenceUInt.write(value.`addressN`, buf) + override fun write(value: TrezorTxInput, buf: ByteBuffer) { + FfiConverterString.write(value.`prevHash`, buf) + FfiConverterUInt.write(value.`prevIndex`, buf) + FfiConverterString.write(value.`path`, buf) FfiConverterULong.write(value.`amount`, buf) - FfiConverterTypeScriptType.write(value.`scriptType`, buf) - FfiConverterOptionalTypeMultisigRedeemScriptType.write(value.`multisig`, buf) - FfiConverterOptionalString.write(value.`opReturnData`, buf) + FfiConverterTypeTrezorScriptType.write(value.`scriptType`, buf) + FfiConverterOptionalUInt.write(value.`sequence`, buf) FfiConverterOptionalString.write(value.`origHash`, buf) FfiConverterOptionalUInt.write(value.`origIndex`, buf) - FfiConverterOptionalUInt.write(value.`paymentReqIndex`, buf) } } -public object FfiConverterTypeUnlockPath: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): UnlockPath { - return UnlockPath( - FfiConverterSequenceUInt.read(buf), +public object FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorTxOutput { + return TrezorTxOutput( + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterULong.read(buf), + FfiConverterOptionalTypeTrezorScriptType.read(buf), + FfiConverterOptionalString.read(buf), FfiConverterOptionalString.read(buf), + FfiConverterOptionalUInt.read(buf), ) } - override fun allocationSize(value: UnlockPath): ULong = ( - FfiConverterSequenceUInt.allocationSize(value.`addressN`) + - FfiConverterOptionalString.allocationSize(value.`mac`) + override fun allocationSize(value: TrezorTxOutput): ULong = ( + FfiConverterOptionalString.allocationSize(value.`address`) + + FfiConverterOptionalString.allocationSize(value.`path`) + + FfiConverterULong.allocationSize(value.`amount`) + + FfiConverterOptionalTypeTrezorScriptType.allocationSize(value.`scriptType`) + + FfiConverterOptionalString.allocationSize(value.`opReturnData`) + + FfiConverterOptionalString.allocationSize(value.`origHash`) + + FfiConverterOptionalUInt.allocationSize(value.`origIndex`) ) - override fun write(value: UnlockPath, buf: ByteBuffer) { - FfiConverterSequenceUInt.write(value.`addressN`, buf) - FfiConverterOptionalString.write(value.`mac`, buf) + override fun write(value: TrezorTxOutput, buf: ByteBuffer) { + FfiConverterOptionalString.write(value.`address`, buf) + FfiConverterOptionalString.write(value.`path`, buf) + FfiConverterULong.write(value.`amount`, buf) + FfiConverterOptionalTypeTrezorScriptType.write(value.`scriptType`, buf) + FfiConverterOptionalString.write(value.`opReturnData`, buf) + FfiConverterOptionalString.write(value.`origHash`, buf) + FfiConverterOptionalUInt.write(value.`origIndex`, buf) } } -public object FfiConverterTypeValidationResult: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ValidationResult { - return ValidationResult( +public object FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorVerifyMessageParams { + return TrezorVerifyMessageParams( FfiConverterString.read(buf), - FfiConverterTypeNetworkType.read(buf), - FfiConverterTypeAddressType.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeTrezorCoinType.read(buf), ) } - override fun allocationSize(value: ValidationResult): ULong = ( + override fun allocationSize(value: TrezorVerifyMessageParams): ULong = ( FfiConverterString.allocationSize(value.`address`) + - FfiConverterTypeNetworkType.allocationSize(value.`network`) + - FfiConverterTypeAddressType.allocationSize(value.`addressType`) + FfiConverterString.allocationSize(value.`signature`) + + FfiConverterString.allocationSize(value.`message`) + + FfiConverterOptionalTypeTrezorCoinType.allocationSize(value.`coin`) ) - override fun write(value: ValidationResult, buf: ByteBuffer) { + override fun write(value: TrezorVerifyMessageParams, buf: ByteBuffer) { FfiConverterString.write(value.`address`, buf) - FfiConverterTypeNetworkType.write(value.`network`, buf) - FfiConverterTypeAddressType.write(value.`addressType`, buf) + FfiConverterString.write(value.`signature`, buf) + FfiConverterString.write(value.`message`, buf) + FfiConverterOptionalTypeTrezorCoinType.write(value.`coin`, buf) } } -public object FfiConverterTypeVerifyMessageResponse: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): VerifyMessageResponse { - return VerifyMessageResponse( +public object FfiConverterTypeTxInput: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TxInput { + return TxInput( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), FfiConverterString.read(buf), + FfiConverterSequenceString.read(buf), + FfiConverterUInt.read(buf), ) } - override fun allocationSize(value: VerifyMessageResponse): ULong = ( - FfiConverterString.allocationSize(value.`message`) + override fun allocationSize(value: TxInput): ULong = ( + FfiConverterString.allocationSize(value.`txid`) + + FfiConverterUInt.allocationSize(value.`vout`) + + FfiConverterString.allocationSize(value.`scriptsig`) + + FfiConverterSequenceString.allocationSize(value.`witness`) + + FfiConverterUInt.allocationSize(value.`sequence`) ) - override fun write(value: VerifyMessageResponse, buf: ByteBuffer) { - FfiConverterString.write(value.`message`, buf) + override fun write(value: TxInput, buf: ByteBuffer) { + FfiConverterString.write(value.`txid`, buf) + FfiConverterUInt.write(value.`vout`, buf) + FfiConverterString.write(value.`scriptsig`, buf) + FfiConverterSequenceString.write(value.`witness`, buf) + FfiConverterUInt.write(value.`sequence`, buf) } } -public object FfiConverterTypeXrpMarker: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): XrpMarker { - return XrpMarker( - FfiConverterULong.read(buf), - FfiConverterULong.read(buf), +public object FfiConverterTypeTxOutput: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TxOutput { + return TxOutput( + FfiConverterString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterLong.read(buf), + FfiConverterUInt.read(buf), ) } - override fun allocationSize(value: XrpMarker): ULong = ( - FfiConverterULong.allocationSize(value.`ledger`) + - FfiConverterULong.allocationSize(value.`seq`) + override fun allocationSize(value: TxOutput): ULong = ( + FfiConverterString.allocationSize(value.`scriptpubkey`) + + FfiConverterOptionalString.allocationSize(value.`scriptpubkeyType`) + + FfiConverterOptionalString.allocationSize(value.`scriptpubkeyAddress`) + + FfiConverterLong.allocationSize(value.`value`) + + FfiConverterUInt.allocationSize(value.`n`) ) - override fun write(value: XrpMarker, buf: ByteBuffer) { - FfiConverterULong.write(value.`ledger`, buf) - FfiConverterULong.write(value.`seq`, buf) + override fun write(value: TxOutput, buf: ByteBuffer) { + FfiConverterString.write(value.`scriptpubkey`, buf) + FfiConverterOptionalString.write(value.`scriptpubkeyType`, buf) + FfiConverterOptionalString.write(value.`scriptpubkeyAddress`, buf) + FfiConverterLong.write(value.`value`, buf) + FfiConverterUInt.write(value.`n`, buf) } } - -public object FfiConverterTypeAccountInfoDetails: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AccountInfoDetails = try { - AccountInfoDetails.entries[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) +public object FfiConverterTypeValidationResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ValidationResult { + return ValidationResult( + FfiConverterString.read(buf), + FfiConverterTypeNetworkType.read(buf), + FfiConverterTypeAddressType.read(buf), + ) } - override fun allocationSize(value: AccountInfoDetails): ULong = 4UL + override fun allocationSize(value: ValidationResult): ULong = ( + FfiConverterString.allocationSize(value.`address`) + + FfiConverterTypeNetworkType.allocationSize(value.`network`) + + FfiConverterTypeAddressType.allocationSize(value.`addressType`) + ) - override fun write(value: AccountInfoDetails, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) + override fun write(value: ValidationResult, buf: ByteBuffer) { + FfiConverterString.write(value.`address`, buf) + FfiConverterTypeNetworkType.write(value.`network`, buf) + FfiConverterTypeAddressType.write(value.`addressType`, buf) } } @@ -6181,24 +7170,6 @@ public object FfiConverterTypeAddressType: FfiConverterRustBuffer { -public object FfiConverterTypeAmountUnit: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AmountUnit = try { - AmountUnit.entries[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) - } - - override fun allocationSize(value: AmountUnit): ULong = 4UL - - override fun write(value: AmountUnit, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) - } -} - - - - - public object FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): BitcoinNetworkEnum = try { BitcoinNetworkEnum.entries[buf.getInt() - 1] @@ -6557,176 +7528,32 @@ public object FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { + override fun lift(errorBuf: RustBufferByValue): DbException = FfiConverterTypeDbError.lift(errorBuf) +} -public object FfiConverterTypeComposeOutput : FfiConverterRustBuffer{ - override fun read(buf: ByteBuffer): ComposeOutput { - return when(buf.getInt()) { - 1 -> ComposeOutput.Regular( - FfiConverterString.read(buf), - FfiConverterString.read(buf), - ) - 2 -> ComposeOutput.SendMax( - FfiConverterString.read(buf), +public object FfiConverterTypeDbError : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): DbException { + return when (buf.getInt()) { + 1 -> DbException.DbActivityException( + FfiConverterTypeActivityError.read(buf), ) - 3 -> ComposeOutput.OpReturn( - FfiConverterString.read(buf), + 2 -> DbException.DbBlocktankException( + FfiConverterTypeBlocktankError.read(buf), ) - 4 -> ComposeOutput.PaymentNoAddress( + 3 -> DbException.InitializationException( FfiConverterString.read(buf), ) - 5 -> ComposeOutput.SendMaxNoAddress - else -> throw RuntimeException("invalid enum value, something is very wrong!!") + else -> throw RuntimeException("invalid error enum value, something is very wrong!!") } } - override fun allocationSize(value: ComposeOutput): ULong = when(value) { - is ComposeOutput.Regular -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + override fun allocationSize(value: DbException): ULong { + return when (value) { + is DbException.DbActivityException -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterString.allocationSize(value.`amount`) - + FfiConverterString.allocationSize(value.`address`) - ) - } - is ComposeOutput.SendMax -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - + FfiConverterString.allocationSize(value.`address`) - ) - } - is ComposeOutput.OpReturn -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - + FfiConverterString.allocationSize(value.`dataHex`) - ) - } - is ComposeOutput.PaymentNoAddress -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - + FfiConverterString.allocationSize(value.`amount`) - ) - } - is ComposeOutput.SendMaxNoAddress -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - ) - } - } - - override fun write(value: ComposeOutput, buf: ByteBuffer) { - when(value) { - is ComposeOutput.Regular -> { - buf.putInt(1) - FfiConverterString.write(value.`amount`, buf) - FfiConverterString.write(value.`address`, buf) - Unit - } - is ComposeOutput.SendMax -> { - buf.putInt(2) - FfiConverterString.write(value.`address`, buf) - Unit - } - is ComposeOutput.OpReturn -> { - buf.putInt(3) - FfiConverterString.write(value.`dataHex`, buf) - Unit - } - is ComposeOutput.PaymentNoAddress -> { - buf.putInt(4) - FfiConverterString.write(value.`amount`, buf) - Unit - } - is ComposeOutput.SendMaxNoAddress -> { - buf.putInt(5) - Unit - } - }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } - } -} - - - - - -public object FfiConverterTypeComposeTransactionResponse : FfiConverterRustBuffer{ - override fun read(buf: ByteBuffer): ComposeTransactionResponse { - return when(buf.getInt()) { - 1 -> ComposeTransactionResponse.SignedTransaction( - FfiConverterTypeSignedTransactionResponse.read(buf), - ) - 2 -> ComposeTransactionResponse.PrecomposedTransactions( - FfiConverterSequenceTypePrecomposedTransaction.read(buf), - ) - else -> throw RuntimeException("invalid enum value, something is very wrong!!") - } - } - - override fun allocationSize(value: ComposeTransactionResponse): ULong = when(value) { - is ComposeTransactionResponse.SignedTransaction -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - + FfiConverterTypeSignedTransactionResponse.allocationSize(value.v1) - ) - } - is ComposeTransactionResponse.PrecomposedTransactions -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - + FfiConverterSequenceTypePrecomposedTransaction.allocationSize(value.v1) - ) - } - } - - override fun write(value: ComposeTransactionResponse, buf: ByteBuffer) { - when(value) { - is ComposeTransactionResponse.SignedTransaction -> { - buf.putInt(1) - FfiConverterTypeSignedTransactionResponse.write(value.v1, buf) - Unit - } - is ComposeTransactionResponse.PrecomposedTransactions -> { - buf.putInt(2) - FfiConverterSequenceTypePrecomposedTransaction.write(value.v1, buf) - Unit - } - }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } - } -} - - - - -public object DbExceptionErrorHandler : UniffiRustCallStatusErrorHandler { - override fun lift(errorBuf: RustBufferByValue): DbException = FfiConverterTypeDbError.lift(errorBuf) -} - -public object FfiConverterTypeDbError : FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): DbException { - return when (buf.getInt()) { - 1 -> DbException.DbActivityException( - FfiConverterTypeActivityError.read(buf), - ) - 2 -> DbException.DbBlocktankException( - FfiConverterTypeBlocktankError.read(buf), - ) - 3 -> DbException.InitializationException( - FfiConverterString.read(buf), - ) - else -> throw RuntimeException("invalid error enum value, something is very wrong!!") - } - } - - override fun allocationSize(value: DbException): ULong { - return when (value) { - is DbException.DbActivityException -> ( - // Add the size for the Int that specifies the variant plus the size needed for all fields - 4UL - + FfiConverterTypeActivityError.allocationSize(value.`errorDetails`) + + FfiConverterTypeActivityError.allocationSize(value.`errorDetails`) ) is DbException.DbBlocktankException -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields @@ -6912,74 +7739,6 @@ public object FfiConverterTypeDecodingError : FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): DefaultAccountType = try { - DefaultAccountType.entries[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) - } - - override fun allocationSize(value: DefaultAccountType): ULong = 4UL - - override fun write(value: DefaultAccountType, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) - } -} - - - - - -public object FfiConverterTypeHDNodeTypeOrString : FfiConverterRustBuffer{ - override fun read(buf: ByteBuffer): HdNodeTypeOrString { - return when(buf.getInt()) { - 1 -> HdNodeTypeOrString.String( - FfiConverterString.read(buf), - ) - 2 -> HdNodeTypeOrString.Node( - FfiConverterTypeHDNodeType.read(buf), - ) - else -> throw RuntimeException("invalid enum value, something is very wrong!!") - } - } - - override fun allocationSize(value: HdNodeTypeOrString): ULong = when(value) { - is HdNodeTypeOrString.String -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - + FfiConverterString.allocationSize(value.v1) - ) - } - is HdNodeTypeOrString.Node -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( - 4UL - + FfiConverterTypeHDNodeType.allocationSize(value.v1) - ) - } - } - - override fun write(value: HdNodeTypeOrString, buf: ByteBuffer) { - when(value) { - is HdNodeTypeOrString.String -> { - buf.putInt(1) - FfiConverterString.write(value.v1, buf) - Unit - } - is HdNodeTypeOrString.Node -> { - buf.putInt(2) - FfiConverterTypeHDNodeType.write(value.v1, buf) - Unit - } - }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } - } -} - - - - public object LnurlExceptionErrorHandler : UniffiRustCallStatusErrorHandler { override fun lift(errorBuf: RustBufferByValue): LnurlException = FfiConverterTypeLnurlError.lift(errorBuf) } @@ -7349,24 +8108,6 @@ public object FfiConverterTypeScanner : FfiConverterRustBuffer{ -public object FfiConverterTypeScriptType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ScriptType = try { - ScriptType.entries[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) - } - - override fun allocationSize(value: ScriptType): ULong = 4UL - - override fun write(value: ScriptType, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) - } -} - - - - - public object FfiConverterTypeSortDirection: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): SortDirection = try { SortDirection.entries[buf.getInt() - 1] @@ -7441,16 +8182,16 @@ public object FfiConverterTypeSweepError : FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TokenFilter = try { - TokenFilter.entries[buf.getInt() - 1] +public object FfiConverterTypeTrezorCoinType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorCoinType = try { + TrezorCoinType.entries[buf.getInt() - 1] } catch (e: IndexOutOfBoundsException) { throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun allocationSize(value: TokenFilter): ULong = 4UL + override fun allocationSize(value: TrezorCoinType): ULong = 4UL - override fun write(value: TokenFilter, buf: ByteBuffer) { + override fun write(value: TrezorCoinType, buf: ByteBuffer) { buf.putInt(value.ordinal + 1) } } @@ -7458,816 +8199,310 @@ public object FfiConverterTypeTokenFilter: FfiConverterRustBuffer { -public object TrezorConnectExceptionErrorHandler : UniffiRustCallStatusErrorHandler { - override fun lift(errorBuf: RustBufferByValue): TrezorConnectException = FfiConverterTypeTrezorConnectError.lift(errorBuf) +public object TrezorExceptionErrorHandler : UniffiRustCallStatusErrorHandler { + override fun lift(errorBuf: RustBufferByValue): TrezorException = FfiConverterTypeTrezorError.lift(errorBuf) } -public object FfiConverterTypeTrezorConnectError : FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TrezorConnectException { +public object FfiConverterTypeTrezorError : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorException { return when (buf.getInt()) { - 1 -> TrezorConnectException.SerdeException( + 1 -> TrezorException.TransportException( + FfiConverterString.read(buf), + ) + 2 -> TrezorException.DeviceNotFound() + 3 -> TrezorException.DeviceDisconnected() + 4 -> TrezorException.ConnectionException( + FfiConverterString.read(buf), + ) + 5 -> TrezorException.ProtocolException( + FfiConverterString.read(buf), + ) + 6 -> TrezorException.PairingRequired() + 7 -> TrezorException.PairingFailed( FfiConverterString.read(buf), ) - 2 -> TrezorConnectException.UrlException( + 8 -> TrezorException.PinRequired() + 9 -> TrezorException.PinCancelled() + 10 -> TrezorException.InvalidPin() + 11 -> TrezorException.PassphraseRequired() + 12 -> TrezorException.UserCancelled() + 13 -> TrezorException.Timeout() + 14 -> TrezorException.InvalidPath( FfiConverterString.read(buf), ) - 3 -> TrezorConnectException.EnvironmentException( + 15 -> TrezorException.DeviceException( FfiConverterString.read(buf), ) - 4 -> TrezorConnectException.Other( + 16 -> TrezorException.NotInitialized() + 17 -> TrezorException.NotConnected() + 18 -> TrezorException.SessionException( FfiConverterString.read(buf), ) - 5 -> TrezorConnectException.ClientException( + 19 -> TrezorException.IoException( FfiConverterString.read(buf), ) else -> throw RuntimeException("invalid error enum value, something is very wrong!!") } } - override fun allocationSize(value: TrezorConnectException): ULong { + override fun allocationSize(value: TrezorException): ULong { return when (value) { - is TrezorConnectException.SerdeException -> ( + is TrezorException.TransportException -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + FfiConverterString.allocationSize(value.`errorDetails`) ) - is TrezorConnectException.UrlException -> ( + is TrezorException.DeviceNotFound -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterString.allocationSize(value.`errorDetails`) ) - is TrezorConnectException.EnvironmentException -> ( + is TrezorException.DeviceDisconnected -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterString.allocationSize(value.`errorDetails`) ) - is TrezorConnectException.Other -> ( + is TrezorException.ConnectionException -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + FfiConverterString.allocationSize(value.`errorDetails`) ) - is TrezorConnectException.ClientException -> ( + is TrezorException.ProtocolException -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + FfiConverterString.allocationSize(value.`errorDetails`) ) - } - } - - override fun write(value: TrezorConnectException, buf: ByteBuffer) { - when (value) { - is TrezorConnectException.SerdeException -> { - buf.putInt(1) - FfiConverterString.write(value.`errorDetails`, buf) - Unit - } - is TrezorConnectException.UrlException -> { - buf.putInt(2) - FfiConverterString.write(value.`errorDetails`, buf) - Unit - } - is TrezorConnectException.EnvironmentException -> { - buf.putInt(3) - FfiConverterString.write(value.`errorDetails`, buf) - Unit - } - is TrezorConnectException.Other -> { - buf.putInt(4) - FfiConverterString.write(value.`errorDetails`, buf) - Unit - } - is TrezorConnectException.ClientException -> { - buf.putInt(5) - FfiConverterString.write(value.`errorDetails`, buf) - Unit - } - }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } - } -} - - - - - -public object FfiConverterTypeTrezorEnvironment: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TrezorEnvironment = try { - TrezorEnvironment.entries[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) - } - - override fun allocationSize(value: TrezorEnvironment): ULong = 4UL - - override fun write(value: TrezorEnvironment, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) - } -} - - - - - -public object FfiConverterTypeTrezorResponsePayload : FfiConverterRustBuffer{ - override fun read(buf: ByteBuffer): TrezorResponsePayload { - return when(buf.getInt()) { - 1 -> TrezorResponsePayload.Features( - FfiConverterTypeFeatureResponse.read(buf), - ) - 2 -> TrezorResponsePayload.Address( - FfiConverterTypeAddressResponse.read(buf), - ) - 3 -> TrezorResponsePayload.PublicKey( - FfiConverterTypePublicKeyResponse.read(buf), - ) - 4 -> TrezorResponsePayload.AccountInfo( - FfiConverterTypeAccountInfoResponse.read(buf), - ) - 5 -> TrezorResponsePayload.ComposeTransaction( - FfiConverterTypeComposeTransactionResponse.read(buf), - ) - 6 -> TrezorResponsePayload.VerifyMessage( - FfiConverterTypeVerifyMessageResponse.read(buf), - ) - 7 -> TrezorResponsePayload.MessageSignature( - FfiConverterTypeMessageSignatureResponse.read(buf), - ) - 8 -> TrezorResponsePayload.SignedTransaction( - FfiConverterTypeSignedTransactionResponse.read(buf), - ) - else -> throw RuntimeException("invalid enum value, something is very wrong!!") - } - } - - override fun allocationSize(value: TrezorResponsePayload): ULong = when(value) { - is TrezorResponsePayload.Features -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.PairingRequired -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypeFeatureResponse.allocationSize(value.v1) ) - } - is TrezorResponsePayload.Address -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.PairingFailed -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypeAddressResponse.allocationSize(value.v1) + + FfiConverterString.allocationSize(value.`errorDetails`) ) - } - is TrezorResponsePayload.PublicKey -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.PinRequired -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypePublicKeyResponse.allocationSize(value.v1) ) - } - is TrezorResponsePayload.AccountInfo -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.PinCancelled -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypeAccountInfoResponse.allocationSize(value.v1) ) - } - is TrezorResponsePayload.ComposeTransaction -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.InvalidPin -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypeComposeTransactionResponse.allocationSize(value.v1) ) - } - is TrezorResponsePayload.VerifyMessage -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.PassphraseRequired -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypeVerifyMessageResponse.allocationSize(value.v1) ) - } - is TrezorResponsePayload.MessageSignature -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.UserCancelled -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypeMessageSignatureResponse.allocationSize(value.v1) ) - } - is TrezorResponsePayload.SignedTransaction -> { - // Add the size for the Int that specifies the variant plus the size needed for all fields - ( + is TrezorException.Timeout -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterTypeSignedTransactionResponse.allocationSize(value.v1) + ) + is TrezorException.InvalidPath -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) + ) + is TrezorException.DeviceException -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) + ) + is TrezorException.NotInitialized -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is TrezorException.NotConnected -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is TrezorException.SessionException -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) + ) + is TrezorException.IoException -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) ) } } - override fun write(value: TrezorResponsePayload, buf: ByteBuffer) { - when(value) { - is TrezorResponsePayload.Features -> { - buf.putInt(1) - FfiConverterTypeFeatureResponse.write(value.v1, buf) - Unit - } - is TrezorResponsePayload.Address -> { - buf.putInt(2) - FfiConverterTypeAddressResponse.write(value.v1, buf) - Unit - } - is TrezorResponsePayload.PublicKey -> { - buf.putInt(3) - FfiConverterTypePublicKeyResponse.write(value.v1, buf) - Unit - } - is TrezorResponsePayload.AccountInfo -> { - buf.putInt(4) - FfiConverterTypeAccountInfoResponse.write(value.v1, buf) - Unit - } - is TrezorResponsePayload.ComposeTransaction -> { - buf.putInt(5) - FfiConverterTypeComposeTransactionResponse.write(value.v1, buf) - Unit - } - is TrezorResponsePayload.VerifyMessage -> { - buf.putInt(6) - FfiConverterTypeVerifyMessageResponse.write(value.v1, buf) - Unit - } - is TrezorResponsePayload.MessageSignature -> { - buf.putInt(7) - FfiConverterTypeMessageSignatureResponse.write(value.v1, buf) - Unit - } - is TrezorResponsePayload.SignedTransaction -> { - buf.putInt(8) - FfiConverterTypeSignedTransactionResponse.write(value.v1, buf) - Unit - } - }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } - } -} - - - - - -public object FfiConverterTypeWordCount: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): WordCount = try { - WordCount.entries[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) - } - - override fun allocationSize(value: WordCount): ULong = 4UL - - override fun write(value: WordCount, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) - } -} - - - - -public object FfiConverterOptionalUByte: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): kotlin.UByte? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterUByte.read(buf) - } - - override fun allocationSize(value: kotlin.UByte?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterUByte.allocationSize(value) - } - } - - override fun write(value: kotlin.UByte?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterUByte.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalUInt: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): kotlin.UInt? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterUInt.read(buf) - } - - override fun allocationSize(value: kotlin.UInt?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterUInt.allocationSize(value) - } - } - - override fun write(value: kotlin.UInt?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterUInt.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalULong: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): kotlin.ULong? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterULong.read(buf) - } - - override fun allocationSize(value: kotlin.ULong?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterULong.allocationSize(value) - } - } - - override fun write(value: kotlin.ULong?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterULong.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalBoolean: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): kotlin.Boolean? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterBoolean.read(buf) - } - - override fun allocationSize(value: kotlin.Boolean?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterBoolean.allocationSize(value) - } - } - - override fun write(value: kotlin.Boolean?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterBoolean.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalString: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): kotlin.String? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterString.read(buf) - } - - override fun allocationSize(value: kotlin.String?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterString.allocationSize(value) - } - } - - override fun write(value: kotlin.String?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterString.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalByteArray: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): kotlin.ByteArray? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterByteArray.read(buf) - } - - override fun allocationSize(value: kotlin.ByteArray?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterByteArray.allocationSize(value) - } - } - - override fun write(value: kotlin.ByteArray?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterByteArray.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeClosedChannelDetails: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ClosedChannelDetails? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeClosedChannelDetails.read(buf) - } - - override fun allocationSize(value: ClosedChannelDetails?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeClosedChannelDetails.allocationSize(value) - } - } - - override fun write(value: ClosedChannelDetails?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeClosedChannelDetails.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeCoinPurchaseMemo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CoinPurchaseMemo? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeCoinPurchaseMemo.read(buf) - } - - override fun allocationSize(value: CoinPurchaseMemo?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeCoinPurchaseMemo.allocationSize(value) - } - } - - override fun write(value: CoinPurchaseMemo?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeCoinPurchaseMemo.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeCommonParams: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CommonParams? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeCommonParams.read(buf) - } - - override fun allocationSize(value: CommonParams?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeCommonParams.allocationSize(value) - } - } - - override fun write(value: CommonParams?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeCommonParams.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeComposeAccount: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ComposeAccount? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeComposeAccount.read(buf) - } - - override fun allocationSize(value: ComposeAccount?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeComposeAccount.allocationSize(value) - } - } - - override fun write(value: ComposeAccount?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeComposeAccount.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeCreateCjitOptions: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CreateCjitOptions? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeCreateCjitOptions.read(buf) - } - - override fun allocationSize(value: CreateCjitOptions?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeCreateCjitOptions.allocationSize(value) - } - } - - override fun write(value: CreateCjitOptions?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeCreateCjitOptions.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeCreateOrderOptions: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CreateOrderOptions? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeCreateOrderOptions.read(buf) - } - - override fun allocationSize(value: CreateOrderOptions?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeCreateOrderOptions.allocationSize(value) - } - } - - override fun write(value: CreateOrderOptions?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeCreateOrderOptions.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeDeviceParams: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): DeviceParams? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeDeviceParams.read(buf) - } - - override fun allocationSize(value: DeviceParams?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeDeviceParams.allocationSize(value) - } - } - - override fun write(value: DeviceParams?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeDeviceParams.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeIBtBolt11Invoice: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IBtBolt11Invoice? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeIBtBolt11Invoice.read(buf) - } - - override fun allocationSize(value: IBtBolt11Invoice?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeIBtBolt11Invoice.allocationSize(value) - } - } - - override fun write(value: IBtBolt11Invoice?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeIBtBolt11Invoice.write(value, buf) - } - } -} - - - - -public object FfiConverterOptionalTypeIBtChannel: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IBtChannel? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeIBtChannel.read(buf) - } - - override fun allocationSize(value: IBtChannel?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeIBtChannel.allocationSize(value) - } - } - - override fun write(value: IBtChannel?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeIBtChannel.write(value, buf) - } + override fun write(value: TrezorException, buf: ByteBuffer) { + when (value) { + is TrezorException.TransportException -> { + buf.putInt(1) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is TrezorException.DeviceNotFound -> { + buf.putInt(2) + Unit + } + is TrezorException.DeviceDisconnected -> { + buf.putInt(3) + Unit + } + is TrezorException.ConnectionException -> { + buf.putInt(4) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is TrezorException.ProtocolException -> { + buf.putInt(5) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is TrezorException.PairingRequired -> { + buf.putInt(6) + Unit + } + is TrezorException.PairingFailed -> { + buf.putInt(7) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is TrezorException.PinRequired -> { + buf.putInt(8) + Unit + } + is TrezorException.PinCancelled -> { + buf.putInt(9) + Unit + } + is TrezorException.InvalidPin -> { + buf.putInt(10) + Unit + } + is TrezorException.PassphraseRequired -> { + buf.putInt(11) + Unit + } + is TrezorException.UserCancelled -> { + buf.putInt(12) + Unit + } + is TrezorException.Timeout -> { + buf.putInt(13) + Unit + } + is TrezorException.InvalidPath -> { + buf.putInt(14) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is TrezorException.DeviceException -> { + buf.putInt(15) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is TrezorException.NotInitialized -> { + buf.putInt(16) + Unit + } + is TrezorException.NotConnected -> { + buf.putInt(17) + Unit + } + is TrezorException.SessionException -> { + buf.putInt(18) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is TrezorException.IoException -> { + buf.putInt(19) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } } } -public object FfiConverterOptionalTypeIBtChannelClose: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IBtChannelClose? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeIBtChannelClose.read(buf) - } - override fun allocationSize(value: IBtChannelClose?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeIBtChannelClose.allocationSize(value) - } +public object FfiConverterTypeTrezorScriptType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorScriptType = try { + TrezorScriptType.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun write(value: IBtChannelClose?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeIBtChannelClose.write(value, buf) - } + override fun allocationSize(value: TrezorScriptType): ULong = 4UL + + override fun write(value: TrezorScriptType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) } } -public object FfiConverterOptionalTypeIBtInfo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IBtInfo? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeIBtInfo.read(buf) - } - override fun allocationSize(value: IBtInfo?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeIBtInfo.allocationSize(value) - } +public object FfiConverterTypeTrezorTransportType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorTransportType = try { + TrezorTransportType.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun write(value: IBtInfo?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeIBtInfo.write(value, buf) - } + override fun allocationSize(value: TrezorTransportType): ULong = 4UL + + override fun write(value: TrezorTransportType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) } } -public object FfiConverterOptionalTypeIBtOnchainTransactions: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IBtOnchainTransactions? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTypeIBtOnchainTransactions.read(buf) - } - override fun allocationSize(value: IBtOnchainTransactions?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTypeIBtOnchainTransactions.allocationSize(value) - } +public object FfiConverterTypeWordCount: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): WordCount = try { + WordCount.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun write(value: IBtOnchainTransactions?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTypeIBtOnchainTransactions.write(value, buf) - } + override fun allocationSize(value: WordCount): ULong = 4UL + + override fun write(value: WordCount, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) } } -public object FfiConverterOptionalTypeIBtPayment: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IBtPayment? { +public object FfiConverterOptionalUShort: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.UShort? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIBtPayment.read(buf) + return FfiConverterUShort.read(buf) } - override fun allocationSize(value: IBtPayment?): ULong { + override fun allocationSize(value: kotlin.UShort?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIBtPayment.allocationSize(value) + return 1UL + FfiConverterUShort.allocationSize(value) } } - override fun write(value: IBtPayment?, buf: ByteBuffer) { + override fun write(value: kotlin.UShort?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIBtPayment.write(value, buf) + FfiConverterUShort.write(value, buf) } } } @@ -8275,28 +8510,28 @@ public object FfiConverterOptionalTypeIBtPayment: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IDiscount? { +public object FfiConverterOptionalUInt: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.UInt? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIDiscount.read(buf) + return FfiConverterUInt.read(buf) } - override fun allocationSize(value: IDiscount?): ULong { + override fun allocationSize(value: kotlin.UInt?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIDiscount.allocationSize(value) + return 1UL + FfiConverterUInt.allocationSize(value) } } - override fun write(value: IDiscount?, buf: ByteBuffer) { + override fun write(value: kotlin.UInt?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIDiscount.write(value, buf) + FfiConverterUInt.write(value, buf) } } } @@ -8304,28 +8539,28 @@ public object FfiConverterOptionalTypeIDiscount: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IGiftBolt11Invoice? { +public object FfiConverterOptionalULong: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.ULong? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIGiftBolt11Invoice.read(buf) + return FfiConverterULong.read(buf) } - override fun allocationSize(value: IGiftBolt11Invoice?): ULong { + override fun allocationSize(value: kotlin.ULong?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIGiftBolt11Invoice.allocationSize(value) + return 1UL + FfiConverterULong.allocationSize(value) } } - override fun write(value: IGiftBolt11Invoice?, buf: ByteBuffer) { + override fun write(value: kotlin.ULong?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIGiftBolt11Invoice.write(value, buf) + FfiConverterULong.write(value, buf) } } } @@ -8333,28 +8568,28 @@ public object FfiConverterOptionalTypeIGiftBolt11Invoice: FfiConverterRustBuffer -public object FfiConverterOptionalTypeIGiftBtcAddress: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IGiftBtcAddress? { +public object FfiConverterOptionalBoolean: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.Boolean? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIGiftBtcAddress.read(buf) + return FfiConverterBoolean.read(buf) } - override fun allocationSize(value: IGiftBtcAddress?): ULong { + override fun allocationSize(value: kotlin.Boolean?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIGiftBtcAddress.allocationSize(value) + return 1UL + FfiConverterBoolean.allocationSize(value) } } - override fun write(value: IGiftBtcAddress?, buf: ByteBuffer) { + override fun write(value: kotlin.Boolean?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIGiftBtcAddress.write(value, buf) + FfiConverterBoolean.write(value, buf) } } } @@ -8362,28 +8597,28 @@ public object FfiConverterOptionalTypeIGiftBtcAddress: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IGiftCode? { +public object FfiConverterOptionalString: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.String? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIGiftCode.read(buf) + return FfiConverterString.read(buf) } - override fun allocationSize(value: IGiftCode?): ULong { + override fun allocationSize(value: kotlin.String?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIGiftCode.allocationSize(value) + return 1UL + FfiConverterString.allocationSize(value) } } - override fun write(value: IGiftCode?, buf: ByteBuffer) { + override fun write(value: kotlin.String?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIGiftCode.write(value, buf) + FfiConverterString.write(value, buf) } } } @@ -8391,28 +8626,28 @@ public object FfiConverterOptionalTypeIGiftCode: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IGiftLspNode? { +public object FfiConverterOptionalByteArray: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): kotlin.ByteArray? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIGiftLspNode.read(buf) + return FfiConverterByteArray.read(buf) } - override fun allocationSize(value: IGiftLspNode?): ULong { + override fun allocationSize(value: kotlin.ByteArray?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIGiftLspNode.allocationSize(value) + return 1UL + FfiConverterByteArray.allocationSize(value) } } - override fun write(value: IGiftLspNode?, buf: ByteBuffer) { + override fun write(value: kotlin.ByteArray?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIGiftLspNode.write(value, buf) + FfiConverterByteArray.write(value, buf) } } } @@ -8420,28 +8655,28 @@ public object FfiConverterOptionalTypeIGiftLspNode: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IGiftOrder? { +public object FfiConverterOptionalTypeClosedChannelDetails: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ClosedChannelDetails? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIGiftOrder.read(buf) + return FfiConverterTypeClosedChannelDetails.read(buf) } - override fun allocationSize(value: IGiftOrder?): ULong { + override fun allocationSize(value: ClosedChannelDetails?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIGiftOrder.allocationSize(value) + return 1UL + FfiConverterTypeClosedChannelDetails.allocationSize(value) } } - override fun write(value: IGiftOrder?, buf: ByteBuffer) { + override fun write(value: ClosedChannelDetails?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIGiftOrder.write(value, buf) + FfiConverterTypeClosedChannelDetails.write(value, buf) } } } @@ -8449,28 +8684,28 @@ public object FfiConverterOptionalTypeIGiftOrder: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): IGiftPayment? { +public object FfiConverterOptionalTypeCreateCjitOptions: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CreateCjitOptions? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeIGiftPayment.read(buf) + return FfiConverterTypeCreateCjitOptions.read(buf) } - override fun allocationSize(value: IGiftPayment?): ULong { + override fun allocationSize(value: CreateCjitOptions?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeIGiftPayment.allocationSize(value) + return 1UL + FfiConverterTypeCreateCjitOptions.allocationSize(value) } } - override fun write(value: IGiftPayment?, buf: ByteBuffer) { + override fun write(value: CreateCjitOptions?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeIGiftPayment.write(value, buf) + FfiConverterTypeCreateCjitOptions.write(value, buf) } } } @@ -8478,28 +8713,28 @@ public object FfiConverterOptionalTypeIGiftPayment: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ILspNode? { +public object FfiConverterOptionalTypeCreateOrderOptions: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CreateOrderOptions? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeILspNode.read(buf) + return FfiConverterTypeCreateOrderOptions.read(buf) } - override fun allocationSize(value: ILspNode?): ULong { + override fun allocationSize(value: CreateOrderOptions?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeILspNode.allocationSize(value) + return 1UL + FfiConverterTypeCreateOrderOptions.allocationSize(value) } } - override fun write(value: ILspNode?, buf: ByteBuffer) { + override fun write(value: CreateOrderOptions?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeILspNode.write(value, buf) + FfiConverterTypeCreateOrderOptions.write(value, buf) } } } @@ -8507,28 +8742,28 @@ public object FfiConverterOptionalTypeILspNode: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): MultisigRedeemScriptType? { +public object FfiConverterOptionalTypeIBtBolt11Invoice: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IBtBolt11Invoice? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeMultisigRedeemScriptType.read(buf) + return FfiConverterTypeIBtBolt11Invoice.read(buf) } - override fun allocationSize(value: MultisigRedeemScriptType?): ULong { + override fun allocationSize(value: IBtBolt11Invoice?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeMultisigRedeemScriptType.allocationSize(value) + return 1UL + FfiConverterTypeIBtBolt11Invoice.allocationSize(value) } } - override fun write(value: MultisigRedeemScriptType?, buf: ByteBuffer) { + override fun write(value: IBtBolt11Invoice?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeMultisigRedeemScriptType.write(value, buf) + FfiConverterTypeIBtBolt11Invoice.write(value, buf) } } } @@ -8536,28 +8771,28 @@ public object FfiConverterOptionalTypeMultisigRedeemScriptType: FfiConverterRust -public object FfiConverterOptionalTypeOnchainActivity: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): OnchainActivity? { +public object FfiConverterOptionalTypeIBtChannel: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IBtChannel? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeOnchainActivity.read(buf) + return FfiConverterTypeIBtChannel.read(buf) } - override fun allocationSize(value: OnchainActivity?): ULong { + override fun allocationSize(value: IBtChannel?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeOnchainActivity.allocationSize(value) + return 1UL + FfiConverterTypeIBtChannel.allocationSize(value) } } - override fun write(value: OnchainActivity?, buf: ByteBuffer) { + override fun write(value: IBtChannel?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeOnchainActivity.write(value, buf) + FfiConverterTypeIBtChannel.write(value, buf) } } } @@ -8565,28 +8800,28 @@ public object FfiConverterOptionalTypeOnchainActivity: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PreActivityMetadata? { +public object FfiConverterOptionalTypeIBtChannelClose: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IBtChannelClose? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypePreActivityMetadata.read(buf) + return FfiConverterTypeIBtChannelClose.read(buf) } - override fun allocationSize(value: PreActivityMetadata?): ULong { + override fun allocationSize(value: IBtChannelClose?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypePreActivityMetadata.allocationSize(value) + return 1UL + FfiConverterTypeIBtChannelClose.allocationSize(value) } } - override fun write(value: PreActivityMetadata?, buf: ByteBuffer) { + override fun write(value: IBtChannelClose?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypePreActivityMetadata.write(value, buf) + FfiConverterTypeIBtChannelClose.write(value, buf) } } } @@ -8594,28 +8829,28 @@ public object FfiConverterOptionalTypePreActivityMetadata: FfiConverterRustBuffe -public object FfiConverterOptionalTypeRefundMemo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): RefundMemo? { +public object FfiConverterOptionalTypeIBtInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IBtInfo? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeRefundMemo.read(buf) + return FfiConverterTypeIBtInfo.read(buf) } - override fun allocationSize(value: RefundMemo?): ULong { + override fun allocationSize(value: IBtInfo?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeRefundMemo.allocationSize(value) + return 1UL + FfiConverterTypeIBtInfo.allocationSize(value) } } - override fun write(value: RefundMemo?, buf: ByteBuffer) { + override fun write(value: IBtInfo?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeRefundMemo.write(value, buf) + FfiConverterTypeIBtInfo.write(value, buf) } } } @@ -8623,28 +8858,28 @@ public object FfiConverterOptionalTypeRefundMemo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TextMemo? { +public object FfiConverterOptionalTypeIBtOnchainTransactions: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IBtOnchainTransactions? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeTextMemo.read(buf) + return FfiConverterTypeIBtOnchainTransactions.read(buf) } - override fun allocationSize(value: TextMemo?): ULong { + override fun allocationSize(value: IBtOnchainTransactions?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeTextMemo.allocationSize(value) + return 1UL + FfiConverterTypeIBtOnchainTransactions.allocationSize(value) } } - override fun write(value: TextMemo?, buf: ByteBuffer) { + override fun write(value: IBtOnchainTransactions?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeTextMemo.write(value, buf) + FfiConverterTypeIBtOnchainTransactions.write(value, buf) } } } @@ -8652,28 +8887,28 @@ public object FfiConverterOptionalTypeTextMemo: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TransactionDetails? { +public object FfiConverterOptionalTypeIBtPayment: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IBtPayment? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeTransactionDetails.read(buf) + return FfiConverterTypeIBtPayment.read(buf) } - override fun allocationSize(value: TransactionDetails?): ULong { + override fun allocationSize(value: IBtPayment?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeTransactionDetails.allocationSize(value) + return 1UL + FfiConverterTypeIBtPayment.allocationSize(value) } } - override fun write(value: TransactionDetails?, buf: ByteBuffer) { + override fun write(value: IBtPayment?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeTransactionDetails.write(value, buf) + FfiConverterTypeIBtPayment.write(value, buf) } } } @@ -8681,28 +8916,28 @@ public object FfiConverterOptionalTypeTransactionDetails: FfiConverterRustBuffer -public object FfiConverterOptionalTypeUnlockPath: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): UnlockPath? { +public object FfiConverterOptionalTypeIDiscount: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IDiscount? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeUnlockPath.read(buf) + return FfiConverterTypeIDiscount.read(buf) } - override fun allocationSize(value: UnlockPath?): ULong { + override fun allocationSize(value: IDiscount?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeUnlockPath.allocationSize(value) + return 1UL + FfiConverterTypeIDiscount.allocationSize(value) } } - override fun write(value: UnlockPath?, buf: ByteBuffer) { + override fun write(value: IDiscount?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeUnlockPath.write(value, buf) + FfiConverterTypeIDiscount.write(value, buf) } } } @@ -8710,28 +8945,28 @@ public object FfiConverterOptionalTypeUnlockPath: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): XrpMarker? { +public object FfiConverterOptionalTypeIGiftBolt11Invoice: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IGiftBolt11Invoice? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeXrpMarker.read(buf) + return FfiConverterTypeIGiftBolt11Invoice.read(buf) } - override fun allocationSize(value: XrpMarker?): ULong { + override fun allocationSize(value: IGiftBolt11Invoice?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeXrpMarker.allocationSize(value) + return 1UL + FfiConverterTypeIGiftBolt11Invoice.allocationSize(value) } } - override fun write(value: XrpMarker?, buf: ByteBuffer) { + override fun write(value: IGiftBolt11Invoice?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeXrpMarker.write(value, buf) + FfiConverterTypeIGiftBolt11Invoice.write(value, buf) } } } @@ -8739,28 +8974,28 @@ public object FfiConverterOptionalTypeXrpMarker: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AccountInfoDetails? { +public object FfiConverterOptionalTypeIGiftBtcAddress: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IGiftBtcAddress? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeAccountInfoDetails.read(buf) + return FfiConverterTypeIGiftBtcAddress.read(buf) } - override fun allocationSize(value: AccountInfoDetails?): ULong { + override fun allocationSize(value: IGiftBtcAddress?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeAccountInfoDetails.allocationSize(value) + return 1UL + FfiConverterTypeIGiftBtcAddress.allocationSize(value) } } - override fun write(value: AccountInfoDetails?, buf: ByteBuffer) { + override fun write(value: IGiftBtcAddress?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeAccountInfoDetails.write(value, buf) + FfiConverterTypeIGiftBtcAddress.write(value, buf) } } } @@ -8768,28 +9003,28 @@ public object FfiConverterOptionalTypeAccountInfoDetails: FfiConverterRustBuffer -public object FfiConverterOptionalTypeActivity: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): Activity? { +public object FfiConverterOptionalTypeIGiftCode: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IGiftCode? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeActivity.read(buf) + return FfiConverterTypeIGiftCode.read(buf) } - override fun allocationSize(value: Activity?): ULong { + override fun allocationSize(value: IGiftCode?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeActivity.allocationSize(value) + return 1UL + FfiConverterTypeIGiftCode.allocationSize(value) } } - override fun write(value: Activity?, buf: ByteBuffer) { + override fun write(value: IGiftCode?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeActivity.write(value, buf) + FfiConverterTypeIGiftCode.write(value, buf) } } } @@ -8797,28 +9032,28 @@ public object FfiConverterOptionalTypeActivity: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ActivityFilter? { +public object FfiConverterOptionalTypeIGiftLspNode: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IGiftLspNode? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeActivityFilter.read(buf) + return FfiConverterTypeIGiftLspNode.read(buf) } - override fun allocationSize(value: ActivityFilter?): ULong { + override fun allocationSize(value: IGiftLspNode?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeActivityFilter.allocationSize(value) + return 1UL + FfiConverterTypeIGiftLspNode.allocationSize(value) } } - override fun write(value: ActivityFilter?, buf: ByteBuffer) { + override fun write(value: IGiftLspNode?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeActivityFilter.write(value, buf) + FfiConverterTypeIGiftLspNode.write(value, buf) } } } @@ -8826,28 +9061,28 @@ public object FfiConverterOptionalTypeActivityFilter: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AmountUnit? { +public object FfiConverterOptionalTypeIGiftOrder: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IGiftOrder? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeAmountUnit.read(buf) + return FfiConverterTypeIGiftOrder.read(buf) } - override fun allocationSize(value: AmountUnit?): ULong { + override fun allocationSize(value: IGiftOrder?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeAmountUnit.allocationSize(value) + return 1UL + FfiConverterTypeIGiftOrder.allocationSize(value) } } - override fun write(value: AmountUnit?, buf: ByteBuffer) { + override fun write(value: IGiftOrder?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeAmountUnit.write(value, buf) + FfiConverterTypeIGiftOrder.write(value, buf) } } } @@ -8855,28 +9090,28 @@ public object FfiConverterOptionalTypeAmountUnit: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): BtOrderState2? { +public object FfiConverterOptionalTypeIGiftPayment: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): IGiftPayment? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeBtOrderState2.read(buf) + return FfiConverterTypeIGiftPayment.read(buf) } - override fun allocationSize(value: BtOrderState2?): ULong { + override fun allocationSize(value: IGiftPayment?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeBtOrderState2.allocationSize(value) + return 1UL + FfiConverterTypeIGiftPayment.allocationSize(value) } } - override fun write(value: BtOrderState2?, buf: ByteBuffer) { + override fun write(value: IGiftPayment?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeBtOrderState2.write(value, buf) + FfiConverterTypeIGiftPayment.write(value, buf) } } } @@ -8884,28 +9119,28 @@ public object FfiConverterOptionalTypeBtOrderState2: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): BtPaymentState2? { +public object FfiConverterOptionalTypeILspNode: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ILspNode? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeBtPaymentState2.read(buf) + return FfiConverterTypeILspNode.read(buf) } - override fun allocationSize(value: BtPaymentState2?): ULong { + override fun allocationSize(value: ILspNode?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeBtPaymentState2.allocationSize(value) + return 1UL + FfiConverterTypeILspNode.allocationSize(value) } } - override fun write(value: BtPaymentState2?, buf: ByteBuffer) { + override fun write(value: ILspNode?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeBtPaymentState2.write(value, buf) + FfiConverterTypeILspNode.write(value, buf) } } } @@ -8913,28 +9148,28 @@ public object FfiConverterOptionalTypeBtPaymentState2: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): CJitStateEnum? { +public object FfiConverterOptionalTypeOnchainActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): OnchainActivity? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeCJitStateEnum.read(buf) + return FfiConverterTypeOnchainActivity.read(buf) } - override fun allocationSize(value: CJitStateEnum?): ULong { + override fun allocationSize(value: OnchainActivity?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeCJitStateEnum.allocationSize(value) + return 1UL + FfiConverterTypeOnchainActivity.allocationSize(value) } } - override fun write(value: CJitStateEnum?, buf: ByteBuffer) { + override fun write(value: OnchainActivity?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeCJitStateEnum.write(value, buf) + FfiConverterTypeOnchainActivity.write(value, buf) } } } @@ -8942,28 +9177,28 @@ public object FfiConverterOptionalTypeCJitStateEnum: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): DefaultAccountType? { +public object FfiConverterOptionalTypePreActivityMetadata: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PreActivityMetadata? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeDefaultAccountType.read(buf) + return FfiConverterTypePreActivityMetadata.read(buf) } - override fun allocationSize(value: DefaultAccountType?): ULong { + override fun allocationSize(value: PreActivityMetadata?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeDefaultAccountType.allocationSize(value) + return 1UL + FfiConverterTypePreActivityMetadata.allocationSize(value) } } - override fun write(value: DefaultAccountType?, buf: ByteBuffer) { + override fun write(value: PreActivityMetadata?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeDefaultAccountType.write(value, buf) + FfiConverterTypePreActivityMetadata.write(value, buf) } } } @@ -8971,28 +9206,28 @@ public object FfiConverterOptionalTypeDefaultAccountType: FfiConverterRustBuffer -public object FfiConverterOptionalTypeNetwork: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): Network? { +public object FfiConverterOptionalTypeTransactionDetails: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TransactionDetails? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeNetwork.read(buf) + return FfiConverterTypeTransactionDetails.read(buf) } - override fun allocationSize(value: Network?): ULong { + override fun allocationSize(value: TransactionDetails?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeNetwork.allocationSize(value) + return 1UL + FfiConverterTypeTransactionDetails.allocationSize(value) } } - override fun write(value: Network?, buf: ByteBuffer) { + override fun write(value: TransactionDetails?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeNetwork.write(value, buf) + FfiConverterTypeTransactionDetails.write(value, buf) } } } @@ -9000,28 +9235,28 @@ public object FfiConverterOptionalTypeNetwork: FfiConverterRustBuffer -public object FfiConverterOptionalTypePaymentType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): PaymentType? { +public object FfiConverterOptionalTypeTrezorCallMessageResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorCallMessageResult? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypePaymentType.read(buf) + return FfiConverterTypeTrezorCallMessageResult.read(buf) } - override fun allocationSize(value: PaymentType?): ULong { + override fun allocationSize(value: TrezorCallMessageResult?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypePaymentType.allocationSize(value) + return 1UL + FfiConverterTypeTrezorCallMessageResult.allocationSize(value) } } - override fun write(value: PaymentType?, buf: ByteBuffer) { + override fun write(value: TrezorCallMessageResult?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypePaymentType.write(value, buf) + FfiConverterTypeTrezorCallMessageResult.write(value, buf) } } } @@ -9029,28 +9264,28 @@ public object FfiConverterOptionalTypePaymentType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): ScriptType? { +public object FfiConverterOptionalTypeTrezorDeviceInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorDeviceInfo? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeScriptType.read(buf) + return FfiConverterTypeTrezorDeviceInfo.read(buf) } - override fun allocationSize(value: ScriptType?): ULong { + override fun allocationSize(value: TrezorDeviceInfo?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeScriptType.allocationSize(value) + return 1UL + FfiConverterTypeTrezorDeviceInfo.allocationSize(value) } } - override fun write(value: ScriptType?, buf: ByteBuffer) { + override fun write(value: TrezorDeviceInfo?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeScriptType.write(value, buf) + FfiConverterTypeTrezorDeviceInfo.write(value, buf) } } } @@ -9058,28 +9293,28 @@ public object FfiConverterOptionalTypeScriptType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): SortDirection? { +public object FfiConverterOptionalTypeTrezorFeatures: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorFeatures? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeSortDirection.read(buf) + return FfiConverterTypeTrezorFeatures.read(buf) } - override fun allocationSize(value: SortDirection?): ULong { + override fun allocationSize(value: TrezorFeatures?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeSortDirection.allocationSize(value) + return 1UL + FfiConverterTypeTrezorFeatures.allocationSize(value) } } - override fun write(value: SortDirection?, buf: ByteBuffer) { + override fun write(value: TrezorFeatures?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeSortDirection.write(value, buf) + FfiConverterTypeTrezorFeatures.write(value, buf) } } } @@ -9087,28 +9322,28 @@ public object FfiConverterOptionalTypeSortDirection: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TokenFilter? { +public object FfiConverterOptionalTypeActivity: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Activity? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeTokenFilter.read(buf) + return FfiConverterTypeActivity.read(buf) } - override fun allocationSize(value: TokenFilter?): ULong { + override fun allocationSize(value: Activity?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeTokenFilter.allocationSize(value) + return 1UL + FfiConverterTypeActivity.allocationSize(value) } } - override fun write(value: TokenFilter?, buf: ByteBuffer) { + override fun write(value: Activity?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeTokenFilter.write(value, buf) + FfiConverterTypeActivity.write(value, buf) } } } @@ -9116,28 +9351,28 @@ public object FfiConverterOptionalTypeTokenFilter: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): TrezorEnvironment? { +public object FfiConverterOptionalTypeActivityFilter: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): ActivityFilter? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeTrezorEnvironment.read(buf) + return FfiConverterTypeActivityFilter.read(buf) } - override fun allocationSize(value: TrezorEnvironment?): ULong { + override fun allocationSize(value: ActivityFilter?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeTrezorEnvironment.allocationSize(value) + return 1UL + FfiConverterTypeActivityFilter.allocationSize(value) } } - override fun write(value: TrezorEnvironment?, buf: ByteBuffer) { + override fun write(value: ActivityFilter?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeTrezorEnvironment.write(value, buf) + FfiConverterTypeActivityFilter.write(value, buf) } } } @@ -9145,28 +9380,28 @@ public object FfiConverterOptionalTypeTrezorEnvironment: FfiConverterRustBuffer< -public object FfiConverterOptionalTypeWordCount: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): WordCount? { +public object FfiConverterOptionalTypeBtOrderState2: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): BtOrderState2? { if (buf.get().toInt() == 0) { return null } - return FfiConverterTypeWordCount.read(buf) + return FfiConverterTypeBtOrderState2.read(buf) } - override fun allocationSize(value: WordCount?): ULong { + override fun allocationSize(value: BtOrderState2?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterTypeWordCount.allocationSize(value) + return 1UL + FfiConverterTypeBtOrderState2.allocationSize(value) } } - override fun write(value: WordCount?, buf: ByteBuffer) { + override fun write(value: BtOrderState2?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterTypeWordCount.write(value, buf) + FfiConverterTypeBtOrderState2.write(value, buf) } } } @@ -9174,28 +9409,28 @@ public object FfiConverterOptionalTypeWordCount: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypeBtPaymentState2: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): BtPaymentState2? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceUInt.read(buf) + return FfiConverterTypeBtPaymentState2.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: BtPaymentState2?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceUInt.allocationSize(value) + return 1UL + FfiConverterTypeBtPaymentState2.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: BtPaymentState2?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceUInt.write(value, buf) + FfiConverterTypeBtPaymentState2.write(value, buf) } } } @@ -9203,28 +9438,28 @@ public object FfiConverterOptionalSequenceUInt: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypeCJitStateEnum: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CJitStateEnum? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceString.read(buf) + return FfiConverterTypeCJitStateEnum.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: CJitStateEnum?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceString.allocationSize(value) + return 1UL + FfiConverterTypeCJitStateEnum.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: CJitStateEnum?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceString.write(value, buf) + FfiConverterTypeCJitStateEnum.write(value, buf) } } } @@ -9232,28 +9467,28 @@ public object FfiConverterOptionalSequenceString: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypeNetwork: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Network? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypeFeeLevel.read(buf) + return FfiConverterTypeNetwork.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: Network?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypeFeeLevel.allocationSize(value) + return 1UL + FfiConverterTypeNetwork.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: Network?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypeFeeLevel.write(value, buf) + FfiConverterTypeNetwork.write(value, buf) } } } @@ -9261,28 +9496,28 @@ public object FfiConverterOptionalSequenceTypeFeeLevel: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypePaymentType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): PaymentType? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypeHDNodeType.read(buf) + return FfiConverterTypePaymentType.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: PaymentType?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypeHDNodeType.allocationSize(value) + return 1UL + FfiConverterTypePaymentType.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: PaymentType?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypeHDNodeType.write(value, buf) + FfiConverterTypePaymentType.write(value, buf) } } } @@ -9290,28 +9525,28 @@ public object FfiConverterOptionalSequenceTypeHDNodeType: FfiConverterRustBuffer -public object FfiConverterOptionalSequenceTypeIManualRefund: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypeSortDirection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): SortDirection? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypeIManualRefund.read(buf) + return FfiConverterTypeSortDirection.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: SortDirection?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypeIManualRefund.allocationSize(value) + return 1UL + FfiConverterTypeSortDirection.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: SortDirection?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypeIManualRefund.write(value, buf) + FfiConverterTypeSortDirection.write(value, buf) } } } @@ -9319,28 +9554,28 @@ public object FfiConverterOptionalSequenceTypeIManualRefund: FfiConverterRustBuf -public object FfiConverterOptionalSequenceTypePaymentRequestMemo: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypeTrezorCoinType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorCoinType? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypePaymentRequestMemo.read(buf) + return FfiConverterTypeTrezorCoinType.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: TrezorCoinType?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypePaymentRequestMemo.allocationSize(value) + return 1UL + FfiConverterTypeTrezorCoinType.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: TrezorCoinType?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypePaymentRequestMemo.write(value, buf) + FfiConverterTypeTrezorCoinType.write(value, buf) } } } @@ -9348,28 +9583,28 @@ public object FfiConverterOptionalSequenceTypePaymentRequestMemo: FfiConverterRu -public object FfiConverterOptionalSequenceTypePrecomposedInput: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypeTrezorScriptType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): TrezorScriptType? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypePrecomposedInput.read(buf) + return FfiConverterTypeTrezorScriptType.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: TrezorScriptType?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypePrecomposedInput.allocationSize(value) + return 1UL + FfiConverterTypeTrezorScriptType.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: TrezorScriptType?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypePrecomposedInput.write(value, buf) + FfiConverterTypeTrezorScriptType.write(value, buf) } } } @@ -9377,28 +9612,28 @@ public object FfiConverterOptionalSequenceTypePrecomposedInput: FfiConverterRust -public object FfiConverterOptionalSequenceTypePrecomposedOutput: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalTypeWordCount: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): WordCount? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypePrecomposedOutput.read(buf) + return FfiConverterTypeWordCount.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: WordCount?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypePrecomposedOutput.allocationSize(value) + return 1UL + FfiConverterTypeWordCount.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: WordCount?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypePrecomposedOutput.write(value, buf) + FfiConverterTypeWordCount.write(value, buf) } } } @@ -9406,28 +9641,28 @@ public object FfiConverterOptionalSequenceTypePrecomposedOutput: FfiConverterRus -public object FfiConverterOptionalSequenceTypeRefTransaction: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalSequenceString: FfiConverterRustBuffer?> { + override fun read(buf: ByteBuffer): List? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypeRefTransaction.read(buf) + return FfiConverterSequenceString.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: List?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypeRefTransaction.allocationSize(value) + return 1UL + FfiConverterSequenceString.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: List?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypeRefTransaction.write(value, buf) + FfiConverterSequenceString.write(value, buf) } } } @@ -9435,28 +9670,28 @@ public object FfiConverterOptionalSequenceTypeRefTransaction: FfiConverterRustBu -public object FfiConverterOptionalSequenceTypeTxAckPaymentRequest: FfiConverterRustBuffer?> { - override fun read(buf: ByteBuffer): List? { +public object FfiConverterOptionalSequenceTypeIManualRefund: FfiConverterRustBuffer?> { + override fun read(buf: ByteBuffer): List? { if (buf.get().toInt() == 0) { return null } - return FfiConverterSequenceTypeTxAckPaymentRequest.read(buf) + return FfiConverterSequenceTypeIManualRefund.read(buf) } - override fun allocationSize(value: List?): ULong { + override fun allocationSize(value: List?): ULong { if (value == null) { return 1UL } else { - return 1UL + FfiConverterSequenceTypeTxAckPaymentRequest.allocationSize(value) + return 1UL + FfiConverterSequenceTypeIManualRefund.allocationSize(value) } } - override fun write(value: List?, buf: ByteBuffer) { + override fun write(value: List?, buf: ByteBuffer) { if (value == null) { buf.put(0) } else { buf.put(1) - FfiConverterSequenceTypeTxAckPaymentRequest.write(value, buf) + FfiConverterSequenceTypeIManualRefund.write(value, buf) } } } @@ -9493,31 +9728,6 @@ public object FfiConverterOptionalMapStringString: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterUInt.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterUInt.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterUInt.write(it, buf) - } - } -} - - - - public object FfiConverterSequenceString: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() @@ -9543,31 +9753,6 @@ public object FfiConverterSequenceString: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeAccountUtxo.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeAccountUtxo.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeAccountUtxo.write(it, buf) - } - } -} - - - - public object FfiConverterSequenceTypeActivityTags: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() @@ -9593,31 +9778,6 @@ public object FfiConverterSequenceTypeActivityTags: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeAddressInfo.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeAddressInfo.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeAddressInfo.write(it, buf) - } - } -} - - - - public object FfiConverterSequenceTypeClosedChannelDetails: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() @@ -9643,31 +9803,6 @@ public object FfiConverterSequenceTypeClosedChannelDetails: FfiConverterRustBuff -public object FfiConverterSequenceTypeFeeLevel: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeFeeLevel.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeFeeLevel.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeFeeLevel.write(it, buf) - } - } -} - - - - public object FfiConverterSequenceTypeGetAddressResponse: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() @@ -9693,56 +9828,6 @@ public object FfiConverterSequenceTypeGetAddressResponse: FfiConverterRustBuffer -public object FfiConverterSequenceTypeHDNodePathType: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeHDNodePathType.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeHDNodePathType.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeHDNodePathType.write(it, buf) - } - } -} - - - - -public object FfiConverterSequenceTypeHDNodeType: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeHDNodeType.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeHDNodeType.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeHDNodeType.write(it, buf) - } - } -} - - - - public object FfiConverterSequenceTypeIBtOnchainTransaction: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() @@ -9893,24 +9978,24 @@ public object FfiConverterSequenceTypeLightningActivity: FfiConverterRustBuffer< -public object FfiConverterSequenceTypeOnchainActivity: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeNativeDeviceInfo: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypeOnchainActivity.read(buf) + return List(len) { + FfiConverterTypeNativeDeviceInfo.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeOnchainActivity.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeNativeDeviceInfo.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 { - FfiConverterTypeOnchainActivity.write(it, buf) + FfiConverterTypeNativeDeviceInfo.write(it, buf) } } } @@ -9918,24 +10003,24 @@ public object FfiConverterSequenceTypeOnchainActivity: FfiConverterRustBuffer
  • > { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeOnchainActivity: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypePaymentRequestMemo.read(buf) + return List(len) { + FfiConverterTypeOnchainActivity.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypePaymentRequestMemo.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeOnchainActivity.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 { - FfiConverterTypePaymentRequestMemo.write(it, buf) + FfiConverterTypeOnchainActivity.write(it, buf) } } } @@ -9968,49 +10053,24 @@ public object FfiConverterSequenceTypePreActivityMetadata: FfiConverterRustBuffe -public object FfiConverterSequenceTypePrecomposedInput: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypePrecomposedInput.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypePrecomposedInput.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypePrecomposedInput.write(it, buf) - } - } -} - - - - -public object FfiConverterSequenceTypePrecomposedOutput: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeTransactionDetails: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypePrecomposedOutput.read(buf) + return List(len) { + FfiConverterTypeTransactionDetails.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypePrecomposedOutput.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTransactionDetails.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 { - FfiConverterTypePrecomposedOutput.write(it, buf) + FfiConverterTypeTransactionDetails.write(it, buf) } } } @@ -10018,24 +10078,24 @@ public object FfiConverterSequenceTypePrecomposedOutput: FfiConverterRustBuffer< -public object FfiConverterSequenceTypePrecomposedTransaction: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeTrezorDeviceInfo: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypePrecomposedTransaction.read(buf) + return List(len) { + FfiConverterTypeTrezorDeviceInfo.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypePrecomposedTransaction.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTrezorDeviceInfo.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 { - FfiConverterTypePrecomposedTransaction.write(it, buf) + FfiConverterTypeTrezorDeviceInfo.write(it, buf) } } } @@ -10043,24 +10103,24 @@ public object FfiConverterSequenceTypePrecomposedTransaction: FfiConverterRustBu -public object FfiConverterSequenceTypeRefTransaction: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeTrezorPrevTx: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypeRefTransaction.read(buf) + return List(len) { + FfiConverterTypeTrezorPrevTx.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeRefTransaction.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTrezorPrevTx.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 { - FfiConverterTypeRefTransaction.write(it, buf) + FfiConverterTypeTrezorPrevTx.write(it, buf) } } } @@ -10068,24 +10128,24 @@ public object FfiConverterSequenceTypeRefTransaction: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeTrezorPrevTxInput: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypeRefTxInput.read(buf) + return List(len) { + FfiConverterTypeTrezorPrevTxInput.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeRefTxInput.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTrezorPrevTxInput.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 { - FfiConverterTypeRefTxInput.write(it, buf) + FfiConverterTypeTrezorPrevTxInput.write(it, buf) } } } @@ -10093,24 +10153,24 @@ public object FfiConverterSequenceTypeRefTxInput: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeTrezorPrevTxOutput: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypeRefTxOutput.read(buf) + return List(len) { + FfiConverterTypeTrezorPrevTxOutput.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeRefTxOutput.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTrezorPrevTxOutput.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 { - FfiConverterTypeRefTxOutput.write(it, buf) + FfiConverterTypeTrezorPrevTxOutput.write(it, buf) } } } @@ -10118,24 +10178,24 @@ public object FfiConverterSequenceTypeRefTxOutput: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeTrezorTxInput: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypeTransactionDetails.read(buf) + return List(len) { + FfiConverterTypeTrezorTxInput.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeTransactionDetails.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTrezorTxInput.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 { - FfiConverterTypeTransactionDetails.write(it, buf) + FfiConverterTypeTrezorTxInput.write(it, buf) } } } @@ -10143,24 +10203,24 @@ public object FfiConverterSequenceTypeTransactionDetails: FfiConverterRustBuffer -public object FfiConverterSequenceTypeTxAckPaymentRequest: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { +public object FfiConverterSequenceTypeTrezorTxOutput: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypeTxAckPaymentRequest.read(buf) + return List(len) { + FfiConverterTypeTrezorTxOutput.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeTxAckPaymentRequest.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTrezorTxOutput.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 { - FfiConverterTypeTxAckPaymentRequest.write(it, buf) + FfiConverterTypeTrezorTxOutput.write(it, buf) } } } @@ -10193,31 +10253,6 @@ public object FfiConverterSequenceTypeTxInput: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeTxInputType.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeTxInputType.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeTxInputType.write(it, buf) - } - } -} - - - - public object FfiConverterSequenceTypeTxOutput: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() @@ -10228,39 +10263,14 @@ public object FfiConverterSequenceTypeTxOutput: FfiConverterRustBuffer): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeTxOutput.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeTxOutput.write(it, buf) - } - } -} - - - - -public object FfiConverterSequenceTypeTxOutputType: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeTxOutputType.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeTxOutputType.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeTxOutput.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 { - FfiConverterTypeTxOutputType.write(it, buf) + FfiConverterTypeTxOutput.write(it, buf) } } } @@ -10292,31 +10302,6 @@ public object FfiConverterSequenceTypeActivity: FfiConverterRustBuffer> { - override fun read(buf: ByteBuffer): List { - val len = buf.getInt() - return List(len) { - FfiConverterTypeComposeOutput.read(buf) - } - } - - override fun allocationSize(value: List): ULong { - val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeComposeOutput.allocationSize(it) } - return sizeForLength + sizeForItems - } - - override fun write(value: List, buf: ByteBuffer) { - buf.putInt(value.size) - value.iterator().forEach { - FfiConverterTypeComposeOutput.write(it, buf) - } - } -} - - - public object FfiConverterMapStringString: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): Map { val len = buf.getInt() @@ -11386,162 +11371,408 @@ public suspend fun `testNotification`(`deviceToken`: kotlin.String, `secretMessa ) } -@Throws(TrezorConnectException::class) -public fun `trezorComposeTransaction`(`outputs`: List, `coin`: kotlin.String, `callbackUrl`: kotlin.String, `requestId`: kotlin.String?, `trezorEnvironment`: TrezorEnvironment?, `push`: kotlin.Boolean?, `sequence`: kotlin.UInt?, `account`: ComposeAccount?, `feeLevels`: List?, `skipPermutation`: kotlin.Boolean?, `common`: CommonParams?): DeepLinkResult { - return FfiConverterTypeDeepLinkResult.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_trezor_compose_transaction( - FfiConverterSequenceTypeComposeOutput.lower(`outputs`), - FfiConverterString.lower(`coin`), - FfiConverterString.lower(`callbackUrl`), - FfiConverterOptionalString.lower(`requestId`), - FfiConverterOptionalTypeTrezorEnvironment.lower(`trezorEnvironment`), - FfiConverterOptionalBoolean.lower(`push`), - FfiConverterOptionalUInt.lower(`sequence`), - FfiConverterOptionalTypeComposeAccount.lower(`account`), - FfiConverterOptionalSequenceTypeFeeLevel.lower(`feeLevels`), - FfiConverterOptionalBoolean.lower(`skipPermutation`), - FfiConverterOptionalTypeCommonParams.lower(`common`), - uniffiRustCallStatus, - ) - }) +/** + * Clear stored Bluetooth pairing credentials for a specific Trezor device. + * + * This removes any stored credentials, requiring re-pairing on the next connection. + * Useful when a device has been reset or credentials have become stale. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorClearCredentials`(`deviceId`: kotlin.String) { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_clear_credentials( + FfiConverterString.lower(`deviceId`), + ), + { 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 + TrezorExceptionErrorHandler, + ) } -@Throws(TrezorConnectException::class) -public fun `trezorGetAccountInfo`(`coin`: kotlin.String, `callbackUrl`: kotlin.String, `requestId`: kotlin.String?, `trezorEnvironment`: TrezorEnvironment?, `path`: kotlin.String?, `descriptor`: kotlin.String?, `details`: AccountInfoDetails?, `tokens`: TokenFilter?, `page`: kotlin.UInt?, `pageSize`: kotlin.UInt?, `from`: kotlin.UInt?, `to`: kotlin.UInt?, `gap`: kotlin.UInt?, `contractFilter`: kotlin.String?, `marker`: XrpMarker?, `defaultAccountType`: DefaultAccountType?, `suppressBackupWarning`: kotlin.Boolean?, `common`: CommonParams?): DeepLinkResult { - return FfiConverterTypeDeepLinkResult.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_account_info( - FfiConverterString.lower(`coin`), - FfiConverterString.lower(`callbackUrl`), - FfiConverterOptionalString.lower(`requestId`), - FfiConverterOptionalTypeTrezorEnvironment.lower(`trezorEnvironment`), - FfiConverterOptionalString.lower(`path`), - FfiConverterOptionalString.lower(`descriptor`), - FfiConverterOptionalTypeAccountInfoDetails.lower(`details`), - FfiConverterOptionalTypeTokenFilter.lower(`tokens`), - FfiConverterOptionalUInt.lower(`page`), - FfiConverterOptionalUInt.lower(`pageSize`), - FfiConverterOptionalUInt.lower(`from`), - FfiConverterOptionalUInt.lower(`to`), - FfiConverterOptionalUInt.lower(`gap`), - FfiConverterOptionalString.lower(`contractFilter`), - FfiConverterOptionalTypeXrpMarker.lower(`marker`), - FfiConverterOptionalTypeDefaultAccountType.lower(`defaultAccountType`), - FfiConverterOptionalBoolean.lower(`suppressBackupWarning`), - FfiConverterOptionalTypeCommonParams.lower(`common`), - uniffiRustCallStatus, - ) - }) +/** + * Connect to a Trezor device by its ID. + * + * For Bluetooth devices, this will use stored credentials if available, + * or trigger pairing if needed. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorConnect`(`deviceId`: kotlin.String): TrezorFeatures { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_connect( + FfiConverterString.lower(`deviceId`), + ), + { 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 + { FfiConverterTypeTrezorFeatures.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) +} + +/** + * Disconnect from the currently connected Trezor device. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorDisconnect`() { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_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 + TrezorExceptionErrorHandler, + ) } -@Throws(TrezorConnectException::class) -public fun `trezorGetAddress`(`path`: kotlin.String, `callbackUrl`: kotlin.String, `requestId`: kotlin.String?, `trezorEnvironment`: TrezorEnvironment?, `address`: kotlin.String?, `showOnTrezor`: kotlin.Boolean?, `chunkify`: kotlin.Boolean?, `useEventListener`: kotlin.Boolean?, `coin`: kotlin.String?, `crossChain`: kotlin.Boolean?, `multisig`: MultisigRedeemScriptType?, `scriptType`: kotlin.String?, `unlockPath`: UnlockPath?, `common`: CommonParams?): DeepLinkResult { - return FfiConverterTypeDeepLinkResult.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> +/** + * Get a Bitcoin address from the connected Trezor device. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorGetAddress`(`params`: TrezorGetAddressParams): TrezorAddressResponse { + return uniffiRustCallAsync( UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_address( - FfiConverterString.lower(`path`), - FfiConverterString.lower(`callbackUrl`), - FfiConverterOptionalString.lower(`requestId`), - FfiConverterOptionalTypeTrezorEnvironment.lower(`trezorEnvironment`), - FfiConverterOptionalString.lower(`address`), - FfiConverterOptionalBoolean.lower(`showOnTrezor`), - FfiConverterOptionalBoolean.lower(`chunkify`), - FfiConverterOptionalBoolean.lower(`useEventListener`), - FfiConverterOptionalString.lower(`coin`), - FfiConverterOptionalBoolean.lower(`crossChain`), - FfiConverterOptionalTypeMultisigRedeemScriptType.lower(`multisig`), - FfiConverterOptionalString.lower(`scriptType`), - FfiConverterOptionalTypeUnlockPath.lower(`unlockPath`), - FfiConverterOptionalTypeCommonParams.lower(`common`), - uniffiRustCallStatus, - ) - }) + FfiConverterTypeTrezorGetAddressParams.lower(`params`), + ), + { 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 + { FfiConverterTypeTrezorAddressResponse.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) +} + +/** + * Get information about the currently connected Trezor device. + */ +public suspend fun `trezorGetConnectedDevice`(): TrezorDeviceInfo? { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_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 + { FfiConverterOptionalTypeTrezorDeviceInfo.lift(it) }, + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) +} + +/** + * Get the device's master root fingerprint as an 8-character hex string. + * + * Returns the root fingerprint in the standard descriptor format (e.g., "73c5da0a"). + * Requires a connected device. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorGetDeviceFingerprint`(): kotlin.String { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint( + ), + { 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 + TrezorExceptionErrorHandler, + ) } -@Throws(TrezorConnectException::class) -public fun `trezorGetFeatures`(`callbackUrl`: kotlin.String, `requestId`: kotlin.String?, `trezorEnvironment`: TrezorEnvironment?): DeepLinkResult { - return FfiConverterTypeDeepLinkResult.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> +/** + * Get the cached features of the currently connected Trezor device. + * + * Returns the features that were obtained during `trezor_connect()`, without + * triggering any device interaction. Returns None if no device is connected. + */ +public suspend fun `trezorGetFeatures`(): TrezorFeatures? { + return uniffiRustCallAsync( UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_features( - FfiConverterString.lower(`callbackUrl`), - FfiConverterOptionalString.lower(`requestId`), - FfiConverterOptionalTypeTrezorEnvironment.lower(`trezorEnvironment`), - uniffiRustCallStatus, - ) - }) + ), + { 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 + { FfiConverterOptionalTypeTrezorFeatures.lift(it) }, + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) +} + +/** + * Get a public key (xpub) from the connected Trezor device. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorGetPublicKey`(`params`: TrezorGetPublicKeyParams): TrezorPublicKeyResponse { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_public_key( + FfiConverterTypeTrezorGetPublicKeyParams.lower(`params`), + ), + { 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 + { FfiConverterTypeTrezorPublicKeyResponse.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) +} + +/** + * Initialize the Trezor manager with optional credential storage. + * + * The credential_path is used to persist Bluetooth pairing credentials, + * allowing reconnection without re-pairing. + * + * NOTE: On Android, you must call the native initBle() function first! + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorInitialize`(`credentialPath`: kotlin.String?) { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_initialize( + FfiConverterOptionalString.lower(`credentialPath`), + ), + { 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 + TrezorExceptionErrorHandler, + ) } -@Throws(TrezorConnectException::class) -public fun `trezorHandleDeepLink`(`callbackUrl`: kotlin.String): TrezorResponsePayload { - return FfiConverterTypeTrezorResponsePayload.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_trezor_handle_deep_link( - FfiConverterString.lower(`callbackUrl`), +/** + * Check if BLE has been initialized. + * + * On Android: Returns true if BluetoothInit.nativeInit() was called successfully. + * On other platforms: Always returns true (BLE works natively). + */ +public fun `trezorIsBleAvailable`(): kotlin.Boolean { + return FfiConverterBoolean.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_ble_available( uniffiRustCallStatus, ) }) } -@Throws(TrezorConnectException::class) -public fun `trezorSignMessage`(`path`: kotlin.String, `message`: kotlin.String, `callbackUrl`: kotlin.String, `requestId`: kotlin.String?, `trezorEnvironment`: TrezorEnvironment?, `coin`: kotlin.String?, `hex`: kotlin.Boolean?, `noScriptType`: kotlin.Boolean?, `common`: CommonParams?): DeepLinkResult { - return FfiConverterTypeDeepLinkResult.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message( - FfiConverterString.lower(`path`), - FfiConverterString.lower(`message`), - FfiConverterString.lower(`callbackUrl`), - FfiConverterOptionalString.lower(`requestId`), - FfiConverterOptionalTypeTrezorEnvironment.lower(`trezorEnvironment`), - FfiConverterOptionalString.lower(`coin`), - FfiConverterOptionalBoolean.lower(`hex`), - FfiConverterOptionalBoolean.lower(`noScriptType`), - FfiConverterOptionalTypeCommonParams.lower(`common`), +/** + * Check if a Trezor device is currently connected. + */ +public suspend fun `trezorIsConnected`(): kotlin.Boolean { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_connected( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_i8(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_i8(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_i8(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_i8(future) }, + // lift function + { FfiConverterBoolean.lift(it) }, + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) +} + +/** + * Check if the Trezor manager is initialized. + */ +public suspend fun `trezorIsInitialized`(): kotlin.Boolean { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_initialized( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_i8(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_i8(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_i8(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_i8(future) }, + // lift function + { FfiConverterBoolean.lift(it) }, + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) +} + +/** + * List previously discovered devices without triggering a new scan. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorListDevices`(): List { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_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 + { FfiConverterSequenceTypeTrezorDeviceInfo.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) +} + +/** + * Scan for available Trezor devices (USB + Bluetooth). + * + * This performs an active Bluetooth scan and enumerates USB devices. + * Returns a list of discovered devices. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorScan`(): List { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_scan( + ), + { 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 + { FfiConverterSequenceTypeTrezorDeviceInfo.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) +} + +/** + * Initialize the Trezor transport with a native callback implementation + * + * This must be called before any Trezor scanning/connection operations. + * The native layer (iOS/Android) must implement the TrezorTransportCallback interface. + */ +public fun `trezorSetTransportCallback`(`callback`: TrezorTransportCallback) { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_transport_callback( + FfiConverterTypeTrezorTransportCallback.lower(`callback`), uniffiRustCallStatus, ) - }) + } } -@Throws(TrezorConnectException::class) -public fun `trezorSignTransaction`(`coin`: kotlin.String, `inputs`: List, `outputs`: List, `callbackUrl`: kotlin.String, `requestId`: kotlin.String?, `trezorEnvironment`: TrezorEnvironment?, `refTxs`: List?, `paymentRequests`: List?, `locktime`: kotlin.UInt?, `version`: kotlin.UInt?, `expiry`: kotlin.UInt?, `versionGroupId`: kotlin.UInt?, `overwintered`: kotlin.Boolean?, `timestamp`: kotlin.UInt?, `branchId`: kotlin.UInt?, `push`: kotlin.Boolean?, `amountUnit`: AmountUnit?, `unlockPath`: UnlockPath?, `serialize`: kotlin.Boolean?, `chunkify`: kotlin.Boolean?, `common`: CommonParams?): DeepLinkResult { - return FfiConverterTypeDeepLinkResult.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_transaction( - FfiConverterString.lower(`coin`), - FfiConverterSequenceTypeTxInputType.lower(`inputs`), - FfiConverterSequenceTypeTxOutputType.lower(`outputs`), - FfiConverterString.lower(`callbackUrl`), - FfiConverterOptionalString.lower(`requestId`), - FfiConverterOptionalTypeTrezorEnvironment.lower(`trezorEnvironment`), - FfiConverterOptionalSequenceTypeRefTransaction.lower(`refTxs`), - FfiConverterOptionalSequenceTypeTxAckPaymentRequest.lower(`paymentRequests`), - FfiConverterOptionalUInt.lower(`locktime`), - FfiConverterOptionalUInt.lower(`version`), - FfiConverterOptionalUInt.lower(`expiry`), - FfiConverterOptionalUInt.lower(`versionGroupId`), - FfiConverterOptionalBoolean.lower(`overwintered`), - FfiConverterOptionalUInt.lower(`timestamp`), - FfiConverterOptionalUInt.lower(`branchId`), - FfiConverterOptionalBoolean.lower(`push`), - FfiConverterOptionalTypeAmountUnit.lower(`amountUnit`), - FfiConverterOptionalTypeUnlockPath.lower(`unlockPath`), - FfiConverterOptionalBoolean.lower(`serialize`), - FfiConverterOptionalBoolean.lower(`chunkify`), - FfiConverterOptionalTypeCommonParams.lower(`common`), +/** + * Set the UI callback for handling PIN and passphrase requests. + * + * This should be called before connecting to a Trezor device if you want + * the library to handle PIN/passphrase requests via your UI instead of + * returning errors. + */ +public fun `trezorSetUiCallback`(`callback`: TrezorUiCallback) { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_ui_callback( + FfiConverterTypeTrezorUiCallback.lower(`callback`), uniffiRustCallStatus, ) - }) + } +} + +/** + * Sign a message with the connected Trezor device. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorSignMessage`(`params`: TrezorSignMessageParams): TrezorSignedMessageResponse { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message( + FfiConverterTypeTrezorSignMessageParams.lower(`params`), + ), + { 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 + { FfiConverterTypeTrezorSignedMessageResponse.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) +} + +/** + * Sign a Bitcoin transaction with the connected Trezor device. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorSignTx`(`params`: TrezorSignTxParams): TrezorSignedTx { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx( + FfiConverterTypeTrezorSignTxParams.lower(`params`), + ), + { 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 + { FfiConverterTypeTrezorSignedTx.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) +} + +/** + * Sign a Bitcoin transaction from a PSBT (base64-encoded). + * + * Parses the PSBT, extracts inputs/outputs/prev_txs, signs via the connected + * Trezor device, and returns the signed transaction. + * + * # Arguments + * * `psbt_base64` - Base64-encoded PSBT data + * * `network` - Bitcoin network type. Defaults to Bitcoin (mainnet) if None. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorSignTxFromPsbt`(`psbtBase64`: kotlin.String, `network`: TrezorCoinType?): TrezorSignedTx { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt( + FfiConverterString.lower(`psbtBase64`), + FfiConverterOptionalTypeTrezorCoinType.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 + { FfiConverterTypeTrezorSignedTx.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) } -@Throws(TrezorConnectException::class) -public fun `trezorVerifyMessage`(`address`: kotlin.String, `signature`: kotlin.String, `message`: kotlin.String, `coin`: kotlin.String, `callbackUrl`: kotlin.String, `requestId`: kotlin.String?, `trezorEnvironment`: TrezorEnvironment?, `hex`: kotlin.Boolean?, `common`: CommonParams?): DeepLinkResult { - return FfiConverterTypeDeepLinkResult.lift(uniffiRustCallWithError(TrezorConnectExceptionErrorHandler) { uniffiRustCallStatus -> +/** + * Verify a message signature with the connected Trezor device. + */ +@Throws(TrezorException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `trezorVerifyMessage`(`params`: TrezorVerifyMessageParams): kotlin.Boolean { + return uniffiRustCallAsync( UniffiLib.uniffi_bitkitcore_fn_func_trezor_verify_message( - FfiConverterString.lower(`address`), - FfiConverterString.lower(`signature`), - FfiConverterString.lower(`message`), - FfiConverterString.lower(`coin`), - FfiConverterString.lower(`callbackUrl`), - FfiConverterOptionalString.lower(`requestId`), - FfiConverterOptionalTypeTrezorEnvironment.lower(`trezorEnvironment`), - FfiConverterOptionalBoolean.lower(`hex`), - FfiConverterOptionalTypeCommonParams.lower(`common`), - uniffiRustCallStatus, - ) - }) + FfiConverterTypeTrezorVerifyMessageParams.lower(`params`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_i8(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_i8(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_i8(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_i8(future) }, + // lift function + { FfiConverterBoolean.lift(it) }, + // Error FFI converter + TrezorExceptionErrorHandler, + ) } @Throws(ActivityException::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 9b1c735..69f336e 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 @@ -112,125 +112,178 @@ public object NoPointer /** - * Account addresses + * Callback interface for native Trezor transport operations + * + * 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. */ -@kotlinx.serialization.Serializable -public data class AccountAddresses ( +public interface TrezorTransportCallback { + /** - * Used addresses + * Enumerate all connected Trezor devices */ - val `used`: List, + public fun `enumerateDevices`(): List + /** - * Unused addresses + * Open a connection to a device */ - val `unused`: List, + public fun `openDevice`(`path`: kotlin.String): TrezorTransportWriteResult + /** - * Change addresses + * Close the connection to a device */ - val `change`: List -) { - public companion object -} - - - -/** - * Account info response - */ -@kotlinx.serialization.Serializable -public data class AccountInfoResponse ( - val `id`: kotlin.UInt, - val `path`: kotlin.String, - val `descriptor`: kotlin.String, - val `legacyXpub`: kotlin.String?, - val `balance`: kotlin.String, - val `availableBalance`: kotlin.String -) { - public companion object -} - - - -/** - * UTXO information for account - */ -@kotlinx.serialization.Serializable -public data class AccountUtxo ( + public fun `closeDevice`(`path`: kotlin.String): TrezorTransportWriteResult + /** - * Transaction ID + * Read a chunk of data from the device */ - val `txid`: kotlin.String, + public fun `readChunk`(`path`: kotlin.String): TrezorTransportReadResult + /** - * Output index + * Write a chunk of data to the device */ - val `vout`: kotlin.UInt, + public fun `writeChunk`(`path`: kotlin.String, `data`: kotlin.ByteArray): TrezorTransportWriteResult + /** - * Amount in satoshis + * Get the chunk size for a device (64 for USB, 244 for Bluetooth) + */ + public fun `getChunkSize`(`path`: kotlin.String): kotlin.UInt + + /** + * 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 */ - val `amount`: kotlin.String, + public fun `callMessage`(`path`: kotlin.String, `messageType`: kotlin.UShort, `data`: kotlin.ByteArray): TrezorCallMessageResult? + /** - * Block height + * 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. */ - val `blockHeight`: kotlin.UInt?, + public fun `getPairingCode`(): kotlin.String + /** - * Address + * 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. */ - val `address`: kotlin.String, + public fun `saveThpCredential`(`deviceId`: kotlin.String, `credentialJson`: kotlin.String): kotlin.Boolean + /** - * Derivation path + * 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. */ - val `path`: kotlin.String, + public fun `loadThpCredential`(`deviceId`: kotlin.String): kotlin.String? + /** - * Number of confirmations + * 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 */ - val `confirmations`: kotlin.UInt? -) { + public fun `logDebug`(`tag`: kotlin.String, `message`: kotlin.String) + public companion object } -@kotlinx.serialization.Serializable -public data class ActivityTags ( - val `activityId`: kotlin.String, - val `tags`: List -) { - public companion object -} - - /** - * Address information + * 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. + * + * Methods return `String`: + * - Empty string (`""`) = cancel the request + * - Non-empty string = the user's input (PIN or passphrase) + * + * This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. */ -@kotlinx.serialization.Serializable -public data class AddressInfo ( - /** - * Address string - */ - val `address`: kotlin.String, +public interface TrezorUiCallback { + /** - * Derivation path + * Called when the device requests a PIN. + * + * Show a PIN matrix UI and return the matrix-encoded PIN string. + * Return empty string to cancel. */ - val `path`: kotlin.String, + public fun `onPinRequest`(): kotlin.String + /** - * Number of transfers + * Called when the device requests a passphrase. + * + * If `on_device` is true, the user should enter on the Trezor itself — + * return any non-empty string (e.g., "ok") to acknowledge. + * + * If `on_device` is false, show a passphrase input UI and return the value. + * Return empty string to cancel. */ - val `transfers`: kotlin.UInt -) { + public fun `onPassphraseRequest`(`onDevice`: kotlin.Boolean): kotlin.String + public companion object } -/** - * Address response containing the derived address information - */ + @kotlinx.serialization.Serializable -public data class AddressResponse ( - val `address`: kotlin.String, - val `path`: List, - val `serializedPath`: kotlin.String +public data class ActivityTags ( + val `activityId`: kotlin.String, + val `tags`: List ) { public companion object } @@ -284,83 +337,6 @@ public data class ClosedChannelDetails ( -/** - * Coin purchase memo - */ -@kotlinx.serialization.Serializable -public data class CoinPurchaseMemo ( - /** - * Coin type - */ - val `coinType`: kotlin.UInt, - /** - * Amount - */ - val `amount`: kotlin.ULong, - /** - * Address - */ - val `address`: kotlin.String, - /** - * MAC - */ - val `mac`: kotlin.String -) { - public companion object -} - - - -/** - * Common parameters for all Trezor Connect methods - */ -@kotlinx.serialization.Serializable -public data class CommonParams ( - /** - * Specific device instance to use - */ - val `device`: DeviceParams?, - /** - * Set to true if method should use empty passphrase - */ - val `useEmptyPassphrase`: kotlin.Boolean?, - /** - * Allow seedless device - */ - val `allowSeedlessDevice`: kotlin.Boolean?, - /** - * Skip final reload - */ - val `skipFinalReload`: kotlin.Boolean? -) { - public companion object -} - - - -/** - * Account information for compose transaction - */ -@kotlinx.serialization.Serializable -public data class ComposeAccount ( - /** - * Derivation path - */ - val `path`: kotlin.String, - /** - * Account addresses - */ - val `addresses`: AccountAddresses, - /** - * UTXOs - */ - val `utxo`: List -) { - public companion object -} - - - @kotlinx.serialization.Serializable public data class CreateCjitOptions ( val `source`: kotlin.String?, @@ -392,25 +368,6 @@ public data class CreateOrderOptions ( -/** - * Result type for deep link generation, including the URL and the ID used - */ -@kotlinx.serialization.Serializable -public data class DeepLinkResult ( - /** - * The generated deep link URL - */ - val `url`: kotlin.String, - /** - * The request ID used (either provided or auto-generated) - */ - val `requestId`: kotlin.String -) { - public companion object -} - - - @kotlinx.serialization.Serializable public data class DefaultLspBalanceParams ( val `clientBalanceSat`: kotlin.ULong, @@ -422,25 +379,6 @@ public data class DefaultLspBalanceParams ( -/** - * Parameters for specifying a particular device - */ -@kotlinx.serialization.Serializable -public data class DeviceParams ( - /** - * Device instance path - */ - val `path`: kotlin.String?, - /** - * Device instance ID - */ - val `instance`: kotlin.UInt? -) { - public companion object -} - - - @kotlinx.serialization.Serializable public data class ErrorData ( val `errorDetails`: kotlin.String @@ -450,46 +388,6 @@ public data class ErrorData ( -/** - * Feature response containing device capabilities and information - */ -@kotlinx.serialization.Serializable -public data class FeatureResponse ( - val `vendor`: kotlin.String, - val `majorVersion`: kotlin.UInt, - val `minorVersion`: kotlin.UInt, - val `patchVersion`: kotlin.UInt, - val `deviceId`: kotlin.String, - val `capabilities`: List? -) { - public companion object -} - - - -/** - * Fee level for compose transaction - */ -@kotlinx.serialization.Serializable -public data class FeeLevel ( - /** - * Fee per unit (satoshi/byte or satoshi/vbyte) - */ - val `feePerUnit`: kotlin.String, - /** - * Base fee in satoshi (optional, used in RBF and DOGE) - */ - val `baseFee`: kotlin.UInt?, - /** - * Floor base fee (optional, used in DOGE) - */ - val `floorBaseFee`: kotlin.Boolean? -) { - public companion object -} - - - @kotlinx.serialization.Serializable public data class FeeRates ( val `fast`: kotlin.UInt, @@ -543,64 +441,6 @@ public data class GetAddressesResponse ( -/** - * HD Node Path Type - */ -@kotlinx.serialization.Serializable -public data class HdNodePathType ( - /** - * Node data (can be String or HDNodeType) - */ - val `node`: HdNodeTypeOrString, - /** - * BIP32 derivation path - */ - val `addressN`: List -) { - public companion object -} - - - -/** - * HD Node Type - */ -@kotlinx.serialization.Serializable -public data class HdNodeType ( - /** - * Depth - */ - val `depth`: kotlin.UInt, - /** - * Fingerprint - */ - val `fingerprint`: kotlin.UInt, - /** - * Child number - */ - val `childNum`: kotlin.UInt, - /** - * Chain code - */ - val `chainCode`: kotlin.String, - /** - * Public key - */ - val `publicKey`: kotlin.String, - /** - * Private key (optional) - */ - val `privateKey`: kotlin.String?, - /** - * BIP32 derivation path (optional) - */ - val `addressN`: List? -) { - public companion object -} - - - @kotlinx.serialization.Serializable public data class IBt0ConfMinTxFeeWindow ( val `satPerVbyte`: kotlin.Double, @@ -1167,49 +1007,30 @@ public data class LnurlWithdrawData ( /** - * Message signature response - */ -@kotlinx.serialization.Serializable -public data class MessageSignatureResponse ( - /** - * Signer address - */ - val `address`: kotlin.String, - /** - * Signature in base64 format - */ - val `signature`: kotlin.String -) { - public companion object -} - - - -/** - * Multisig Redeem Script Type + * Native device information returned from enumeration */ @kotlinx.serialization.Serializable -public data class MultisigRedeemScriptType ( +public data class NativeDeviceInfo ( /** - * Public keys + * Unique path/identifier for this device */ - val `pubkeys`: List, + val `path`: kotlin.String, /** - * Signatures + * Transport type: "usb" or "bluetooth" */ - val `signatures`: List, + val `transportType`: kotlin.String, /** - * M-of-N threshold + * Optional device name (from BLE advertisement or USB descriptor) */ - val `m`: kotlin.UInt, + val `name`: kotlin.String?, /** - * Nodes (optional) + * USB Vendor ID (for USB devices) */ - val `nodes`: List?, + val `vendorId`: kotlin.UShort?, /** - * Pubkeys order (optional): 0 for PRESERVED, 1 for LEXICOGRAPHIC + * USB Product ID (for USB devices) */ - val `pubkeysOrder`: kotlin.UByte? + val `productId`: kotlin.UShort? ) { public companion object } @@ -1256,29 +1077,6 @@ public data class OnchainActivity ( -/** - * Payment request memo types - */ -@kotlinx.serialization.Serializable -public data class PaymentRequestMemo ( - /** - * Text memo - */ - val `textMemo`: TextMemo?, - /** - * Refund memo - */ - val `refundMemo`: RefundMemo?, - /** - * Coin purchase memo - */ - val `coinPurchaseMemo`: CoinPurchaseMemo? -) { - public companion object -} - - - @kotlinx.serialization.Serializable public data class PreActivityMetadata ( val `paymentId`: kotlin.String, @@ -1297,186 +1095,109 @@ public data class PreActivityMetadata ( -/** - * Precomposed transaction input - */ @kotlinx.serialization.Serializable -public data class PrecomposedInput ( - /** - * BIP32 derivation path - */ - val `addressN`: List, - /** - * Amount in satoshis - */ - val `amount`: kotlin.String, - /** - * Previous transaction hash - */ - val `prevHash`: kotlin.String, - /** - * Previous output index - */ - val `prevIndex`: kotlin.UInt, - /** - * Script type - */ - val `scriptType`: ScriptType +public data class PubkyAuth ( + val `data`: kotlin.String ) { public companion object } -/** - * Precomposed transaction output - */ @kotlinx.serialization.Serializable -public data class PrecomposedOutput ( +public data class SweepResult ( /** - * BIP32 derivation path (for change outputs) + * The transaction ID of the sweep transaction */ - val `addressN`: List?, + val `txid`: kotlin.String, /** - * Amount in satoshis + * The total amount swept (in satoshis) */ - val `amount`: kotlin.String, + val `amountSwept`: kotlin.ULong, /** - * Address (for regular outputs) + * The fee paid (in satoshis) */ - val `address`: kotlin.String?, + val `feePaid`: kotlin.ULong, /** - * Script type + * The number of UTXOs swept */ - val `scriptType`: ScriptType + val `utxosSwept`: kotlin.UInt ) { public companion object } -/** - * Precomposed transaction - */ @kotlinx.serialization.Serializable -public data class PrecomposedTransaction ( - /** - * Transaction type (usually "final" or "error") - */ - val `txType`: kotlin.String, +public data class SweepTransactionPreview ( /** - * Total amount spent (including fee) + * The PSBT (Partially Signed Bitcoin Transaction) in base64 format */ - val `totalSpent`: kotlin.String?, + val `psbt`: kotlin.String, /** - * Transaction fee + * The total amount available to sweep (in satoshis) */ - val `fee`: kotlin.String?, + val `totalAmount`: kotlin.ULong, /** - * Fee per byte + * The estimated fee for the transaction (in satoshis) */ - val `feePerByte`: kotlin.String?, + val `estimatedFee`: kotlin.ULong, /** - * Transaction size in bytes + * The estimated virtual size of the transaction (in vbytes) */ - val `bytes`: kotlin.UInt?, + val `estimatedVsize`: kotlin.ULong, /** - * Transaction inputs + * The number of UTXOs that will be swept */ - val `inputs`: List?, + val `utxosCount`: kotlin.UInt, /** - * Transaction outputs + * The destination address */ - val `outputs`: List?, + val `destinationAddress`: kotlin.String, /** - * Output permutation indices + * The amount that will be sent to destination after fees (in satoshis) */ - val `outputsPermutation`: List? -) { - public companion object -} - - - -@kotlinx.serialization.Serializable -public data class PubkyAuth ( - val `data`: kotlin.String -) { - public companion object -} - - - -/** - * Public key response containing the derived public key information - */ -@kotlinx.serialization.Serializable -public data class PublicKeyResponse ( - val `path`: List, - val `serializedPath`: kotlin.String, - val `xpub`: kotlin.String, - val `xpubSegwit`: kotlin.String?, - val `chainCode`: kotlin.String, - val `childNum`: kotlin.UInt, - val `publicKey`: kotlin.String, - val `fingerprint`: kotlin.UInt, - val `depth`: kotlin.UInt, - val `descriptor`: kotlin.String? + val `amountAfterFees`: kotlin.ULong ) { public companion object } -/** - * Reference transaction for transaction signing - */ @kotlinx.serialization.Serializable -public data class RefTransaction ( - /** - * Transaction hash - */ - val `hash`: kotlin.String, - /** - * Transaction version - */ - val `version`: kotlin.UInt?, - /** - * Transaction inputs - */ - val `inputs`: List, +public data class SweepableBalances ( /** - * Transaction outputs (binary format) + * Balance in legacy (P2PKH) addresses (in satoshis) */ - val `binOutputs`: List, + val `legacyBalance`: kotlin.ULong, /** - * Lock time + * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) */ - val `lockTime`: kotlin.UInt?, + val `p2shBalance`: kotlin.ULong, /** - * Expiry (for Zcash/Decred) + * Balance in Taproot (P2TR) addresses (in satoshis) */ - val `expiry`: kotlin.UInt?, + val `taprootBalance`: kotlin.ULong, /** - * Version group ID (for Zcash) + * Total balance across all wallet types (in satoshis) */ - val `versionGroupId`: kotlin.UInt?, + val `totalBalance`: kotlin.ULong, /** - * Overwintered flag (for Zcash) + * Number of UTXOs in legacy wallet */ - val `overwintered`: kotlin.Boolean?, + val `legacyUtxosCount`: kotlin.UInt, /** - * Timestamp (for Capricoin) + * Number of UTXOs in P2SH-SegWit wallet */ - val `timestamp`: kotlin.UInt?, + val `p2shUtxosCount`: kotlin.UInt, /** - * Branch ID (for Zcash) + * Number of UTXOs in Taproot wallet */ - val `branchId`: kotlin.UInt?, + val `taprootUtxosCount`: kotlin.UInt, /** - * Extra data + * Total number of UTXOs across all wallet types */ - val `extraData`: kotlin.String? + val `totalUtxosCount`: kotlin.UInt ) { public companion object } @@ -1484,26 +1205,31 @@ public data class RefTransaction ( /** - * Reference transaction input + * Details about an onchain transaction. */ @kotlinx.serialization.Serializable -public data class RefTxInput ( +public data class TransactionDetails ( /** - * Previous transaction hash + * The transaction ID. */ - val `prevHash`: kotlin.String, + val `txId`: kotlin.String, /** - * Previous transaction 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. */ - val `prevIndex`: kotlin.UInt, + val `amountSats`: kotlin.Long, /** - * Script signature + * The transaction inputs with full details. */ - val `scriptSig`: kotlin.String, + val `inputs`: List, /** - * Sequence number + * The transaction outputs with full details. */ - val `sequence`: kotlin.UInt + val `outputs`: List ) { public companion object } @@ -1511,18 +1237,18 @@ public data class RefTxInput ( /** - * Reference transaction output (binary format) + * Address response from device. */ @kotlinx.serialization.Serializable -public data class RefTxOutput ( +public data class TrezorAddressResponse ( /** - * Amount in satoshis + * The Bitcoin address */ - val `amount`: kotlin.ULong, + val `address`: kotlin.String, /** - * Script public key (binary hex) + * The serialized path (e.g., "m/84'/0'/0'/0/0") */ - val `scriptPubkey`: kotlin.String + val `path`: kotlin.String ) { public companion object } @@ -1530,141 +1256,189 @@ public data class RefTxOutput ( /** - * Refund memo + * Result from a high-level message call (for BLE/THP devices) */ @kotlinx.serialization.Serializable -public data class RefundMemo ( +public data class TrezorCallMessageResult ( /** - * Refund address + * Whether the call succeeded */ - val `address`: kotlin.String, + val `success`: kotlin.Boolean, + /** + * Response message type + */ + val `messageType`: kotlin.UShort, + /** + * Response protobuf data + */ + val `data`: kotlin.ByteArray, /** - * MAC + * Error message (empty on success) */ - val `mac`: kotlin.String + val `error`: kotlin.String ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || this::class != other::class) return false + + other as TrezorCallMessageResult + if (`success` != other.`success`) return false + if (`messageType` != other.`messageType`) return false + if (!`data`.contentEquals(other.`data`)) return false + if (`error` != other.`error`) return false + + return true + } + override fun hashCode(): Int { + var result = `success`.hashCode() + result = 31 * result + `messageType`.hashCode() + result = 31 * result + `data`.contentHashCode() + result = 31 * result + `error`.hashCode() + return result + } public companion object } /** - * Signed transaction response + * Device information exposed to FFI. */ @kotlinx.serialization.Serializable -public data class SignedTransactionResponse ( +public data class TrezorDeviceInfo ( /** - * Array of signer signatures + * Unique identifier for the device */ - val `signatures`: List, + val `id`: kotlin.String, /** - * Serialized transaction + * Transport type (USB or Bluetooth) */ - val `serializedTx`: kotlin.String, + val `transportType`: TrezorTransportType, /** - * Broadcasted transaction ID (if push was true) + * Device name (from BLE advertisement or USB descriptor) */ - val `txid`: kotlin.String? -) { - public companion object -} - - - -@kotlinx.serialization.Serializable -public data class SweepResult ( + val `name`: kotlin.String?, /** - * The transaction ID of the sweep transaction + * Transport-specific path (used internally for connection) */ - val `txid`: kotlin.String, + val `path`: kotlin.String, /** - * The total amount swept (in satoshis) + * Device label (set by user during device setup) */ - val `amountSwept`: kotlin.ULong, + val `label`: kotlin.String?, /** - * The fee paid (in satoshis) + * Device model (e.g., "T2", "Safe 5", "Safe 7") */ - val `feePaid`: kotlin.ULong, + val `model`: kotlin.String?, /** - * The number of UTXOs swept + * Whether the device is in bootloader mode */ - val `utxosSwept`: kotlin.UInt + val `isBootloader`: kotlin.Boolean ) { public companion object } +/** + * Device features after initialization. + */ @kotlinx.serialization.Serializable -public data class SweepTransactionPreview ( +public data class TrezorFeatures ( /** - * The PSBT (Partially Signed Bitcoin Transaction) in base64 format + * Vendor string */ - val `psbt`: kotlin.String, + val `vendor`: kotlin.String?, /** - * The total amount available to sweep (in satoshis) + * Device model */ - val `totalAmount`: kotlin.ULong, + val `model`: kotlin.String?, /** - * The estimated fee for the transaction (in satoshis) + * Device label (set by user during device setup) */ - val `estimatedFee`: kotlin.ULong, + val `label`: kotlin.String?, /** - * The estimated virtual size of the transaction (in vbytes) + * Device ID (unique per device) */ - val `estimatedVsize`: kotlin.ULong, + val `deviceId`: kotlin.String?, /** - * The number of UTXOs that will be swept + * Major firmware version */ - val `utxosCount`: kotlin.UInt, + val `majorVersion`: kotlin.UInt?, /** - * The destination address + * Minor firmware version */ - val `destinationAddress`: kotlin.String, + val `minorVersion`: kotlin.UInt?, /** - * The amount that will be sent to destination after fees (in satoshis) + * Patch firmware version */ - val `amountAfterFees`: kotlin.ULong + val `patchVersion`: kotlin.UInt?, + /** + * Whether PIN protection is enabled + */ + val `pinProtection`: kotlin.Boolean?, + /** + * Whether passphrase protection is enabled + */ + val `passphraseProtection`: kotlin.Boolean?, + /** + * Whether the device is initialized with a seed + */ + val `initialized`: kotlin.Boolean?, + /** + * Whether the device needs backup + */ + val `needsBackup`: kotlin.Boolean? ) { public companion object } +/** + * Parameters for getting an address from the device. + */ @kotlinx.serialization.Serializable -public data class SweepableBalances ( - /** - * Balance in legacy (P2PKH) addresses (in satoshis) - */ - val `legacyBalance`: kotlin.ULong, +public data class TrezorGetAddressParams ( /** - * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) + * BIP32 path (e.g., "m/84'/0'/0'/0/0") */ - val `p2shBalance`: kotlin.ULong, + val `path`: kotlin.String, /** - * Balance in Taproot (P2TR) addresses (in satoshis) + * Coin network (default: Bitcoin) */ - val `taprootBalance`: kotlin.ULong, + val `coin`: TrezorCoinType?, /** - * Total balance across all wallet types (in satoshis) + * Whether to display the address on the device for confirmation */ - val `totalBalance`: kotlin.ULong, + val `showOnTrezor`: kotlin.Boolean, /** - * Number of UTXOs in legacy wallet + * Script type (auto-detected from path if not specified) */ - val `legacyUtxosCount`: kotlin.UInt, + val `scriptType`: TrezorScriptType? +) { + public companion object +} + + + +/** + * Parameters for getting a public key from the device. + */ +@kotlinx.serialization.Serializable +public data class TrezorGetPublicKeyParams ( /** - * Number of UTXOs in P2SH-SegWit wallet + * BIP32 path (e.g., "m/84'/0'/0'") */ - val `p2shUtxosCount`: kotlin.UInt, + val `path`: kotlin.String, /** - * Number of UTXOs in Taproot wallet + * Coin network (default: Bitcoin) */ - val `taprootUtxosCount`: kotlin.UInt, + val `coin`: TrezorCoinType?, /** - * Total number of UTXOs across all wallet types + * Whether to display on device for confirmation */ - val `totalUtxosCount`: kotlin.UInt + val `showOnTrezor`: kotlin.Boolean ) { public companion object } @@ -1672,14 +1446,30 @@ public data class SweepableBalances ( /** - * Text memo + * Previous transaction data (for non-SegWit input verification). */ @kotlinx.serialization.Serializable -public data class TextMemo ( +public data class TrezorPrevTx ( + /** + * Transaction hash (hex encoded) + */ + val `hash`: kotlin.String, + /** + * Transaction version + */ + val `version`: kotlin.UInt, + /** + * Lock time + */ + val `lockTime`: kotlin.UInt, + /** + * Transaction inputs + */ + val `inputs`: List, /** - * Text content + * Transaction outputs */ - val `text`: kotlin.String + val `outputs`: List ) { public companion object } @@ -1687,31 +1477,45 @@ public data class TextMemo ( /** - * Details about an onchain transaction. + * Input of a previous transaction. */ @kotlinx.serialization.Serializable -public data class TransactionDetails ( +public data class TrezorPrevTxInput ( /** - * The transaction ID. + * Previous transaction hash (hex encoded) */ - val `txId`: kotlin.String, + val `prevHash`: kotlin.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. + * Previous output index */ - val `amountSats`: kotlin.Long, + val `prevIndex`: kotlin.UInt, /** - * The transaction inputs with full details. + * Script signature (hex encoded) + */ + val `scriptSig`: kotlin.String, + /** + * Sequence number + */ + val `sequence`: kotlin.UInt +) { + public companion object +} + + + +/** + * Output of a previous transaction. + */ +@kotlinx.serialization.Serializable +public data class TrezorPrevTxOutput ( + /** + * Amount in satoshis */ - val `inputs`: List, + val `amount`: kotlin.ULong, /** - * The transaction outputs with full details. + * Script pubkey (hex encoded) */ - val `outputs`: List + val `scriptPubkey`: kotlin.String ) { public companion object } @@ -1719,30 +1523,38 @@ public data class TransactionDetails ( /** - * Payment request + * Public key response from device. */ @kotlinx.serialization.Serializable -public data class TxAckPaymentRequest ( +public data class TrezorPublicKeyResponse ( + /** + * Extended public key (xpub) + */ + val `xpub`: kotlin.String, /** - * Nonce + * The serialized path (e.g., "m/84'/0'/0'") */ - val `nonce`: kotlin.String?, + val `path`: kotlin.String, /** - * Recipient name + * Compressed public key (hex encoded) */ - val `recipientName`: kotlin.String, + val `publicKey`: kotlin.String, /** - * Memos + * Chain code (hex encoded) */ - val `memos`: List?, + val `chainCode`: kotlin.String, /** - * Amount + * Parent key fingerprint */ - val `amount`: kotlin.ULong?, + val `fingerprint`: kotlin.UInt, /** - * Signature + * Derivation depth */ - val `signature`: kotlin.String + val `depth`: kotlin.UInt, + /** + * Master root fingerprint (from the device's master seed) + */ + val `rootFingerprint`: kotlin.UInt? ) { public companion object } @@ -1750,30 +1562,22 @@ public data class TxAckPaymentRequest ( /** - * Details about a transaction input. + * Parameters for signing a message. */ @kotlinx.serialization.Serializable -public data class TxInput ( - /** - * The transaction ID of the previous output being spent. - */ - val `txid`: kotlin.String, - /** - * The output index of the previous output being spent. - */ - val `vout`: kotlin.UInt, +public data class TrezorSignMessageParams ( /** - * The script signature (hex-encoded). + * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") */ - val `scriptsig`: kotlin.String, + val `path`: kotlin.String, /** - * The witness stack (hex-encoded strings). + * Message to sign */ - val `witness`: List, + val `message`: kotlin.String, /** - * The sequence number. + * Coin network (default: Bitcoin) */ - val `sequence`: kotlin.UInt + val `coin`: TrezorCoinType? ) { public companion object } @@ -1781,70 +1585,131 @@ public data class TxInput ( /** - * Transaction input type + * Parameters for signing a transaction. */ @kotlinx.serialization.Serializable -public data class TxInputType ( +public data class TrezorSignTxParams ( /** - * Previous transaction hash + * Transaction inputs */ - val `prevHash`: kotlin.String, + val `inputs`: List, /** - * Previous transaction output index + * Transaction outputs */ - val `prevIndex`: kotlin.UInt, + val `outputs`: List, /** - * Amount in satoshis + * Coin network (default: Bitcoin) */ - val `amount`: kotlin.ULong, + val `coin`: TrezorCoinType?, /** - * Transaction sequence + * Lock time (default: 0) */ - val `sequence`: kotlin.UInt?, + val `lockTime`: kotlin.UInt?, /** - * BIP32 derivation path + * Version (default: 2) */ - val `addressN`: List?, + val `version`: kotlin.UInt?, /** - * Script type + * Previous transactions (for non-SegWit input verification) */ - val `scriptType`: ScriptType?, + val `prevTxs`: List +) { + public companion object +} + + + +/** + * Response from signing a message. + */ +@kotlinx.serialization.Serializable +public data class TrezorSignedMessageResponse ( /** - * Multisig information + * Bitcoin address that signed the message */ - val `multisig`: MultisigRedeemScriptType?, + val `address`: kotlin.String, /** - * Script public key (for external inputs) + * Signature (base64 encoded) */ - val `scriptPubkey`: kotlin.String?, + val `signature`: kotlin.String +) { + public companion object +} + + + +/** + * Signed transaction result. + */ +@kotlinx.serialization.Serializable +public data class TrezorSignedTx ( /** - * Script signature + * Signatures for each input (hex encoded) */ - val `scriptSig`: kotlin.String?, + val `signatures`: List, /** - * Witness data + * Serialized transaction (hex) */ - val `witness`: kotlin.String?, + val `serializedTx`: kotlin.String +) { + public companion object +} + + + +/** + * Result from a transport read operation + */ +@kotlinx.serialization.Serializable +public data class TrezorTransportReadResult ( /** - * Ownership proof + * Whether the read succeeded */ - val `ownershipProof`: kotlin.String?, + val `success`: kotlin.Boolean, /** - * Commitment data + * Data read (empty on failure) */ - val `commitmentData`: kotlin.String?, + val `data`: kotlin.ByteArray, /** - * Original hash for RBF + * Error message (empty on success) */ - val `origHash`: kotlin.String?, + val `error`: kotlin.String +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || this::class != other::class) return false + + other as TrezorTransportReadResult + if (`success` != other.`success`) return false + if (!`data`.contentEquals(other.`data`)) return false + if (`error` != other.`error`) return false + + return true + } + override fun hashCode(): Int { + var result = `success`.hashCode() + result = 31 * result + `data`.contentHashCode() + result = 31 * result + `error`.hashCode() + return result + } + public companion object +} + + + +/** + * Result from a transport write or open operation + */ +@kotlinx.serialization.Serializable +public data class TrezorTransportWriteResult ( /** - * Original index for RBF + * Whether the operation succeeded */ - val `origIndex`: kotlin.UInt?, + val `success`: kotlin.Boolean, /** - * Coinjoin flags + * Error message (empty on success) */ - val `coinjoinFlags`: kotlin.UInt? + val `error`: kotlin.String ) { public companion object } @@ -1852,30 +1717,42 @@ public data class TxInputType ( /** - * Details about a transaction output. + * Transaction input for signing. */ @kotlinx.serialization.Serializable -public data class TxOutput ( +public data class TrezorTxInput ( /** - * The script public key (hex-encoded). + * Previous transaction hash (hex, 32 bytes) */ - val `scriptpubkey`: kotlin.String, + val `prevHash`: kotlin.String, /** - * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + * Previous output index */ - val `scriptpubkeyType`: kotlin.String?, + val `prevIndex`: kotlin.UInt, /** - * The address corresponding to this script (if decodable). + * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") */ - val `scriptpubkeyAddress`: kotlin.String?, + val `path`: kotlin.String, /** - * The value in satoshis. + * Amount in satoshis */ - val `value`: kotlin.Long, + val `amount`: kotlin.ULong, /** - * The output index in the transaction. + * Script type */ - val `n`: kotlin.UInt + val `scriptType`: TrezorScriptType, + /** + * Sequence number (default: 0xFFFFFFFD for RBF) + */ + val `sequence`: kotlin.UInt?, + /** + * Original transaction hash for RBF replacement (hex encoded) + */ + val `origHash`: kotlin.String?, + /** + * Original input index for RBF replacement + */ + val `origIndex`: kotlin.UInt? ) { public companion object } @@ -1883,46 +1760,38 @@ public data class TxOutput ( /** - * Transaction output type + * Transaction output for signing. */ @kotlinx.serialization.Serializable -public data class TxOutputType ( +public data class TrezorTxOutput ( /** - * Output address (for address outputs) + * Destination address (for external outputs) */ val `address`: kotlin.String?, /** - * BIP32 derivation path (for change outputs) + * BIP32 path (for change outputs) */ - val `addressN`: List?, + val `path`: kotlin.String?, /** * Amount in satoshis */ val `amount`: kotlin.ULong, /** - * Script type - */ - val `scriptType`: ScriptType, - /** - * Multisig information + * Script type (for change outputs) */ - val `multisig`: MultisigRedeemScriptType?, + val `scriptType`: TrezorScriptType?, /** - * OP_RETURN data + * OP_RETURN data (hex encoded, for data outputs) */ val `opReturnData`: kotlin.String?, /** - * Original hash for RBF + * Original transaction hash for RBF replacement (hex encoded) */ val `origHash`: kotlin.String?, /** - * Original index for RBF - */ - val `origIndex`: kotlin.UInt?, - /** - * Payment request index + * Original output index for RBF replacement */ - val `paymentReqIndex`: kotlin.UInt? + val `origIndex`: kotlin.UInt? ) { public companion object } @@ -1930,44 +1799,26 @@ public data class TxOutputType ( /** - * Unlock Path parameters + * Parameters for verifying a message signature. */ @kotlinx.serialization.Serializable -public data class UnlockPath ( +public data class TrezorVerifyMessageParams ( /** - * BIP32 derivation path + * Bitcoin address that signed the message */ - val `addressN`: List, + val `address`: kotlin.String, /** - * MAC (optional) + * Signature (base64 encoded) */ - val `mac`: kotlin.String? -) { - public companion object -} - - - -@kotlinx.serialization.Serializable -public data class ValidationResult ( - val `address`: kotlin.String, - val `network`: NetworkType, - val `addressType`: AddressType -) { - public companion object -} - - - -/** - * Verify message response - */ -@kotlinx.serialization.Serializable -public data class VerifyMessageResponse ( + val `signature`: kotlin.String, + /** + * Original message + */ + val `message`: kotlin.String, /** - * Verification result message + * Coin network (default: Bitcoin) */ - val `message`: kotlin.String + val `coin`: TrezorCoinType? ) { public companion object } @@ -1975,53 +1826,76 @@ public data class VerifyMessageResponse ( /** - * Marker object for XRP accounts + * Details about a transaction input. */ @kotlinx.serialization.Serializable -public data class XrpMarker ( +public data class TxInput ( /** - * Ledger number + * The transaction ID of the previous output being spent. */ - val `ledger`: kotlin.ULong, + val `txid`: kotlin.String, /** - * Sequence number + * The output index of the previous output being spent. + */ + val `vout`: kotlin.UInt, + /** + * The script signature (hex-encoded). + */ + val `scriptsig`: kotlin.String, + /** + * The witness stack (hex-encoded strings). + */ + val `witness`: List, + /** + * The sequence number. */ - val `seq`: kotlin.ULong + val `sequence`: kotlin.UInt ) { public companion object } - /** - * Level of details to be returned by getAccountInfo + * Details about a transaction output. */ - @kotlinx.serialization.Serializable -public enum class AccountInfoDetails { - +public data class TxOutput ( /** - * Return only account balances (default) + * The script public key (hex-encoded). + */ + val `scriptpubkey`: kotlin.String, + /** + * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). */ - BASIC, + val `scriptpubkeyType`: kotlin.String?, /** - * Return with derived addresses or ERC20 tokens + * The address corresponding to this script (if decodable). */ - TOKENS, + val `scriptpubkeyAddress`: kotlin.String?, /** - * Same as tokens with balances + * The value in satoshis. */ - TOKEN_BALANCES, + val `value`: kotlin.Long, /** - * TokenBalances + complete account transaction history + * The output index in the transaction. */ - TXS; + val `n`: kotlin.UInt +) { public companion object } +@kotlinx.serialization.Serializable +public data class ValidationResult ( + val `address`: kotlin.String, + val `network`: NetworkType, + val `addressType`: AddressType +) { + public companion object +} + @@ -2193,25 +2067,6 @@ public enum class AddressType { -/** - * Amount unit for display - */ - -@kotlinx.serialization.Serializable -public enum class AmountUnit { - - BITCOIN, - MILLI_BITCOIN, - MICRO_BITCOIN, - SATOSHI; - public companion object -} - - - - - - @kotlinx.serialization.Serializable public enum class BitcoinNetworkEnum { @@ -2442,112 +2297,15 @@ public enum class BtPaymentState2 { - -@kotlinx.serialization.Serializable -public enum class CJitStateEnum { - - CREATED, - COMPLETED, - EXPIRED, - FAILED; - public companion object -} - - - - - - -/** - * Output type for compose transaction - */ -@kotlinx.serialization.Serializable -public sealed class ComposeOutput { - - /** - * Regular output with amount and address - */@kotlinx.serialization.Serializable - public data class Regular( - /** - * Amount in satoshis - */ - val `amount`: kotlin.String, - /** - * Recipient address - */ - val `address`: kotlin.String, - ) : ComposeOutput() { - } - - /** - * Send max output - */@kotlinx.serialization.Serializable - public data class SendMax( - /** - * Recipient address - */ - val `address`: kotlin.String, - ) : ComposeOutput() { - } - - /** - * OP_RETURN output - */@kotlinx.serialization.Serializable - public data class OpReturn( - /** - * Hexadecimal string with arbitrary data - */ - val `dataHex`: kotlin.String, - ) : ComposeOutput() { - } - - /** - * Payment without address (precompose only) - */@kotlinx.serialization.Serializable - public data class PaymentNoAddress( - /** - * Amount in satoshis - */ - val `amount`: kotlin.String, - ) : ComposeOutput() { - } - - /** - * Send max without address (precompose only) - */ - @kotlinx.serialization.Serializable - public data object SendMaxNoAddress : ComposeOutput() - - -} - - - - - - -/** - * Compose transaction response - */ + @kotlinx.serialization.Serializable -public sealed class ComposeTransactionResponse { - - /** - * Signed transaction (payment mode) - */@kotlinx.serialization.Serializable - public data class SignedTransaction( - val v1: SignedTransactionResponse, - ) : ComposeTransactionResponse() { - } - - /** - * Precomposed transactions (precompose mode) - */@kotlinx.serialization.Serializable - public data class PrecomposedTransactions( - val v1: List, - ) : ComposeTransactionResponse() { - } +public enum class CJitStateEnum { + CREATED, + COMPLETED, + EXPIRED, + FAILED; + public companion object } @@ -2668,62 +2426,6 @@ public sealed class DecodingException: kotlin.Exception() { -/** - * Bitcoin account types for default display - */ - -@kotlinx.serialization.Serializable -public enum class DefaultAccountType { - - /** - * Normal account - */ - NORMAL, - /** - * SegWit account - */ - SEGWIT, - /** - * Legacy account - */ - LEGACY; - public companion object -} - - - - - - -/** - * Union type for HD Node (either a String or HDNodeType) - */ -@kotlinx.serialization.Serializable -public sealed class HdNodeTypeOrString { - - /** - * HD Node as a string - */@kotlinx.serialization.Serializable - public data class String( - val v1: kotlin.String, - ) : HdNodeTypeOrString() { - } - - /** - * HD Node as an object - */@kotlinx.serialization.Serializable - public data class Node( - val v1: HdNodeType, - ) : HdNodeTypeOrString() { - } - -} - - - - - - public sealed class LnurlException: kotlin.Exception() { @@ -2933,34 +2635,6 @@ public sealed class Scanner { -/** - * Script type for inputs and outputs - */ - -@kotlinx.serialization.Serializable -public enum class ScriptType { - - SPEND_ADDRESS, - SPEND_MULTISIG, - SPEND_WITNESS, - SPEND_P2SH_WITNESS, - SPEND_TAPROOT, - EXTERNAL, - PAY_TO_ADDRESS, - PAY_TO_SCRIPT_HASH, - PAY_TO_MULTISIG, - PAY_TO_WITNESS, - PAY_TO_P2SH_WITNESS, - PAY_TO_TAPROOT, - PAY_TO_OP_RETURN; - public companion object -} - - - - - - @kotlinx.serialization.Serializable public enum class SortDirection { @@ -3003,24 +2677,28 @@ public sealed class SweepException: kotlin.Exception() { /** - * Token filter options for getAccountInfo + * Bitcoin network / coin type for Trezor operations. */ @kotlinx.serialization.Serializable -public enum class TokenFilter { +public enum class TrezorCoinType { /** - * Return only addresses with nonzero balance (default) + * Bitcoin mainnet + */ + BITCOIN, + /** + * Bitcoin testnet */ - NONZERO, + TESTNET, /** - * Return addresses with at least one transaction + * Bitcoin signet (treated as testnet by the device) */ - USED, + SIGNET, /** - * Return all derived addresses + * Bitcoin regtest */ - DERIVED; + REGTEST; public companion object } @@ -3031,157 +2709,187 @@ public enum class TokenFilter { /** - * Error types for Trezor Connect operations + * Trezor-related errors exposed via FFI. */ -public sealed class TrezorConnectException: kotlin.Exception() { +public sealed class TrezorException: kotlin.Exception() { /** - * Error during serialization/deserialization + * Transport layer error (USB/Bluetooth communication) */ - public class SerdeException( + public class TransportException( public val `errorDetails`: kotlin.String, - ) : TrezorConnectException() { + ) : TrezorException() { override val message: String get() = "errorDetails=${ `errorDetails` }" } /** - * Error with URL parsing or formatting + * No Trezor device found */ - public class UrlException( - public val `errorDetails`: kotlin.String, - ) : TrezorConnectException() { + public class DeviceNotFound( + ) : TrezorException() { override val message: String - get() = "errorDetails=${ `errorDetails` }" + get() = "" + } + + /** + * Device disconnected during operation + */ + public class DeviceDisconnected( + ) : TrezorException() { + override val message: String + get() = "" } /** - * Environment-related errors + * Connection error */ - public class EnvironmentException( + public class ConnectionException( public val `errorDetails`: kotlin.String, - ) : TrezorConnectException() { + ) : TrezorException() { override val message: String get() = "errorDetails=${ `errorDetails` }" } /** - * General errors + * Protocol error (encoding/decoding) */ - public class Other( + public class ProtocolException( public val `errorDetails`: kotlin.String, - ) : TrezorConnectException() { + ) : TrezorException() { override val message: String get() = "errorDetails=${ `errorDetails` }" } - public class ClientException( + /** + * Pairing required for Bluetooth connection + */ + public class PairingRequired( + ) : TrezorException() { + override val message: String + get() = "" + } + + /** + * Pairing failed + */ + public class PairingFailed( public val `errorDetails`: kotlin.String, - ) : TrezorConnectException() { + ) : TrezorException() { override val message: String get() = "errorDetails=${ `errorDetails` }" } -} - - - - -/** - * Environment options for Trezor deep linking - */ - -@kotlinx.serialization.Serializable -public enum class TrezorEnvironment { + /** + * PIN is required + */ + public class PinRequired( + ) : TrezorException() { + override val message: String + get() = "" + } /** - * Production environment (currently unavailable according to docs) + * PIN entry cancelled */ - PRODUCTION, + public class PinCancelled( + ) : TrezorException() { + override val message: String + get() = "" + } + /** - * Development environment + * Invalid PIN entered */ - DEVELOPMENT, + public class InvalidPin( + ) : TrezorException() { + override val message: String + get() = "" + } + /** - * Local environment + * Passphrase is required */ - LOCAL; - public companion object -} - - - - - - -/** - * Enum representing the different types of Trezor responses - */ -@kotlinx.serialization.Serializable -public sealed class TrezorResponsePayload { + public class PassphraseRequired( + ) : TrezorException() { + override val message: String + get() = "" + } /** - * Response from getFeatures method - */@kotlinx.serialization.Serializable - public data class Features( - val v1: FeatureResponse, - ) : TrezorResponsePayload() { + * Action cancelled by user on device + */ + public class UserCancelled( + ) : TrezorException() { + override val message: String + get() = "" } /** - * Response from getAddress method - */@kotlinx.serialization.Serializable - public data class Address( - val v1: AddressResponse, - ) : TrezorResponsePayload() { + * Operation timed out + */ + public class Timeout( + ) : TrezorException() { + override val message: String + get() = "" } /** - * Response from getPublicKey method - */@kotlinx.serialization.Serializable - public data class PublicKey( - val v1: PublicKeyResponse, - ) : TrezorResponsePayload() { + * Invalid derivation path + */ + public class InvalidPath( + public val `errorDetails`: kotlin.String, + ) : TrezorException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" } /** - * Response from getAccountInfo method - */@kotlinx.serialization.Serializable - public data class AccountInfo( - val v1: AccountInfoResponse, - ) : TrezorResponsePayload() { + * Device returned an error + */ + public class DeviceException( + public val `errorDetails`: kotlin.String, + ) : TrezorException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" } /** - * Response from composeTransaction method - */@kotlinx.serialization.Serializable - public data class ComposeTransaction( - val v1: ComposeTransactionResponse, - ) : TrezorResponsePayload() { + * Trezor manager not initialized + */ + public class NotInitialized( + ) : TrezorException() { + override val message: String + get() = "" } /** - * Response from verifyMessage method - */@kotlinx.serialization.Serializable - public data class VerifyMessage( - val v1: VerifyMessageResponse, - ) : TrezorResponsePayload() { + * No device connected + */ + public class NotConnected( + ) : TrezorException() { + override val message: String + get() = "" } /** - * Response from signMessage method - */@kotlinx.serialization.Serializable - public data class MessageSignature( - val v1: MessageSignatureResponse, - ) : TrezorResponsePayload() { + * Session error + */ + public class SessionException( + public val `errorDetails`: kotlin.String, + ) : TrezorException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" } /** - * Response from signTransaction method - */@kotlinx.serialization.Serializable - public data class SignedTransaction( - val v1: SignedTransactionResponse, - ) : TrezorResponsePayload() { + * IO error + */ + public class IoException( + public val `errorDetails`: kotlin.String, + ) : TrezorException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" } } @@ -3189,32 +2897,37 @@ public sealed class TrezorResponsePayload { - - +/** + * Script types for address derivation. + */ @kotlinx.serialization.Serializable -public enum class WordCount { +public enum class TrezorScriptType { /** - * 12-word mnemonic (128 bits of entropy) + * P2PKH (legacy) */ - WORDS12, + SPEND_ADDRESS, /** - * 15-word mnemonic (160 bits of entropy) + * P2SH-P2WPKH (nested SegWit) */ - WORDS15, + SPEND_P2SH_WITNESS, /** - * 18-word mnemonic (192 bits of entropy) + * P2WPKH (native SegWit) */ - WORDS18, + SPEND_WITNESS, /** - * 21-word mnemonic (224 bits of entropy) + * P2TR (Taproot) */ - WORDS21, + SPEND_TAPROOT, /** - * 24-word mnemonic (256 bits of entropy) + * P2SH multisig */ - WORDS24; + SPEND_MULTISIG, + /** + * External/watch-only input (not signed by device) + */ + EXTERNAL; public companion object } @@ -3223,7 +2936,23 @@ public enum class WordCount { +/** + * Transport type for Trezor devices. + */ +@kotlinx.serialization.Serializable +public enum class TrezorTransportType { + + /** + * USB connection + */ + USB, + /** + * Bluetooth connection + */ + BLUETOOTH; + public companion object +} @@ -3231,48 +2960,31 @@ public enum class WordCount { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +@kotlinx.serialization.Serializable +public enum class WordCount { + + /** + * 12-word mnemonic (128 bits of entropy) + */ + WORDS12, + /** + * 15-word mnemonic (160 bits of entropy) + */ + WORDS15, + /** + * 18-word mnemonic (192 bits of entropy) + */ + WORDS18, + /** + * 21-word mnemonic (224 bits of entropy) + */ + WORDS21, + /** + * 24-word mnemonic (256 bits of entropy) + */ + WORDS24; + public companion object +} diff --git a/bindings/ios/BitkitCore.xcframework.zip b/bindings/ios/BitkitCore.xcframework.zip index 512aa67..0fa3136 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 478a88f..b7357e0 100644 --- a/bindings/ios/BitkitCore.xcframework/Info.plist +++ b/bindings/ios/BitkitCore.xcframework/Info.plist @@ -10,7 +10,7 @@ HeadersPath Headers LibraryIdentifier - ios-arm64 + ios-arm64-simulator LibraryPath libbitkitcore.a SupportedArchitectures @@ -19,6 +19,8 @@ SupportedPlatform ios + SupportedPlatformVariant + simulator BinaryPath @@ -26,7 +28,7 @@ HeadersPath Headers LibraryIdentifier - ios-arm64-simulator + ios-arm64 LibraryPath libbitkitcore.a SupportedArchitectures @@ -35,8 +37,6 @@ 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 d4a9c1e..ad95039 100644 --- a/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/Headers/bitkitcoreFFI.h +++ b/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/Headers/bitkitcoreFFI.h @@ -250,6 +250,219 @@ typedef struct UniffiForeignFutureStructVoid { typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureStructVoid ); +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod0)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod1)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod2)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod3)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod4)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod5)(uint64_t, RustBuffer, uint32_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod6)(uint64_t, RustBuffer, uint16_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod7)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod8)(uint64_t, RustBuffer, RustBuffer, int8_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod9)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod10)(uint64_t, RustBuffer, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTrezorUiCallbackMethod0)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTrezorUiCallbackMethod1)(uint64_t, int8_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTrezorTransportCallback { + UniffiCallbackInterfaceTrezorTransportCallbackMethod0 _Nonnull enumerateDevices; + UniffiCallbackInterfaceTrezorTransportCallbackMethod1 _Nonnull openDevice; + UniffiCallbackInterfaceTrezorTransportCallbackMethod2 _Nonnull closeDevice; + UniffiCallbackInterfaceTrezorTransportCallbackMethod3 _Nonnull readChunk; + UniffiCallbackInterfaceTrezorTransportCallbackMethod4 _Nonnull writeChunk; + UniffiCallbackInterfaceTrezorTransportCallbackMethod5 _Nonnull getChunkSize; + UniffiCallbackInterfaceTrezorTransportCallbackMethod6 _Nonnull callMessage; + UniffiCallbackInterfaceTrezorTransportCallbackMethod7 _Nonnull getPairingCode; + UniffiCallbackInterfaceTrezorTransportCallbackMethod8 _Nonnull saveThpCredential; + UniffiCallbackInterfaceTrezorTransportCallbackMethod9 _Nonnull loadThpCredential; + UniffiCallbackInterfaceTrezorTransportCallbackMethod10 _Nonnull logDebug; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceTrezorTransportCallback; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTrezorUiCallback { + UniffiCallbackInterfaceTrezorUiCallbackMethod0 _Nonnull onPinRequest; + UniffiCallbackInterfaceTrezorUiCallbackMethod1 _Nonnull onPassphraseRequest; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceTrezorUiCallback; + +#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 +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORTRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORTRANSPORTCALLBACK +void uniffi_bitkitcore_fn_free_trezortransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORTRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORTRANSPORTCALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(const UniffiVTableCallbackInterfaceTrezorTransportCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_open_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_close_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk(void*_Nonnull ptr, RustBuffer path, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +uint32_t uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_call_message(void*_Nonnull ptr, RustBuffer path, uint16_t message_type, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +int8_t uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential(void*_Nonnull ptr, RustBuffer device_id, RustBuffer credential_json, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential(void*_Nonnull ptr, RustBuffer device_id, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +void uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug(void*_Nonnull ptr, RustBuffer tag, RustBuffer message, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORUICALLBACK +void*_Nonnull uniffi_bitkitcore_fn_clone_trezoruicallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORUICALLBACK +void uniffi_bitkitcore_fn_free_trezoruicallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORUICALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(const UniffiVTableCallbackInterfaceTrezorUiCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +RustBuffer uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +RustBuffer uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request(void*_Nonnull ptr, int8_t on_device, RustCallStatus *_Nonnull out_status +); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ACTIVITY_WIPE_ALL #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ACTIVITY_WIPE_ALL @@ -627,44 +840,113 @@ void uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags(RustBuffer payme uint64_t uniffi_bitkitcore_fn_func_test_notification(RustBuffer device_token, RustBuffer secret_message, RustBuffer notification_type, RustBuffer custom_url ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_COMPOSE_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_COMPOSE_TRANSACTION -RustBuffer uniffi_bitkitcore_fn_func_trezor_compose_transaction(RustBuffer outputs, RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer push, RustBuffer sequence, RustBuffer account, RustBuffer fee_levels, RustBuffer skip_permutation, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CLEAR_CREDENTIALS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CLEAR_CREDENTIALS +uint64_t uniffi_bitkitcore_fn_func_trezor_clear_credentials(RustBuffer device_id ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ACCOUNT_INFO -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ACCOUNT_INFO -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_account_info(RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer path, RustBuffer descriptor, RustBuffer details, RustBuffer tokens, RustBuffer page, RustBuffer pageSize, RustBuffer from, RustBuffer to, RustBuffer gap, RustBuffer contractFilter, RustBuffer marker, RustBuffer defaultAccountType, RustBuffer suppressBackupWarning, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CONNECT +uint64_t uniffi_bitkitcore_fn_func_trezor_connect(RustBuffer device_id +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_DISCONNECT +uint64_t uniffi_bitkitcore_fn_func_trezor_disconnect(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ADDRESS #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ADDRESS -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_address(RustBuffer path, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer address, RustBuffer showOnTrezor, RustBuffer chunkify, RustBuffer useEventListener, RustBuffer coin, RustBuffer crossChain, RustBuffer multisig, RustBuffer scriptType, RustBuffer unlockPath, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_get_address(RustBuffer params +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_CONNECTED_DEVICE +uint64_t uniffi_bitkitcore_fn_func_trezor_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +uint64_t uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_FEATURES #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_FEATURES -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_features(RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_get_features(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_PUBLIC_KEY +uint64_t uniffi_bitkitcore_fn_func_trezor_get_public_key(RustBuffer params ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_HANDLE_DEEP_LINK -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_HANDLE_DEEP_LINK -RustBuffer uniffi_bitkitcore_fn_func_trezor_handle_deep_link(RustBuffer callback_url, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_INITIALIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_INITIALIZE +uint64_t uniffi_bitkitcore_fn_func_trezor_initialize(RustBuffer credential_path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_BLE_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_BLE_AVAILABLE +int8_t uniffi_bitkitcore_fn_func_trezor_is_ble_available(RustCallStatus *_Nonnull out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_CONNECTED +uint64_t uniffi_bitkitcore_fn_func_trezor_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_INITIALIZED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_INITIALIZED +uint64_t uniffi_bitkitcore_fn_func_trezor_is_initialized(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_LIST_DEVICES +uint64_t uniffi_bitkitcore_fn_func_trezor_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SCAN +uint64_t uniffi_bitkitcore_fn_func_trezor_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +void uniffi_bitkitcore_fn_func_trezor_set_transport_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_UI_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_UI_CALLBACK +void uniffi_bitkitcore_fn_func_trezor_set_ui_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_MESSAGE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_MESSAGE -RustBuffer uniffi_bitkitcore_fn_func_trezor_sign_message(RustBuffer path, RustBuffer message, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer coin, RustBuffer hex, RustBuffer no_script_type, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_message(RustBuffer params +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_tx(RustBuffer params ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TRANSACTION -RustBuffer uniffi_bitkitcore_fn_func_trezor_sign_transaction(RustBuffer coin, RustBuffer inputs, RustBuffer outputs, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer ref_txs, RustBuffer payment_requests, RustBuffer locktime, RustBuffer version, RustBuffer expiry, RustBuffer version_group_id, RustBuffer overwintered, RustBuffer timestamp, RustBuffer branch_id, RustBuffer push, RustBuffer amount_unit, RustBuffer unlock_path, RustBuffer serialize, RustBuffer chunkify, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX_FROM_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX_FROM_PSBT +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt(RustBuffer psbt_base64, RustBuffer network ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_VERIFY_MESSAGE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_VERIFY_MESSAGE -RustBuffer uniffi_bitkitcore_fn_func_trezor_verify_message(RustBuffer address, RustBuffer signature, RustBuffer message, RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer hex, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_verify_message(RustBuffer params ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_UPDATE_ACTIVITY @@ -1483,15 +1765,21 @@ uint16_t uniffi_bitkitcore_checksum_func_test_notification(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_COMPOSE_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_COMPOSE_TRANSACTION -uint16_t uniffi_bitkitcore_checksum_func_trezor_compose_transaction(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CLEAR_CREDENTIALS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CLEAR_CREDENTIALS +uint16_t uniffi_bitkitcore_checksum_func_trezor_clear_credentials(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CONNECT +uint16_t uniffi_bitkitcore_checksum_func_trezor_connect(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ACCOUNT_INFO -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ACCOUNT_INFO -uint16_t uniffi_bitkitcore_checksum_func_trezor_get_account_info(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_DISCONNECT +uint16_t uniffi_bitkitcore_checksum_func_trezor_disconnect(void ); #endif @@ -1499,6 +1787,18 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_get_account_info(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ADDRESS uint16_t uniffi_bitkitcore_checksum_func_trezor_get_address(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_CONNECTED_DEVICE +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_FEATURES @@ -1507,9 +1807,57 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_get_features(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_HANDLE_DEEP_LINK -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_HANDLE_DEEP_LINK -uint16_t uniffi_bitkitcore_checksum_func_trezor_handle_deep_link(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_PUBLIC_KEY +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_public_key(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_INITIALIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_INITIALIZE +uint16_t uniffi_bitkitcore_checksum_func_trezor_initialize(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_BLE_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_BLE_AVAILABLE +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_ble_available(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_CONNECTED +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_INITIALIZED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_INITIALIZED +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_initialized(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_LIST_DEVICES +uint16_t uniffi_bitkitcore_checksum_func_trezor_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SCAN +uint16_t uniffi_bitkitcore_checksum_func_trezor_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_trezor_set_transport_callback(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_UI_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_UI_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_trezor_set_ui_callback(void ); #endif @@ -1519,9 +1867,15 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_message(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TRANSACTION -uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_transaction(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX +uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_tx(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX_FROM_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX_FROM_PSBT +uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt(void ); #endif @@ -1643,6 +1997,84 @@ uint16_t uniffi_bitkitcore_checksum_func_wipe_all_databases(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_WIPE_ALL_TRANSACTION_DETAILS uint16_t uniffi_bitkitcore_checksum_func_wipe_all_transaction_details(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +uint16_t uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +uint16_t uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request(void + ); #endif #ifndef UNIFFI_FFIDEF_FFI_BITKITCORE_UNIFFI_CONTRACT_VERSION diff --git a/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/libbitkitcore.a b/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/libbitkitcore.a index 8eff570..1eda6f7 100644 Binary files a/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/libbitkitcore.a and b/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/libbitkitcore.a differ diff --git a/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h b/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h index d4a9c1e..ad95039 100644 --- a/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h +++ b/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h @@ -250,6 +250,219 @@ typedef struct UniffiForeignFutureStructVoid { typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureStructVoid ); +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod0)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod1)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod2)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod3)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod4)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod5)(uint64_t, RustBuffer, uint32_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod6)(uint64_t, RustBuffer, uint16_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod7)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod8)(uint64_t, RustBuffer, RustBuffer, int8_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod9)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod10)(uint64_t, RustBuffer, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTrezorUiCallbackMethod0)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTrezorUiCallbackMethod1)(uint64_t, int8_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTrezorTransportCallback { + UniffiCallbackInterfaceTrezorTransportCallbackMethod0 _Nonnull enumerateDevices; + UniffiCallbackInterfaceTrezorTransportCallbackMethod1 _Nonnull openDevice; + UniffiCallbackInterfaceTrezorTransportCallbackMethod2 _Nonnull closeDevice; + UniffiCallbackInterfaceTrezorTransportCallbackMethod3 _Nonnull readChunk; + UniffiCallbackInterfaceTrezorTransportCallbackMethod4 _Nonnull writeChunk; + UniffiCallbackInterfaceTrezorTransportCallbackMethod5 _Nonnull getChunkSize; + UniffiCallbackInterfaceTrezorTransportCallbackMethod6 _Nonnull callMessage; + UniffiCallbackInterfaceTrezorTransportCallbackMethod7 _Nonnull getPairingCode; + UniffiCallbackInterfaceTrezorTransportCallbackMethod8 _Nonnull saveThpCredential; + UniffiCallbackInterfaceTrezorTransportCallbackMethod9 _Nonnull loadThpCredential; + UniffiCallbackInterfaceTrezorTransportCallbackMethod10 _Nonnull logDebug; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceTrezorTransportCallback; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTrezorUiCallback { + UniffiCallbackInterfaceTrezorUiCallbackMethod0 _Nonnull onPinRequest; + UniffiCallbackInterfaceTrezorUiCallbackMethod1 _Nonnull onPassphraseRequest; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceTrezorUiCallback; + +#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 +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORTRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORTRANSPORTCALLBACK +void uniffi_bitkitcore_fn_free_trezortransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORTRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORTRANSPORTCALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(const UniffiVTableCallbackInterfaceTrezorTransportCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_open_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_close_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk(void*_Nonnull ptr, RustBuffer path, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +uint32_t uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_call_message(void*_Nonnull ptr, RustBuffer path, uint16_t message_type, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +int8_t uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential(void*_Nonnull ptr, RustBuffer device_id, RustBuffer credential_json, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential(void*_Nonnull ptr, RustBuffer device_id, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +void uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug(void*_Nonnull ptr, RustBuffer tag, RustBuffer message, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORUICALLBACK +void*_Nonnull uniffi_bitkitcore_fn_clone_trezoruicallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORUICALLBACK +void uniffi_bitkitcore_fn_free_trezoruicallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORUICALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(const UniffiVTableCallbackInterfaceTrezorUiCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +RustBuffer uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +RustBuffer uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request(void*_Nonnull ptr, int8_t on_device, RustCallStatus *_Nonnull out_status +); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ACTIVITY_WIPE_ALL #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ACTIVITY_WIPE_ALL @@ -627,44 +840,113 @@ void uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags(RustBuffer payme uint64_t uniffi_bitkitcore_fn_func_test_notification(RustBuffer device_token, RustBuffer secret_message, RustBuffer notification_type, RustBuffer custom_url ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_COMPOSE_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_COMPOSE_TRANSACTION -RustBuffer uniffi_bitkitcore_fn_func_trezor_compose_transaction(RustBuffer outputs, RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer push, RustBuffer sequence, RustBuffer account, RustBuffer fee_levels, RustBuffer skip_permutation, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CLEAR_CREDENTIALS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CLEAR_CREDENTIALS +uint64_t uniffi_bitkitcore_fn_func_trezor_clear_credentials(RustBuffer device_id ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ACCOUNT_INFO -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ACCOUNT_INFO -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_account_info(RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer path, RustBuffer descriptor, RustBuffer details, RustBuffer tokens, RustBuffer page, RustBuffer pageSize, RustBuffer from, RustBuffer to, RustBuffer gap, RustBuffer contractFilter, RustBuffer marker, RustBuffer defaultAccountType, RustBuffer suppressBackupWarning, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CONNECT +uint64_t uniffi_bitkitcore_fn_func_trezor_connect(RustBuffer device_id +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_DISCONNECT +uint64_t uniffi_bitkitcore_fn_func_trezor_disconnect(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ADDRESS #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ADDRESS -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_address(RustBuffer path, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer address, RustBuffer showOnTrezor, RustBuffer chunkify, RustBuffer useEventListener, RustBuffer coin, RustBuffer crossChain, RustBuffer multisig, RustBuffer scriptType, RustBuffer unlockPath, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_get_address(RustBuffer params +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_CONNECTED_DEVICE +uint64_t uniffi_bitkitcore_fn_func_trezor_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +uint64_t uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_FEATURES #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_FEATURES -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_features(RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_get_features(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_PUBLIC_KEY +uint64_t uniffi_bitkitcore_fn_func_trezor_get_public_key(RustBuffer params ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_HANDLE_DEEP_LINK -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_HANDLE_DEEP_LINK -RustBuffer uniffi_bitkitcore_fn_func_trezor_handle_deep_link(RustBuffer callback_url, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_INITIALIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_INITIALIZE +uint64_t uniffi_bitkitcore_fn_func_trezor_initialize(RustBuffer credential_path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_BLE_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_BLE_AVAILABLE +int8_t uniffi_bitkitcore_fn_func_trezor_is_ble_available(RustCallStatus *_Nonnull out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_CONNECTED +uint64_t uniffi_bitkitcore_fn_func_trezor_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_INITIALIZED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_INITIALIZED +uint64_t uniffi_bitkitcore_fn_func_trezor_is_initialized(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_LIST_DEVICES +uint64_t uniffi_bitkitcore_fn_func_trezor_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SCAN +uint64_t uniffi_bitkitcore_fn_func_trezor_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +void uniffi_bitkitcore_fn_func_trezor_set_transport_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_UI_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_UI_CALLBACK +void uniffi_bitkitcore_fn_func_trezor_set_ui_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_MESSAGE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_MESSAGE -RustBuffer uniffi_bitkitcore_fn_func_trezor_sign_message(RustBuffer path, RustBuffer message, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer coin, RustBuffer hex, RustBuffer no_script_type, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_message(RustBuffer params +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_tx(RustBuffer params ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TRANSACTION -RustBuffer uniffi_bitkitcore_fn_func_trezor_sign_transaction(RustBuffer coin, RustBuffer inputs, RustBuffer outputs, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer ref_txs, RustBuffer payment_requests, RustBuffer locktime, RustBuffer version, RustBuffer expiry, RustBuffer version_group_id, RustBuffer overwintered, RustBuffer timestamp, RustBuffer branch_id, RustBuffer push, RustBuffer amount_unit, RustBuffer unlock_path, RustBuffer serialize, RustBuffer chunkify, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX_FROM_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX_FROM_PSBT +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt(RustBuffer psbt_base64, RustBuffer network ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_VERIFY_MESSAGE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_VERIFY_MESSAGE -RustBuffer uniffi_bitkitcore_fn_func_trezor_verify_message(RustBuffer address, RustBuffer signature, RustBuffer message, RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer hex, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_verify_message(RustBuffer params ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_UPDATE_ACTIVITY @@ -1483,15 +1765,21 @@ uint16_t uniffi_bitkitcore_checksum_func_test_notification(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_COMPOSE_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_COMPOSE_TRANSACTION -uint16_t uniffi_bitkitcore_checksum_func_trezor_compose_transaction(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CLEAR_CREDENTIALS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CLEAR_CREDENTIALS +uint16_t uniffi_bitkitcore_checksum_func_trezor_clear_credentials(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CONNECT +uint16_t uniffi_bitkitcore_checksum_func_trezor_connect(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ACCOUNT_INFO -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ACCOUNT_INFO -uint16_t uniffi_bitkitcore_checksum_func_trezor_get_account_info(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_DISCONNECT +uint16_t uniffi_bitkitcore_checksum_func_trezor_disconnect(void ); #endif @@ -1499,6 +1787,18 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_get_account_info(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ADDRESS uint16_t uniffi_bitkitcore_checksum_func_trezor_get_address(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_CONNECTED_DEVICE +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_FEATURES @@ -1507,9 +1807,57 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_get_features(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_HANDLE_DEEP_LINK -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_HANDLE_DEEP_LINK -uint16_t uniffi_bitkitcore_checksum_func_trezor_handle_deep_link(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_PUBLIC_KEY +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_public_key(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_INITIALIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_INITIALIZE +uint16_t uniffi_bitkitcore_checksum_func_trezor_initialize(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_BLE_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_BLE_AVAILABLE +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_ble_available(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_CONNECTED +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_INITIALIZED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_INITIALIZED +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_initialized(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_LIST_DEVICES +uint16_t uniffi_bitkitcore_checksum_func_trezor_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SCAN +uint16_t uniffi_bitkitcore_checksum_func_trezor_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_trezor_set_transport_callback(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_UI_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_UI_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_trezor_set_ui_callback(void ); #endif @@ -1519,9 +1867,15 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_message(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TRANSACTION -uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_transaction(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX +uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_tx(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX_FROM_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX_FROM_PSBT +uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt(void ); #endif @@ -1643,6 +1997,84 @@ uint16_t uniffi_bitkitcore_checksum_func_wipe_all_databases(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_WIPE_ALL_TRANSACTION_DETAILS uint16_t uniffi_bitkitcore_checksum_func_wipe_all_transaction_details(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +uint16_t uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +uint16_t uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request(void + ); #endif #ifndef UNIFFI_FFIDEF_FFI_BITKITCORE_UNIFFI_CONTRACT_VERSION diff --git a/bindings/ios/BitkitCore.xcframework/ios-arm64/libbitkitcore.a b/bindings/ios/BitkitCore.xcframework/ios-arm64/libbitkitcore.a index a893ced..167aae6 100644 Binary files a/bindings/ios/BitkitCore.xcframework/ios-arm64/libbitkitcore.a and b/bindings/ios/BitkitCore.xcframework/ios-arm64/libbitkitcore.a differ diff --git a/bindings/ios/bitkitcore.swift b/bindings/ios/bitkitcore.swift index 8c769fc..4c9f712 100644 --- a/bindings/ios/bitkitcore.swift +++ b/bindings/ios/bitkitcore.swift @@ -395,20 +395,26 @@ fileprivate final class UniffiHandleMap: @unchecked Sendable { // Public interface members begin here. - +// Magic number for the Rust proxy to call using the same mechanism as every other method, +// to free the callback once it's dropped by Rust. +private let IDX_CALLBACK_FREE: Int32 = 0 +// Callback return codes +private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0 +private let UNIFFI_CALLBACK_ERROR: Int32 = 1 +private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2 #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterUInt8: FfiConverterPrimitive { - typealias FfiType = UInt8 - typealias SwiftType = UInt8 +fileprivate struct FfiConverterUInt16: FfiConverterPrimitive { + typealias FfiType = UInt16 + typealias SwiftType = UInt16 - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt8 { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt16 { return try lift(readInt(&buf)) } - public static func write(_ value: UInt8, into buf: inout [UInt8]) { + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { writeInt(&buf, lower(value)) } } @@ -561,352 +567,966 @@ fileprivate struct FfiConverterData: FfiConverterRustBuffer { } + + /** - * Account addresses + * Callback interface for native Trezor transport operations + * + * 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 struct AccountAddresses { +public protocol TrezorTransportCallback: AnyObject, Sendable { + /** - * Used addresses + * Enumerate all connected Trezor devices */ - public var used: [AddressInfo] + func enumerateDevices() -> [NativeDeviceInfo] + /** - * Unused addresses + * Open a connection to a device */ - public var unused: [AddressInfo] + func openDevice(path: String) -> TrezorTransportWriteResult + /** - * Change addresses + * Close the connection to a device */ - public var change: [AddressInfo] - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Used addresses - */used: [AddressInfo], - /** - * Unused addresses - */unused: [AddressInfo], - /** - * Change addresses - */change: [AddressInfo]) { - self.used = used - self.unused = unused - self.change = change - } + 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. + * + * 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 callMessage(path: String, messageType: UInt16, data: Data) -> TrezorCallMessageResult? + + /** + * 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. + */ + 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 native Trezor transport operations + * + * 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 TrezorTransportCallbackImpl: TrezorTransportCallback, @unchecked Sendable { + fileprivate let pointer: UnsafeMutableRawPointer! -#if compiler(>=6) -extension AccountAddresses: Sendable {} + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) #endif - - -extension AccountAddresses: Equatable, Hashable { - public static func ==(lhs: AccountAddresses, rhs: AccountAddresses) -> Bool { - if lhs.used != rhs.used { - return false - } - if lhs.unused != rhs.unused { - return false - } - if lhs.change != rhs.change { - return false - } - return true + public struct NoPointer { + public init() {} } - public func hash(into hasher: inout Hasher) { - hasher.combine(used) - hasher.combine(unused) - hasher.combine(change) - } -} - -extension AccountAddresses: Codable {} - - - + // 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) + @_documentation(visibility: private) #endif -public struct FfiConverterTypeAccountAddresses: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountAddresses { - return - try AccountAddresses( - used: FfiConverterSequenceTypeAddressInfo.read(from: &buf), - unused: FfiConverterSequenceTypeAddressInfo.read(from: &buf), - change: FfiConverterSequenceTypeAddressInfo.read(from: &buf) - ) - } - - public static func write(_ value: AccountAddresses, into buf: inout [UInt8]) { - FfiConverterSequenceTypeAddressInfo.write(value.used, into: &buf) - FfiConverterSequenceTypeAddressInfo.write(value.unused, into: &buf) - FfiConverterSequenceTypeAddressInfo.write(value.change, into: &buf) + 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) + @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountAddresses_lift(_ buf: RustBuffer) throws -> AccountAddresses { - return try FfiConverterTypeAccountAddresses.lift(buf) -} + public init(noPointer: NoPointer) { + self.pointer = nil + } #if swift(>=5.8) -@_documentation(visibility: private) + @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountAddresses_lower(_ value: AccountAddresses) -> RustBuffer { - return FfiConverterTypeAccountAddresses.lower(value) -} - - -/** - * Account info response - */ -public struct AccountInfoResponse { - public var id: UInt32 - public var path: String - public var descriptor: String - public var legacyXpub: String? - public var balance: String - public var availableBalance: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(id: UInt32, path: String, descriptor: String, legacyXpub: String?, balance: String, availableBalance: String) { - self.id = id - self.path = path - self.descriptor = descriptor - self.legacyXpub = legacyXpub - self.balance = balance - self.availableBalance = availableBalance + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_bitkitcore_fn_clone_trezortransportcallback(self.pointer, $0) } } -} - -#if compiler(>=6) -extension AccountInfoResponse: Sendable {} -#endif + // No primary constructor declared for this class. - -extension AccountInfoResponse: Equatable, Hashable { - public static func ==(lhs: AccountInfoResponse, rhs: AccountInfoResponse) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.path != rhs.path { - return false - } - if lhs.descriptor != rhs.descriptor { - return false - } - if lhs.legacyXpub != rhs.legacyXpub { - return false - } - if lhs.balance != rhs.balance { - return false - } - if lhs.availableBalance != rhs.availableBalance { - return false + deinit { + guard let pointer = pointer else { + return } - return true - } - public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(path) - hasher.combine(descriptor) - hasher.combine(legacyXpub) - hasher.combine(balance) - hasher.combine(availableBalance) + try! rustCall { uniffi_bitkitcore_fn_free_trezortransportcallback(pointer, $0) } } -} - -extension AccountInfoResponse: Codable {} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeAccountInfoResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountInfoResponse { - return - try AccountInfoResponse( - id: FfiConverterUInt32.read(from: &buf), - path: FfiConverterString.read(from: &buf), - descriptor: FfiConverterString.read(from: &buf), - legacyXpub: FfiConverterOptionString.read(from: &buf), - balance: FfiConverterString.read(from: &buf), - availableBalance: FfiConverterString.read(from: &buf) - ) - } + - public static func write(_ value: AccountInfoResponse, into buf: inout [UInt8]) { - FfiConverterUInt32.write(value.id, into: &buf) - FfiConverterString.write(value.path, into: &buf) - FfiConverterString.write(value.descriptor, into: &buf) - FfiConverterOptionString.write(value.legacyXpub, into: &buf) - FfiConverterString.write(value.balance, into: &buf) - FfiConverterString.write(value.availableBalance, into: &buf) - } + + /** + * 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 + ) +}) } - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAccountInfoResponse_lift(_ buf: RustBuffer) throws -> AccountInfoResponse { - return try FfiConverterTypeAccountInfoResponse.lift(buf) + + /** + * 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 + ) +}) } - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAccountInfoResponse_lower(_ value: AccountInfoResponse) -> RustBuffer { - return FfiConverterTypeAccountInfoResponse.lower(value) + + /** + * 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 + ) +}) } - - -/** - * UTXO information for account - */ -public struct AccountUtxo { + /** - * Transaction ID + * Read a chunk of data from the device */ - public var txid: String +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 + ) +}) +} + /** - * Output index + * Write a chunk of data to the device */ - public var vout: UInt32 +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 + ) +}) +} + /** - * Amount in satoshis + * Get the chunk size for a device (64 for USB, 244 for Bluetooth) */ - public var amount: String +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 + ) +}) +} + /** - * Block height + * 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 var blockHeight: UInt32? +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 + ) +}) +} + /** - * Address + * 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 var address: String +open func getPairingCode() -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code(self.uniffiClonePointer(),$0 + ) +}) +} + /** - * Derivation path + * 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 var path: String +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 + ) +}) +} + /** - * Number of confirmations + * 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 var confirmations: UInt32? +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 + ) +} +} + - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Transaction ID - */txid: String, - /** - * Output index - */vout: UInt32, - /** - * Amount in satoshis - */amount: String, - /** - * Block height - */blockHeight: UInt32?, - /** - * Address - */address: String, - /** - * Derivation path - */path: String, - /** - * Number of confirmations - */confirmations: UInt32?) { - self.txid = txid - self.vout = vout - self.amount = amount - self.blockHeight = blockHeight - self.address = address - self.path = path - self.confirmations = confirmations - } } -#if compiler(>=6) -extension AccountUtxo: Sendable {} -#endif +// Put the implementation in a struct so we don't pollute the top-level namespace +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: [UniffiVTableCallbackInterfaceTrezorTransportCallback] = [UniffiVTableCallbackInterfaceTrezorTransportCallback( + enumerateDevices: { ( + uniffiHandle: UInt64, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> [NativeDeviceInfo] in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.enumerateDevices( + ) + } -extension AccountUtxo: Equatable, Hashable { - public static func ==(lhs: AccountUtxo, rhs: AccountUtxo) -> Bool { - if lhs.txid != rhs.txid { - return false - } - if lhs.vout != rhs.vout { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.blockHeight != rhs.blockHeight { - return false - } - if lhs.address != rhs.address { - return false + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterSequenceTypeNativeDeviceInfo.lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + openDevice: { ( + 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.openDevice( + path: try FfiConverterString.lift(path) + ) + } + + + 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, + writeReturn: writeReturn + ) + }, + uniffiFree: { (uniffiHandle: UInt64) -> () in + let result = try? FfiConverterTypeTrezorTransportCallback.handleMap.remove(handle: uniffiHandle) + if result == nil { + print("Uniffi callback interface TrezorTransportCallback: handle missing in uniffiFree") + } } - if lhs.path != rhs.path { - return false + )] +} + +private func uniffiCallbackInitTrezorTransportCallback() { + uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(UniffiCallbackInterfaceTrezorTransportCallback.vtable) +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTrezorTransportCallback: FfiConverter { + fileprivate static let handleMap = UniffiHandleMap() + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = TrezorTransportCallback + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorTransportCallback { + return TrezorTransportCallbackImpl(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: TrezorTransportCallback) -> UnsafeMutableRawPointer { + guard let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: handleMap.insert(obj: value))) else { + fatalError("Cast to UnsafeMutableRawPointer failed") } - if lhs.confirmations != rhs.confirmations { - return false + return ptr + } + + 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. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer } - return true + return try lift(ptr!) } - public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(vout) - hasher.combine(amount) - hasher.combine(blockHeight) - hasher.combine(address) - hasher.combine(path) - hasher.combine(confirmations) + 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. + * + * Methods return `String`: + * - Empty string (`""`) = cancel the request + * - Non-empty string = the user's input (PIN or passphrase) + * + * This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. + */ +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 user should enter on the Trezor itself — + * return any non-empty string (e.g., "ok") to acknowledge. + * + * If `on_device` is false, show a passphrase input UI and return the value. + * Return empty string to cancel. + */ + func onPassphraseRequest(onDevice: Bool) -> String + +} +/** + * 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. + * + * Methods return `String`: + * - Empty string (`""`) = cancel the request + * - Non-empty string = the user's input (PIN or passphrase) + * + * This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. + */ +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 user should enter on the Trezor itself — + * return any non-empty string (e.g., "ok") to acknowledge. + * + * If `on_device` is false, show a passphrase input UI and return the value. + * Return empty string to cancel. + */ +open func onPassphraseRequest(onDevice: Bool) -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request(self.uniffiClonePointer(), + FfiConverterBool.lower(onDevice),$0 + ) +}) +} + + } -extension AccountUtxo: Codable {} +// 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 -> String 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 = FfiConverterString.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 FfiConverterTypeAccountUtxo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountUtxo { - return - try AccountUtxo( - txid: FfiConverterString.read(from: &buf), - vout: FfiConverterUInt32.read(from: &buf), - amount: FfiConverterString.read(from: &buf), - blockHeight: FfiConverterOptionUInt32.read(from: &buf), - address: FfiConverterString.read(from: &buf), - path: FfiConverterString.read(from: &buf), - confirmations: FfiConverterOptionUInt32.read(from: &buf) - ) +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 write(_ value: AccountUtxo, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt32.write(value.vout, into: &buf) - FfiConverterString.write(value.amount, into: &buf) - FfiConverterOptionUInt32.write(value.blockHeight, into: &buf) - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.path, into: &buf) - FfiConverterOptionUInt32.write(value.confirmations, into: &buf) + 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))))) } } @@ -914,18 +1534,20 @@ public struct FfiConverterTypeAccountUtxo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountUtxo_lift(_ buf: RustBuffer) throws -> AccountUtxo { - return try FfiConverterTypeAccountUtxo.lift(buf) +public func FfiConverterTypeTrezorUiCallback_lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorUiCallback { + return try FfiConverterTypeTrezorUiCallback.lift(pointer) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountUtxo_lower(_ value: AccountUtxo) -> RustBuffer { - return FfiConverterTypeAccountUtxo.lower(value) +public func FfiConverterTypeTrezorUiCallback_lower(_ value: TrezorUiCallback) -> UnsafeMutableRawPointer { + return FfiConverterTypeTrezorUiCallback.lower(value) } + + public struct ActivityTags { public var activityId: String public var tags: [String] @@ -998,245 +1620,61 @@ public func FfiConverterTypeActivityTags_lower(_ value: ActivityTags) -> RustBuf } -/** - * Address information - */ -public struct AddressInfo { - /** - * Address string - */ - public var address: String - /** - * Derivation path - */ - public var path: String - /** - * Number of transfers - */ - public var transfers: UInt32 +public struct ChannelLiquidityOptions { + public var defaultLspBalanceSat: UInt64 + public var minLspBalanceSat: UInt64 + public var maxLspBalanceSat: UInt64 + public var maxClientBalanceSat: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Address string - */address: String, - /** - * Derivation path - */path: String, - /** - * Number of transfers - */transfers: UInt32) { - self.address = address - self.path = path - self.transfers = transfers + public init(defaultLspBalanceSat: UInt64, minLspBalanceSat: UInt64, maxLspBalanceSat: UInt64, maxClientBalanceSat: UInt64) { + self.defaultLspBalanceSat = defaultLspBalanceSat + self.minLspBalanceSat = minLspBalanceSat + self.maxLspBalanceSat = maxLspBalanceSat + self.maxClientBalanceSat = maxClientBalanceSat } } #if compiler(>=6) -extension AddressInfo: Sendable {} +extension ChannelLiquidityOptions: Sendable {} #endif -extension AddressInfo: Equatable, Hashable { - public static func ==(lhs: AddressInfo, rhs: AddressInfo) -> Bool { - if lhs.address != rhs.address { +extension ChannelLiquidityOptions: Equatable, Hashable { + public static func ==(lhs: ChannelLiquidityOptions, rhs: ChannelLiquidityOptions) -> Bool { + if lhs.defaultLspBalanceSat != rhs.defaultLspBalanceSat { return false } - if lhs.path != rhs.path { + if lhs.minLspBalanceSat != rhs.minLspBalanceSat { + return false + } + if lhs.maxLspBalanceSat != rhs.maxLspBalanceSat { return false } - if lhs.transfers != rhs.transfers { + if lhs.maxClientBalanceSat != rhs.maxClientBalanceSat { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(path) - hasher.combine(transfers) + hasher.combine(defaultLspBalanceSat) + hasher.combine(minLspBalanceSat) + hasher.combine(maxLspBalanceSat) + hasher.combine(maxClientBalanceSat) } } -extension AddressInfo: Codable {} +extension ChannelLiquidityOptions: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAddressInfo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressInfo { - return - try AddressInfo( - address: FfiConverterString.read(from: &buf), - path: FfiConverterString.read(from: &buf), - transfers: FfiConverterUInt32.read(from: &buf) - ) - } - - public static func write(_ value: AddressInfo, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.path, into: &buf) - FfiConverterUInt32.write(value.transfers, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAddressInfo_lift(_ buf: RustBuffer) throws -> AddressInfo { - return try FfiConverterTypeAddressInfo.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAddressInfo_lower(_ value: AddressInfo) -> RustBuffer { - return FfiConverterTypeAddressInfo.lower(value) -} - - -/** - * Address response containing the derived address information - */ -public struct AddressResponse { - public var address: String - public var path: [UInt32] - public var serializedPath: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(address: String, path: [UInt32], serializedPath: String) { - self.address = address - self.path = path - self.serializedPath = serializedPath - } -} - -#if compiler(>=6) -extension AddressResponse: Sendable {} -#endif - - -extension AddressResponse: Equatable, Hashable { - public static func ==(lhs: AddressResponse, rhs: AddressResponse) -> Bool { - if lhs.address != rhs.address { - return false - } - if lhs.path != rhs.path { - return false - } - if lhs.serializedPath != rhs.serializedPath { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(path) - hasher.combine(serializedPath) - } -} - -extension AddressResponse: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeAddressResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressResponse { - return - try AddressResponse( - address: FfiConverterString.read(from: &buf), - path: FfiConverterSequenceUInt32.read(from: &buf), - serializedPath: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: AddressResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterSequenceUInt32.write(value.path, into: &buf) - FfiConverterString.write(value.serializedPath, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAddressResponse_lift(_ buf: RustBuffer) throws -> AddressResponse { - return try FfiConverterTypeAddressResponse.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeAddressResponse_lower(_ value: AddressResponse) -> RustBuffer { - return FfiConverterTypeAddressResponse.lower(value) -} - - -public struct ChannelLiquidityOptions { - public var defaultLspBalanceSat: UInt64 - public var minLspBalanceSat: UInt64 - public var maxLspBalanceSat: UInt64 - public var maxClientBalanceSat: UInt64 - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(defaultLspBalanceSat: UInt64, minLspBalanceSat: UInt64, maxLspBalanceSat: UInt64, maxClientBalanceSat: UInt64) { - self.defaultLspBalanceSat = defaultLspBalanceSat - self.minLspBalanceSat = minLspBalanceSat - self.maxLspBalanceSat = maxLspBalanceSat - self.maxClientBalanceSat = maxClientBalanceSat - } -} - -#if compiler(>=6) -extension ChannelLiquidityOptions: Sendable {} -#endif - - -extension ChannelLiquidityOptions: Equatable, Hashable { - public static func ==(lhs: ChannelLiquidityOptions, rhs: ChannelLiquidityOptions) -> Bool { - if lhs.defaultLspBalanceSat != rhs.defaultLspBalanceSat { - return false - } - if lhs.minLspBalanceSat != rhs.minLspBalanceSat { - return false - } - if lhs.maxLspBalanceSat != rhs.maxLspBalanceSat { - return false - } - if lhs.maxClientBalanceSat != rhs.maxClientBalanceSat { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(defaultLspBalanceSat) - hasher.combine(minLspBalanceSat) - hasher.combine(maxLspBalanceSat) - hasher.combine(maxClientBalanceSat) - } -} - -extension ChannelLiquidityOptions: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeChannelLiquidityOptions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChannelLiquidityOptions { +public struct FfiConverterTypeChannelLiquidityOptions: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChannelLiquidityOptions { return try ChannelLiquidityOptions( defaultLspBalanceSat: FfiConverterUInt64.read(from: &buf), @@ -1534,102 +1972,59 @@ public func FfiConverterTypeClosedChannelDetails_lower(_ value: ClosedChannelDet } -/** - * Coin purchase memo - */ -public struct CoinPurchaseMemo { - /** - * Coin type - */ - public var coinType: UInt32 - /** - * Amount - */ - public var amount: UInt64 - /** - * Address - */ - public var address: String - /** - * MAC - */ - public var mac: String +public struct CreateCjitOptions { + public var source: String? + public var discountCode: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Coin type - */coinType: UInt32, - /** - * Amount - */amount: UInt64, - /** - * Address - */address: String, - /** - * MAC - */mac: String) { - self.coinType = coinType - self.amount = amount - self.address = address - self.mac = mac + public init(source: String?, discountCode: String?) { + self.source = source + self.discountCode = discountCode } } #if compiler(>=6) -extension CoinPurchaseMemo: Sendable {} +extension CreateCjitOptions: Sendable {} #endif -extension CoinPurchaseMemo: Equatable, Hashable { - public static func ==(lhs: CoinPurchaseMemo, rhs: CoinPurchaseMemo) -> Bool { - if lhs.coinType != rhs.coinType { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.address != rhs.address { +extension CreateCjitOptions: Equatable, Hashable { + public static func ==(lhs: CreateCjitOptions, rhs: CreateCjitOptions) -> Bool { + if lhs.source != rhs.source { return false } - if lhs.mac != rhs.mac { + if lhs.discountCode != rhs.discountCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(coinType) - hasher.combine(amount) - hasher.combine(address) - hasher.combine(mac) + hasher.combine(source) + hasher.combine(discountCode) } } -extension CoinPurchaseMemo: Codable {} +extension CreateCjitOptions: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeCoinPurchaseMemo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CoinPurchaseMemo { +public struct FfiConverterTypeCreateCjitOptions: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CreateCjitOptions { return - try CoinPurchaseMemo( - coinType: FfiConverterUInt32.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - address: FfiConverterString.read(from: &buf), - mac: FfiConverterString.read(from: &buf) + try CreateCjitOptions( + source: FfiConverterOptionString.read(from: &buf), + discountCode: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: CoinPurchaseMemo, into buf: inout [UInt8]) { - FfiConverterUInt32.write(value.coinType, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.mac, into: &buf) + public static func write(_ value: CreateCjitOptions, into buf: inout [UInt8]) { + FfiConverterOptionString.write(value.source, into: &buf) + FfiConverterOptionString.write(value.discountCode, into: &buf) } } @@ -1637,357 +2032,69 @@ public struct FfiConverterTypeCoinPurchaseMemo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCoinPurchaseMemo_lift(_ buf: RustBuffer) throws -> CoinPurchaseMemo { - return try FfiConverterTypeCoinPurchaseMemo.lift(buf) +public func FfiConverterTypeCreateCjitOptions_lift(_ buf: RustBuffer) throws -> CreateCjitOptions { + return try FfiConverterTypeCreateCjitOptions.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCoinPurchaseMemo_lower(_ value: CoinPurchaseMemo) -> RustBuffer { - return FfiConverterTypeCoinPurchaseMemo.lower(value) +public func FfiConverterTypeCreateCjitOptions_lower(_ value: CreateCjitOptions) -> RustBuffer { + return FfiConverterTypeCreateCjitOptions.lower(value) } -/** - * Common parameters for all Trezor Connect methods - */ -public struct CommonParams { - /** - * Specific device instance to use - */ - public var device: DeviceParams? - /** - * Set to true if method should use empty passphrase - */ - public var useEmptyPassphrase: Bool? - /** - * Allow seedless device - */ - public var allowSeedlessDevice: Bool? - /** - * Skip final reload - */ - public var skipFinalReload: Bool? +public struct CreateOrderOptions { + public var clientBalanceSat: UInt64 + public var lspNodeId: String? + public var couponCode: String + public var source: String? + public var discountCode: String? + public var zeroConf: Bool + public var zeroConfPayment: Bool? + public var zeroReserve: Bool + public var clientNodeId: String? + public var signature: String? + public var timestamp: String? + public var refundOnchainAddress: String? + public var announceChannel: Bool // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Specific device instance to use - */device: DeviceParams?, - /** - * Set to true if method should use empty passphrase - */useEmptyPassphrase: Bool?, - /** - * Allow seedless device - */allowSeedlessDevice: Bool?, - /** - * Skip final reload - */skipFinalReload: Bool?) { - self.device = device - self.useEmptyPassphrase = useEmptyPassphrase - self.allowSeedlessDevice = allowSeedlessDevice - self.skipFinalReload = skipFinalReload + public init(clientBalanceSat: UInt64, lspNodeId: String?, couponCode: String, source: String?, discountCode: String?, zeroConf: Bool, zeroConfPayment: Bool?, zeroReserve: Bool, clientNodeId: String?, signature: String?, timestamp: String?, refundOnchainAddress: String?, announceChannel: Bool) { + self.clientBalanceSat = clientBalanceSat + self.lspNodeId = lspNodeId + self.couponCode = couponCode + self.source = source + self.discountCode = discountCode + self.zeroConf = zeroConf + self.zeroConfPayment = zeroConfPayment + self.zeroReserve = zeroReserve + self.clientNodeId = clientNodeId + self.signature = signature + self.timestamp = timestamp + self.refundOnchainAddress = refundOnchainAddress + self.announceChannel = announceChannel } } #if compiler(>=6) -extension CommonParams: Sendable {} +extension CreateOrderOptions: Sendable {} #endif -extension CommonParams: Equatable, Hashable { - public static func ==(lhs: CommonParams, rhs: CommonParams) -> Bool { - if lhs.device != rhs.device { +extension CreateOrderOptions: Equatable, Hashable { + public static func ==(lhs: CreateOrderOptions, rhs: CreateOrderOptions) -> Bool { + if lhs.clientBalanceSat != rhs.clientBalanceSat { return false } - if lhs.useEmptyPassphrase != rhs.useEmptyPassphrase { + if lhs.lspNodeId != rhs.lspNodeId { return false } - if lhs.allowSeedlessDevice != rhs.allowSeedlessDevice { + if lhs.couponCode != rhs.couponCode { return false } - if lhs.skipFinalReload != rhs.skipFinalReload { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(device) - hasher.combine(useEmptyPassphrase) - hasher.combine(allowSeedlessDevice) - hasher.combine(skipFinalReload) - } -} - -extension CommonParams: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeCommonParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CommonParams { - return - try CommonParams( - device: FfiConverterOptionTypeDeviceParams.read(from: &buf), - useEmptyPassphrase: FfiConverterOptionBool.read(from: &buf), - allowSeedlessDevice: FfiConverterOptionBool.read(from: &buf), - skipFinalReload: FfiConverterOptionBool.read(from: &buf) - ) - } - - public static func write(_ value: CommonParams, into buf: inout [UInt8]) { - FfiConverterOptionTypeDeviceParams.write(value.device, into: &buf) - FfiConverterOptionBool.write(value.useEmptyPassphrase, into: &buf) - FfiConverterOptionBool.write(value.allowSeedlessDevice, into: &buf) - FfiConverterOptionBool.write(value.skipFinalReload, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCommonParams_lift(_ buf: RustBuffer) throws -> CommonParams { - return try FfiConverterTypeCommonParams.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCommonParams_lower(_ value: CommonParams) -> RustBuffer { - return FfiConverterTypeCommonParams.lower(value) -} - - -/** - * Account information for compose transaction - */ -public struct ComposeAccount { - /** - * Derivation path - */ - public var path: String - /** - * Account addresses - */ - public var addresses: AccountAddresses - /** - * UTXOs - */ - public var utxo: [AccountUtxo] - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Derivation path - */path: String, - /** - * Account addresses - */addresses: AccountAddresses, - /** - * UTXOs - */utxo: [AccountUtxo]) { - self.path = path - self.addresses = addresses - self.utxo = utxo - } -} - -#if compiler(>=6) -extension ComposeAccount: Sendable {} -#endif - - -extension ComposeAccount: Equatable, Hashable { - public static func ==(lhs: ComposeAccount, rhs: ComposeAccount) -> Bool { - if lhs.path != rhs.path { - return false - } - if lhs.addresses != rhs.addresses { - return false - } - if lhs.utxo != rhs.utxo { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(addresses) - hasher.combine(utxo) - } -} - -extension ComposeAccount: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeComposeAccount: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposeAccount { - return - try ComposeAccount( - path: FfiConverterString.read(from: &buf), - addresses: FfiConverterTypeAccountAddresses.read(from: &buf), - utxo: FfiConverterSequenceTypeAccountUtxo.read(from: &buf) - ) - } - - public static func write(_ value: ComposeAccount, into buf: inout [UInt8]) { - FfiConverterString.write(value.path, into: &buf) - FfiConverterTypeAccountAddresses.write(value.addresses, into: &buf) - FfiConverterSequenceTypeAccountUtxo.write(value.utxo, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeComposeAccount_lift(_ buf: RustBuffer) throws -> ComposeAccount { - return try FfiConverterTypeComposeAccount.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeComposeAccount_lower(_ value: ComposeAccount) -> RustBuffer { - return FfiConverterTypeComposeAccount.lower(value) -} - - -public struct CreateCjitOptions { - public var source: String? - public var discountCode: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(source: String?, discountCode: String?) { - self.source = source - self.discountCode = discountCode - } -} - -#if compiler(>=6) -extension CreateCjitOptions: Sendable {} -#endif - - -extension CreateCjitOptions: Equatable, Hashable { - public static func ==(lhs: CreateCjitOptions, rhs: CreateCjitOptions) -> Bool { - if lhs.source != rhs.source { - return false - } - if lhs.discountCode != rhs.discountCode { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(source) - hasher.combine(discountCode) - } -} - -extension CreateCjitOptions: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeCreateCjitOptions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CreateCjitOptions { - return - try CreateCjitOptions( - source: FfiConverterOptionString.read(from: &buf), - discountCode: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: CreateCjitOptions, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.source, into: &buf) - FfiConverterOptionString.write(value.discountCode, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCreateCjitOptions_lift(_ buf: RustBuffer) throws -> CreateCjitOptions { - return try FfiConverterTypeCreateCjitOptions.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeCreateCjitOptions_lower(_ value: CreateCjitOptions) -> RustBuffer { - return FfiConverterTypeCreateCjitOptions.lower(value) -} - - -public struct CreateOrderOptions { - public var clientBalanceSat: UInt64 - public var lspNodeId: String? - public var couponCode: String - public var source: String? - public var discountCode: String? - public var zeroConf: Bool - public var zeroConfPayment: Bool? - public var zeroReserve: Bool - public var clientNodeId: String? - public var signature: String? - public var timestamp: String? - public var refundOnchainAddress: String? - public var announceChannel: Bool - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(clientBalanceSat: UInt64, lspNodeId: String?, couponCode: String, source: String?, discountCode: String?, zeroConf: Bool, zeroConfPayment: Bool?, zeroReserve: Bool, clientNodeId: String?, signature: String?, timestamp: String?, refundOnchainAddress: String?, announceChannel: Bool) { - self.clientBalanceSat = clientBalanceSat - self.lspNodeId = lspNodeId - self.couponCode = couponCode - self.source = source - self.discountCode = discountCode - self.zeroConf = zeroConf - self.zeroConfPayment = zeroConfPayment - self.zeroReserve = zeroReserve - self.clientNodeId = clientNodeId - self.signature = signature - self.timestamp = timestamp - self.refundOnchainAddress = refundOnchainAddress - self.announceChannel = announceChannel - } -} - -#if compiler(>=6) -extension CreateOrderOptions: Sendable {} -#endif - - -extension CreateOrderOptions: Equatable, Hashable { - public static func ==(lhs: CreateOrderOptions, rhs: CreateOrderOptions) -> Bool { - if lhs.clientBalanceSat != rhs.clientBalanceSat { - return false - } - if lhs.lspNodeId != rhs.lspNodeId { - return false - } - if lhs.couponCode != rhs.couponCode { - return false - } - if lhs.source != rhs.source { + if lhs.source != rhs.source { return false } if lhs.discountCode != rhs.discountCode { @@ -2097,74 +2204,67 @@ public func FfiConverterTypeCreateOrderOptions_lower(_ value: CreateOrderOptions } -/** - * Result type for deep link generation, including the URL and the ID used - */ -public struct DeepLinkResult { - /** - * The generated deep link URL - */ - public var url: String - /** - * The request ID used (either provided or auto-generated) - */ - public var requestId: String +public struct DefaultLspBalanceParams { + public var clientBalanceSat: UInt64 + public var maxChannelSizeSat: UInt64 + public var satsPerEur: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * The generated deep link URL - */url: String, - /** - * The request ID used (either provided or auto-generated) - */requestId: String) { - self.url = url - self.requestId = requestId + public init(clientBalanceSat: UInt64, maxChannelSizeSat: UInt64, satsPerEur: UInt64) { + self.clientBalanceSat = clientBalanceSat + self.maxChannelSizeSat = maxChannelSizeSat + self.satsPerEur = satsPerEur } } #if compiler(>=6) -extension DeepLinkResult: Sendable {} +extension DefaultLspBalanceParams: Sendable {} #endif -extension DeepLinkResult: Equatable, Hashable { - public static func ==(lhs: DeepLinkResult, rhs: DeepLinkResult) -> Bool { - if lhs.url != rhs.url { +extension DefaultLspBalanceParams: Equatable, Hashable { + public static func ==(lhs: DefaultLspBalanceParams, rhs: DefaultLspBalanceParams) -> Bool { + if lhs.clientBalanceSat != rhs.clientBalanceSat { return false } - if lhs.requestId != rhs.requestId { + if lhs.maxChannelSizeSat != rhs.maxChannelSizeSat { + return false + } + if lhs.satsPerEur != rhs.satsPerEur { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(url) - hasher.combine(requestId) + hasher.combine(clientBalanceSat) + hasher.combine(maxChannelSizeSat) + hasher.combine(satsPerEur) } } -extension DeepLinkResult: Codable {} +extension DefaultLspBalanceParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDeepLinkResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DeepLinkResult { +public struct FfiConverterTypeDefaultLspBalanceParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DefaultLspBalanceParams { return - try DeepLinkResult( - url: FfiConverterString.read(from: &buf), - requestId: FfiConverterString.read(from: &buf) + try DefaultLspBalanceParams( + clientBalanceSat: FfiConverterUInt64.read(from: &buf), + maxChannelSizeSat: FfiConverterUInt64.read(from: &buf), + satsPerEur: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: DeepLinkResult, into buf: inout [UInt8]) { - FfiConverterString.write(value.url, into: &buf) - FfiConverterString.write(value.requestId, into: &buf) + public static func write(_ value: DefaultLspBalanceParams, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.clientBalanceSat, into: &buf) + FfiConverterUInt64.write(value.maxChannelSizeSat, into: &buf) + FfiConverterUInt64.write(value.satsPerEur, into: &buf) } } @@ -2172,79 +2272,63 @@ public struct FfiConverterTypeDeepLinkResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDeepLinkResult_lift(_ buf: RustBuffer) throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult.lift(buf) +public func FfiConverterTypeDefaultLspBalanceParams_lift(_ buf: RustBuffer) throws -> DefaultLspBalanceParams { + return try FfiConverterTypeDefaultLspBalanceParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDeepLinkResult_lower(_ value: DeepLinkResult) -> RustBuffer { - return FfiConverterTypeDeepLinkResult.lower(value) +public func FfiConverterTypeDefaultLspBalanceParams_lower(_ value: DefaultLspBalanceParams) -> RustBuffer { + return FfiConverterTypeDefaultLspBalanceParams.lower(value) } -public struct DefaultLspBalanceParams { - public var clientBalanceSat: UInt64 - public var maxChannelSizeSat: UInt64 - public var satsPerEur: UInt64 +public struct ErrorData { + public var errorDetails: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(clientBalanceSat: UInt64, maxChannelSizeSat: UInt64, satsPerEur: UInt64) { - self.clientBalanceSat = clientBalanceSat - self.maxChannelSizeSat = maxChannelSizeSat - self.satsPerEur = satsPerEur + public init(errorDetails: String) { + self.errorDetails = errorDetails } } #if compiler(>=6) -extension DefaultLspBalanceParams: Sendable {} +extension ErrorData: Sendable {} #endif -extension DefaultLspBalanceParams: Equatable, Hashable { - public static func ==(lhs: DefaultLspBalanceParams, rhs: DefaultLspBalanceParams) -> Bool { - if lhs.clientBalanceSat != rhs.clientBalanceSat { - return false - } - if lhs.maxChannelSizeSat != rhs.maxChannelSizeSat { - return false - } - if lhs.satsPerEur != rhs.satsPerEur { +extension ErrorData: Equatable, Hashable { + public static func ==(lhs: ErrorData, rhs: ErrorData) -> Bool { + if lhs.errorDetails != rhs.errorDetails { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(clientBalanceSat) - hasher.combine(maxChannelSizeSat) - hasher.combine(satsPerEur) + hasher.combine(errorDetails) } } -extension DefaultLspBalanceParams: Codable {} +extension ErrorData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDefaultLspBalanceParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DefaultLspBalanceParams { +public struct FfiConverterTypeErrorData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ErrorData { return - try DefaultLspBalanceParams( - clientBalanceSat: FfiConverterUInt64.read(from: &buf), - maxChannelSizeSat: FfiConverterUInt64.read(from: &buf), - satsPerEur: FfiConverterUInt64.read(from: &buf) + try ErrorData( + errorDetails: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: DefaultLspBalanceParams, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.clientBalanceSat, into: &buf) - FfiConverterUInt64.write(value.maxChannelSizeSat, into: &buf) - FfiConverterUInt64.write(value.satsPerEur, into: &buf) + public static func write(_ value: ErrorData, into buf: inout [UInt8]) { + FfiConverterString.write(value.errorDetails, into: &buf) } } @@ -2252,86 +2336,79 @@ public struct FfiConverterTypeDefaultLspBalanceParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDefaultLspBalanceParams_lift(_ buf: RustBuffer) throws -> DefaultLspBalanceParams { - return try FfiConverterTypeDefaultLspBalanceParams.lift(buf) +public func FfiConverterTypeErrorData_lift(_ buf: RustBuffer) throws -> ErrorData { + return try FfiConverterTypeErrorData.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDefaultLspBalanceParams_lower(_ value: DefaultLspBalanceParams) -> RustBuffer { - return FfiConverterTypeDefaultLspBalanceParams.lower(value) +public func FfiConverterTypeErrorData_lower(_ value: ErrorData) -> RustBuffer { + return FfiConverterTypeErrorData.lower(value) } -/** - * Parameters for specifying a particular device - */ -public struct DeviceParams { - /** - * Device instance path - */ - public var path: String? - /** - * Device instance ID - */ - public var instance: UInt32? +public struct FeeRates { + public var fast: UInt32 + public var mid: UInt32 + public var slow: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Device instance path - */path: String?, - /** - * Device instance ID - */instance: UInt32?) { - self.path = path - self.instance = instance + public init(fast: UInt32, mid: UInt32, slow: UInt32) { + self.fast = fast + self.mid = mid + self.slow = slow } } #if compiler(>=6) -extension DeviceParams: Sendable {} +extension FeeRates: Sendable {} #endif -extension DeviceParams: Equatable, Hashable { - public static func ==(lhs: DeviceParams, rhs: DeviceParams) -> Bool { - if lhs.path != rhs.path { +extension FeeRates: Equatable, Hashable { + public static func ==(lhs: FeeRates, rhs: FeeRates) -> Bool { + if lhs.fast != rhs.fast { + return false + } + if lhs.mid != rhs.mid { return false } - if lhs.instance != rhs.instance { + if lhs.slow != rhs.slow { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(instance) + hasher.combine(fast) + hasher.combine(mid) + hasher.combine(slow) } } -extension DeviceParams: Codable {} +extension FeeRates: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDeviceParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DeviceParams { +public struct FfiConverterTypeFeeRates: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FeeRates { return - try DeviceParams( - path: FfiConverterOptionString.read(from: &buf), - instance: FfiConverterOptionUInt32.read(from: &buf) + try FeeRates( + fast: FfiConverterUInt32.read(from: &buf), + mid: FfiConverterUInt32.read(from: &buf), + slow: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: DeviceParams, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.path, into: &buf) - FfiConverterOptionUInt32.write(value.instance, into: &buf) + public static func write(_ value: FeeRates, into buf: inout [UInt8]) { + FfiConverterUInt32.write(value.fast, into: &buf) + FfiConverterUInt32.write(value.mid, into: &buf) + FfiConverterUInt32.write(value.slow, into: &buf) } } @@ -2339,63 +2416,71 @@ public struct FfiConverterTypeDeviceParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDeviceParams_lift(_ buf: RustBuffer) throws -> DeviceParams { - return try FfiConverterTypeDeviceParams.lift(buf) +public func FfiConverterTypeFeeRates_lift(_ buf: RustBuffer) throws -> FeeRates { + return try FfiConverterTypeFeeRates.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDeviceParams_lower(_ value: DeviceParams) -> RustBuffer { - return FfiConverterTypeDeviceParams.lower(value) +public func FfiConverterTypeFeeRates_lower(_ value: FeeRates) -> RustBuffer { + return FfiConverterTypeFeeRates.lower(value) } -public struct ErrorData { - public var errorDetails: String +public struct FundingTx { + public var id: String + public var vout: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(errorDetails: String) { - self.errorDetails = errorDetails + public init(id: String, vout: UInt64) { + self.id = id + self.vout = vout } } #if compiler(>=6) -extension ErrorData: Sendable {} +extension FundingTx: Sendable {} #endif -extension ErrorData: Equatable, Hashable { - public static func ==(lhs: ErrorData, rhs: ErrorData) -> Bool { - if lhs.errorDetails != rhs.errorDetails { +extension FundingTx: Equatable, Hashable { + public static func ==(lhs: FundingTx, rhs: FundingTx) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.vout != rhs.vout { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(errorDetails) + hasher.combine(id) + hasher.combine(vout) } } -extension ErrorData: Codable {} +extension FundingTx: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeErrorData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ErrorData { +public struct FfiConverterTypeFundingTx: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FundingTx { return - try ErrorData( - errorDetails: FfiConverterString.read(from: &buf) + try FundingTx( + id: FfiConverterString.read(from: &buf), + vout: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: ErrorData, into buf: inout [UInt8]) { - FfiConverterString.write(value.errorDetails, into: &buf) + public static func write(_ value: FundingTx, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterUInt64.write(value.vout, into: &buf) } } @@ -2403,106 +2488,97 @@ public struct FfiConverterTypeErrorData: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeErrorData_lift(_ buf: RustBuffer) throws -> ErrorData { - return try FfiConverterTypeErrorData.lift(buf) +public func FfiConverterTypeFundingTx_lift(_ buf: RustBuffer) throws -> FundingTx { + return try FfiConverterTypeFundingTx.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeErrorData_lower(_ value: ErrorData) -> RustBuffer { - return FfiConverterTypeErrorData.lower(value) +public func FfiConverterTypeFundingTx_lower(_ value: FundingTx) -> RustBuffer { + return FfiConverterTypeFundingTx.lower(value) } -/** - * Feature response containing device capabilities and information - */ -public struct FeatureResponse { - public var vendor: String - public var majorVersion: UInt32 - public var minorVersion: UInt32 - public var patchVersion: UInt32 - public var deviceId: String - public var capabilities: [String]? +public struct GetAddressResponse { + /** + * The generated Bitcoin address as a string + */ + public var address: String + /** + * The derivation path used to generate the address + */ + public var path: String + /** + * The hexadecimal representation of the public key + */ + public var publicKey: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(vendor: String, majorVersion: UInt32, minorVersion: UInt32, patchVersion: UInt32, deviceId: String, capabilities: [String]?) { - self.vendor = vendor - self.majorVersion = majorVersion - self.minorVersion = minorVersion - self.patchVersion = patchVersion - self.deviceId = deviceId - self.capabilities = capabilities + public init( + /** + * The generated Bitcoin address as a string + */address: String, + /** + * The derivation path used to generate the address + */path: String, + /** + * The hexadecimal representation of the public key + */publicKey: String) { + self.address = address + self.path = path + self.publicKey = publicKey } } #if compiler(>=6) -extension FeatureResponse: Sendable {} +extension GetAddressResponse: Sendable {} #endif -extension FeatureResponse: Equatable, Hashable { - public static func ==(lhs: FeatureResponse, rhs: FeatureResponse) -> Bool { - if lhs.vendor != rhs.vendor { - return false - } - if lhs.majorVersion != rhs.majorVersion { - return false - } - if lhs.minorVersion != rhs.minorVersion { - return false - } - if lhs.patchVersion != rhs.patchVersion { +extension GetAddressResponse: Equatable, Hashable { + public static func ==(lhs: GetAddressResponse, rhs: GetAddressResponse) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.deviceId != rhs.deviceId { + if lhs.path != rhs.path { return false } - if lhs.capabilities != rhs.capabilities { + if lhs.publicKey != rhs.publicKey { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(vendor) - hasher.combine(majorVersion) - hasher.combine(minorVersion) - hasher.combine(patchVersion) - hasher.combine(deviceId) - hasher.combine(capabilities) + hasher.combine(address) + hasher.combine(path) + hasher.combine(publicKey) } } -extension FeatureResponse: Codable {} +extension GetAddressResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeFeatureResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FeatureResponse { +public struct FfiConverterTypeGetAddressResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GetAddressResponse { return - try FeatureResponse( - vendor: FfiConverterString.read(from: &buf), - majorVersion: FfiConverterUInt32.read(from: &buf), - minorVersion: FfiConverterUInt32.read(from: &buf), - patchVersion: FfiConverterUInt32.read(from: &buf), - deviceId: FfiConverterString.read(from: &buf), - capabilities: FfiConverterOptionSequenceString.read(from: &buf) + try GetAddressResponse( + address: FfiConverterString.read(from: &buf), + path: FfiConverterString.read(from: &buf), + publicKey: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: FeatureResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.vendor, into: &buf) - FfiConverterUInt32.write(value.majorVersion, into: &buf) - FfiConverterUInt32.write(value.minorVersion, into: &buf) - FfiConverterUInt32.write(value.patchVersion, into: &buf) - FfiConverterString.write(value.deviceId, into: &buf) - FfiConverterOptionSequenceString.write(value.capabilities, into: &buf) + public static func write(_ value: GetAddressResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterString.write(value.path, into: &buf) + FfiConverterString.write(value.publicKey, into: &buf) } } @@ -2510,100 +2586,69 @@ public struct FfiConverterTypeFeatureResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFeatureResponse_lift(_ buf: RustBuffer) throws -> FeatureResponse { - return try FfiConverterTypeFeatureResponse.lift(buf) +public func FfiConverterTypeGetAddressResponse_lift(_ buf: RustBuffer) throws -> GetAddressResponse { + return try FfiConverterTypeGetAddressResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFeatureResponse_lower(_ value: FeatureResponse) -> RustBuffer { - return FfiConverterTypeFeatureResponse.lower(value) +public func FfiConverterTypeGetAddressResponse_lower(_ value: GetAddressResponse) -> RustBuffer { + return FfiConverterTypeGetAddressResponse.lower(value) } -/** - * Fee level for compose transaction - */ -public struct FeeLevel { - /** - * Fee per unit (satoshi/byte or satoshi/vbyte) - */ - public var feePerUnit: String - /** - * Base fee in satoshi (optional, used in RBF and DOGE) - */ - public var baseFee: UInt32? +public struct GetAddressesResponse { /** - * Floor base fee (optional, used in DOGE) + * Vector of generated Bitcoin addresses */ - public var floorBaseFee: Bool? + public var addresses: [GetAddressResponse] // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Fee per unit (satoshi/byte or satoshi/vbyte) - */feePerUnit: String, - /** - * Base fee in satoshi (optional, used in RBF and DOGE) - */baseFee: UInt32?, - /** - * Floor base fee (optional, used in DOGE) - */floorBaseFee: Bool?) { - self.feePerUnit = feePerUnit - self.baseFee = baseFee - self.floorBaseFee = floorBaseFee + * Vector of generated Bitcoin addresses + */addresses: [GetAddressResponse]) { + self.addresses = addresses } } #if compiler(>=6) -extension FeeLevel: Sendable {} +extension GetAddressesResponse: Sendable {} #endif -extension FeeLevel: Equatable, Hashable { - public static func ==(lhs: FeeLevel, rhs: FeeLevel) -> Bool { - if lhs.feePerUnit != rhs.feePerUnit { - return false - } - if lhs.baseFee != rhs.baseFee { - return false - } - if lhs.floorBaseFee != rhs.floorBaseFee { +extension GetAddressesResponse: Equatable, Hashable { + public static func ==(lhs: GetAddressesResponse, rhs: GetAddressesResponse) -> Bool { + if lhs.addresses != rhs.addresses { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(feePerUnit) - hasher.combine(baseFee) - hasher.combine(floorBaseFee) + hasher.combine(addresses) } } -extension FeeLevel: Codable {} +extension GetAddressesResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeFeeLevel: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FeeLevel { +public struct FfiConverterTypeGetAddressesResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GetAddressesResponse { return - try FeeLevel( - feePerUnit: FfiConverterString.read(from: &buf), - baseFee: FfiConverterOptionUInt32.read(from: &buf), - floorBaseFee: FfiConverterOptionBool.read(from: &buf) + try GetAddressesResponse( + addresses: FfiConverterSequenceTypeGetAddressResponse.read(from: &buf) ) } - public static func write(_ value: FeeLevel, into buf: inout [UInt8]) { - FfiConverterString.write(value.feePerUnit, into: &buf) - FfiConverterOptionUInt32.write(value.baseFee, into: &buf) - FfiConverterOptionBool.write(value.floorBaseFee, into: &buf) + public static func write(_ value: GetAddressesResponse, into buf: inout [UInt8]) { + FfiConverterSequenceTypeGetAddressResponse.write(value.addresses, into: &buf) } } @@ -2611,79 +2656,71 @@ public struct FfiConverterTypeFeeLevel: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFeeLevel_lift(_ buf: RustBuffer) throws -> FeeLevel { - return try FfiConverterTypeFeeLevel.lift(buf) -} +public func FfiConverterTypeGetAddressesResponse_lift(_ buf: RustBuffer) throws -> GetAddressesResponse { + return try FfiConverterTypeGetAddressesResponse.lift(buf) +} #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFeeLevel_lower(_ value: FeeLevel) -> RustBuffer { - return FfiConverterTypeFeeLevel.lower(value) +public func FfiConverterTypeGetAddressesResponse_lower(_ value: GetAddressesResponse) -> RustBuffer { + return FfiConverterTypeGetAddressesResponse.lower(value) } -public struct FeeRates { - public var fast: UInt32 - public var mid: UInt32 - public var slow: UInt32 +public struct IBt0ConfMinTxFeeWindow { + public var satPerVbyte: Double + public var validityEndsAt: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(fast: UInt32, mid: UInt32, slow: UInt32) { - self.fast = fast - self.mid = mid - self.slow = slow + public init(satPerVbyte: Double, validityEndsAt: String) { + self.satPerVbyte = satPerVbyte + self.validityEndsAt = validityEndsAt } } #if compiler(>=6) -extension FeeRates: Sendable {} +extension IBt0ConfMinTxFeeWindow: Sendable {} #endif -extension FeeRates: Equatable, Hashable { - public static func ==(lhs: FeeRates, rhs: FeeRates) -> Bool { - if lhs.fast != rhs.fast { - return false - } - if lhs.mid != rhs.mid { +extension IBt0ConfMinTxFeeWindow: Equatable, Hashable { + public static func ==(lhs: IBt0ConfMinTxFeeWindow, rhs: IBt0ConfMinTxFeeWindow) -> Bool { + if lhs.satPerVbyte != rhs.satPerVbyte { return false } - if lhs.slow != rhs.slow { + if lhs.validityEndsAt != rhs.validityEndsAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(fast) - hasher.combine(mid) - hasher.combine(slow) + hasher.combine(satPerVbyte) + hasher.combine(validityEndsAt) } } -extension FeeRates: Codable {} +extension IBt0ConfMinTxFeeWindow: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeFeeRates: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FeeRates { +public struct FfiConverterTypeIBt0ConfMinTxFeeWindow: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBt0ConfMinTxFeeWindow { return - try FeeRates( - fast: FfiConverterUInt32.read(from: &buf), - mid: FfiConverterUInt32.read(from: &buf), - slow: FfiConverterUInt32.read(from: &buf) + try IBt0ConfMinTxFeeWindow( + satPerVbyte: FfiConverterDouble.read(from: &buf), + validityEndsAt: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: FeeRates, into buf: inout [UInt8]) { - FfiConverterUInt32.write(value.fast, into: &buf) - FfiConverterUInt32.write(value.mid, into: &buf) - FfiConverterUInt32.write(value.slow, into: &buf) + public static func write(_ value: IBt0ConfMinTxFeeWindow, into buf: inout [UInt8]) { + FfiConverterDouble.write(value.satPerVbyte, into: &buf) + FfiConverterString.write(value.validityEndsAt, into: &buf) } } @@ -2691,71 +2728,87 @@ public struct FfiConverterTypeFeeRates: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFeeRates_lift(_ buf: RustBuffer) throws -> FeeRates { - return try FfiConverterTypeFeeRates.lift(buf) +public func FfiConverterTypeIBt0ConfMinTxFeeWindow_lift(_ buf: RustBuffer) throws -> IBt0ConfMinTxFeeWindow { + return try FfiConverterTypeIBt0ConfMinTxFeeWindow.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFeeRates_lower(_ value: FeeRates) -> RustBuffer { - return FfiConverterTypeFeeRates.lower(value) +public func FfiConverterTypeIBt0ConfMinTxFeeWindow_lower(_ value: IBt0ConfMinTxFeeWindow) -> RustBuffer { + return FfiConverterTypeIBt0ConfMinTxFeeWindow.lower(value) } -public struct FundingTx { - public var id: String - public var vout: UInt64 +public struct IBtBolt11Invoice { + public var request: String + public var state: BtBolt11InvoiceState + public var expiresAt: String + public var updatedAt: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, vout: UInt64) { - self.id = id - self.vout = vout + public init(request: String, state: BtBolt11InvoiceState, expiresAt: String, updatedAt: String) { + self.request = request + self.state = state + self.expiresAt = expiresAt + self.updatedAt = updatedAt } } #if compiler(>=6) -extension FundingTx: Sendable {} +extension IBtBolt11Invoice: Sendable {} #endif -extension FundingTx: Equatable, Hashable { - public static func ==(lhs: FundingTx, rhs: FundingTx) -> Bool { - if lhs.id != rhs.id { +extension IBtBolt11Invoice: Equatable, Hashable { + public static func ==(lhs: IBtBolt11Invoice, rhs: IBtBolt11Invoice) -> Bool { + if lhs.request != rhs.request { return false } - if lhs.vout != rhs.vout { + if lhs.state != rhs.state { + return false + } + if lhs.expiresAt != rhs.expiresAt { + return false + } + if lhs.updatedAt != rhs.updatedAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(vout) + hasher.combine(request) + hasher.combine(state) + hasher.combine(expiresAt) + hasher.combine(updatedAt) } } -extension FundingTx: Codable {} +extension IBtBolt11Invoice: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeFundingTx: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FundingTx { +public struct FfiConverterTypeIBtBolt11Invoice: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtBolt11Invoice { return - try FundingTx( - id: FfiConverterString.read(from: &buf), - vout: FfiConverterUInt64.read(from: &buf) + try IBtBolt11Invoice( + request: FfiConverterString.read(from: &buf), + state: FfiConverterTypeBtBolt11InvoiceState.read(from: &buf), + expiresAt: FfiConverterString.read(from: &buf), + updatedAt: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: FundingTx, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterUInt64.write(value.vout, into: &buf) + public static func write(_ value: IBtBolt11Invoice, into buf: inout [UInt8]) { + FfiConverterString.write(value.request, into: &buf) + FfiConverterTypeBtBolt11InvoiceState.write(value.state, into: &buf) + FfiConverterString.write(value.expiresAt, into: &buf) + FfiConverterString.write(value.updatedAt, into: &buf) } } @@ -2763,97 +2816,119 @@ public struct FfiConverterTypeFundingTx: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFundingTx_lift(_ buf: RustBuffer) throws -> FundingTx { - return try FfiConverterTypeFundingTx.lift(buf) +public func FfiConverterTypeIBtBolt11Invoice_lift(_ buf: RustBuffer) throws -> IBtBolt11Invoice { + return try FfiConverterTypeIBtBolt11Invoice.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeFundingTx_lower(_ value: FundingTx) -> RustBuffer { - return FfiConverterTypeFundingTx.lower(value) +public func FfiConverterTypeIBtBolt11Invoice_lower(_ value: IBtBolt11Invoice) -> RustBuffer { + return FfiConverterTypeIBtBolt11Invoice.lower(value) } -public struct GetAddressResponse { - /** - * The generated Bitcoin address as a string - */ - public var address: String - /** - * The derivation path used to generate the address - */ - public var path: String - /** - * The hexadecimal representation of the public key - */ - public var publicKey: String +public struct IBtChannel { + public var state: BtOpenChannelState + public var lspNodePubkey: String + public var clientNodePubkey: String + public var announceChannel: Bool + public var fundingTx: FundingTx + public var closingTxId: String? + public var close: IBtChannelClose? + public var shortChannelId: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * The generated Bitcoin address as a string - */address: String, - /** - * The derivation path used to generate the address - */path: String, - /** - * The hexadecimal representation of the public key - */publicKey: String) { - self.address = address - self.path = path - self.publicKey = publicKey + public init(state: BtOpenChannelState, lspNodePubkey: String, clientNodePubkey: String, announceChannel: Bool, fundingTx: FundingTx, closingTxId: String?, close: IBtChannelClose?, shortChannelId: String?) { + self.state = state + self.lspNodePubkey = lspNodePubkey + self.clientNodePubkey = clientNodePubkey + self.announceChannel = announceChannel + self.fundingTx = fundingTx + self.closingTxId = closingTxId + self.close = close + self.shortChannelId = shortChannelId } } #if compiler(>=6) -extension GetAddressResponse: Sendable {} +extension IBtChannel: Sendable {} #endif -extension GetAddressResponse: Equatable, Hashable { - public static func ==(lhs: GetAddressResponse, rhs: GetAddressResponse) -> Bool { - if lhs.address != rhs.address { +extension IBtChannel: Equatable, Hashable { + public static func ==(lhs: IBtChannel, rhs: IBtChannel) -> Bool { + if lhs.state != rhs.state { return false } - if lhs.path != rhs.path { + if lhs.lspNodePubkey != rhs.lspNodePubkey { return false } - if lhs.publicKey != rhs.publicKey { + if lhs.clientNodePubkey != rhs.clientNodePubkey { + return false + } + if lhs.announceChannel != rhs.announceChannel { + return false + } + if lhs.fundingTx != rhs.fundingTx { + return false + } + if lhs.closingTxId != rhs.closingTxId { + return false + } + if lhs.close != rhs.close { + return false + } + if lhs.shortChannelId != rhs.shortChannelId { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(path) - hasher.combine(publicKey) + hasher.combine(state) + hasher.combine(lspNodePubkey) + hasher.combine(clientNodePubkey) + hasher.combine(announceChannel) + hasher.combine(fundingTx) + hasher.combine(closingTxId) + hasher.combine(close) + hasher.combine(shortChannelId) } } -extension GetAddressResponse: Codable {} +extension IBtChannel: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeGetAddressResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GetAddressResponse { +public struct FfiConverterTypeIBtChannel: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtChannel { return - try GetAddressResponse( - address: FfiConverterString.read(from: &buf), - path: FfiConverterString.read(from: &buf), - publicKey: FfiConverterString.read(from: &buf) + try IBtChannel( + state: FfiConverterTypeBtOpenChannelState.read(from: &buf), + lspNodePubkey: FfiConverterString.read(from: &buf), + clientNodePubkey: FfiConverterString.read(from: &buf), + announceChannel: FfiConverterBool.read(from: &buf), + fundingTx: FfiConverterTypeFundingTx.read(from: &buf), + closingTxId: FfiConverterOptionString.read(from: &buf), + close: FfiConverterOptionTypeIBtChannelClose.read(from: &buf), + shortChannelId: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: GetAddressResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.path, into: &buf) - FfiConverterString.write(value.publicKey, into: &buf) + public static func write(_ value: IBtChannel, into buf: inout [UInt8]) { + FfiConverterTypeBtOpenChannelState.write(value.state, into: &buf) + FfiConverterString.write(value.lspNodePubkey, into: &buf) + FfiConverterString.write(value.clientNodePubkey, into: &buf) + FfiConverterBool.write(value.announceChannel, into: &buf) + FfiConverterTypeFundingTx.write(value.fundingTx, into: &buf) + FfiConverterOptionString.write(value.closingTxId, into: &buf) + FfiConverterOptionTypeIBtChannelClose.write(value.close, into: &buf) + FfiConverterOptionString.write(value.shortChannelId, into: &buf) } } @@ -2861,69 +2936,87 @@ public struct FfiConverterTypeGetAddressResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeGetAddressResponse_lift(_ buf: RustBuffer) throws -> GetAddressResponse { - return try FfiConverterTypeGetAddressResponse.lift(buf) +public func FfiConverterTypeIBtChannel_lift(_ buf: RustBuffer) throws -> IBtChannel { + return try FfiConverterTypeIBtChannel.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeGetAddressResponse_lower(_ value: GetAddressResponse) -> RustBuffer { - return FfiConverterTypeGetAddressResponse.lower(value) +public func FfiConverterTypeIBtChannel_lower(_ value: IBtChannel) -> RustBuffer { + return FfiConverterTypeIBtChannel.lower(value) } -public struct GetAddressesResponse { - /** - * Vector of generated Bitcoin addresses - */ - public var addresses: [GetAddressResponse] +public struct IBtChannelClose { + public var txId: String + public var closeType: String + public var initiator: String + public var registeredAt: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Vector of generated Bitcoin addresses - */addresses: [GetAddressResponse]) { - self.addresses = addresses + public init(txId: String, closeType: String, initiator: String, registeredAt: String) { + self.txId = txId + self.closeType = closeType + self.initiator = initiator + self.registeredAt = registeredAt } } #if compiler(>=6) -extension GetAddressesResponse: Sendable {} +extension IBtChannelClose: Sendable {} #endif -extension GetAddressesResponse: Equatable, Hashable { - public static func ==(lhs: GetAddressesResponse, rhs: GetAddressesResponse) -> Bool { - if lhs.addresses != rhs.addresses { +extension IBtChannelClose: Equatable, Hashable { + public static func ==(lhs: IBtChannelClose, rhs: IBtChannelClose) -> Bool { + if lhs.txId != rhs.txId { + return false + } + if lhs.closeType != rhs.closeType { + return false + } + if lhs.initiator != rhs.initiator { + return false + } + if lhs.registeredAt != rhs.registeredAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(addresses) + hasher.combine(txId) + hasher.combine(closeType) + hasher.combine(initiator) + hasher.combine(registeredAt) } } -extension GetAddressesResponse: Codable {} +extension IBtChannelClose: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeGetAddressesResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GetAddressesResponse { +public struct FfiConverterTypeIBtChannelClose: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtChannelClose { return - try GetAddressesResponse( - addresses: FfiConverterSequenceTypeGetAddressResponse.read(from: &buf) + try IBtChannelClose( + txId: FfiConverterString.read(from: &buf), + closeType: FfiConverterString.read(from: &buf), + initiator: FfiConverterString.read(from: &buf), + registeredAt: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: GetAddressesResponse, into buf: inout [UInt8]) { - FfiConverterSequenceTypeGetAddressResponse.write(value.addresses, into: &buf) + public static func write(_ value: IBtChannelClose, into buf: inout [UInt8]) { + FfiConverterString.write(value.txId, into: &buf) + FfiConverterString.write(value.closeType, into: &buf) + FfiConverterString.write(value.initiator, into: &buf) + FfiConverterString.write(value.registeredAt, into: &buf) } } @@ -2931,86 +3024,71 @@ public struct FfiConverterTypeGetAddressesResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeGetAddressesResponse_lift(_ buf: RustBuffer) throws -> GetAddressesResponse { - return try FfiConverterTypeGetAddressesResponse.lift(buf) +public func FfiConverterTypeIBtChannelClose_lift(_ buf: RustBuffer) throws -> IBtChannelClose { + return try FfiConverterTypeIBtChannelClose.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeGetAddressesResponse_lower(_ value: GetAddressesResponse) -> RustBuffer { - return FfiConverterTypeGetAddressesResponse.lower(value) +public func FfiConverterTypeIBtChannelClose_lower(_ value: IBtChannelClose) -> RustBuffer { + return FfiConverterTypeIBtChannelClose.lower(value) } -/** - * HD Node Path Type - */ -public struct HdNodePathType { - /** - * Node data (can be String or HDNodeType) - */ - public var node: HdNodeTypeOrString - /** - * BIP32 derivation path - */ - public var addressN: [UInt32] +public struct IBtEstimateFeeResponse { + public var feeSat: UInt64 + public var min0ConfTxFee: IBt0ConfMinTxFeeWindow // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Node data (can be String or HDNodeType) - */node: HdNodeTypeOrString, - /** - * BIP32 derivation path - */addressN: [UInt32]) { - self.node = node - self.addressN = addressN + public init(feeSat: UInt64, min0ConfTxFee: IBt0ConfMinTxFeeWindow) { + self.feeSat = feeSat + self.min0ConfTxFee = min0ConfTxFee } } #if compiler(>=6) -extension HdNodePathType: Sendable {} +extension IBtEstimateFeeResponse: Sendable {} #endif -extension HdNodePathType: Equatable, Hashable { - public static func ==(lhs: HdNodePathType, rhs: HdNodePathType) -> Bool { - if lhs.node != rhs.node { +extension IBtEstimateFeeResponse: Equatable, Hashable { + public static func ==(lhs: IBtEstimateFeeResponse, rhs: IBtEstimateFeeResponse) -> Bool { + if lhs.feeSat != rhs.feeSat { return false } - if lhs.addressN != rhs.addressN { + if lhs.min0ConfTxFee != rhs.min0ConfTxFee { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(node) - hasher.combine(addressN) + hasher.combine(feeSat) + hasher.combine(min0ConfTxFee) } } -extension HdNodePathType: Codable {} +extension IBtEstimateFeeResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeHDNodePathType: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HdNodePathType { +public struct FfiConverterTypeIBtEstimateFeeResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtEstimateFeeResponse { return - try HdNodePathType( - node: FfiConverterTypeHDNodeTypeOrString.read(from: &buf), - addressN: FfiConverterSequenceUInt32.read(from: &buf) + try IBtEstimateFeeResponse( + feeSat: FfiConverterUInt64.read(from: &buf), + min0ConfTxFee: FfiConverterTypeIBt0ConfMinTxFeeWindow.read(from: &buf) ) } - public static func write(_ value: HdNodePathType, into buf: inout [UInt8]) { - FfiConverterTypeHDNodeTypeOrString.write(value.node, into: &buf) - FfiConverterSequenceUInt32.write(value.addressN, into: &buf) + public static func write(_ value: IBtEstimateFeeResponse, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.feeSat, into: &buf) + FfiConverterTypeIBt0ConfMinTxFeeWindow.write(value.min0ConfTxFee, into: &buf) } } @@ -3018,156 +3096,87 @@ public struct FfiConverterTypeHDNodePathType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHDNodePathType_lift(_ buf: RustBuffer) throws -> HdNodePathType { - return try FfiConverterTypeHDNodePathType.lift(buf) +public func FfiConverterTypeIBtEstimateFeeResponse_lift(_ buf: RustBuffer) throws -> IBtEstimateFeeResponse { + return try FfiConverterTypeIBtEstimateFeeResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHDNodePathType_lower(_ value: HdNodePathType) -> RustBuffer { - return FfiConverterTypeHDNodePathType.lower(value) +public func FfiConverterTypeIBtEstimateFeeResponse_lower(_ value: IBtEstimateFeeResponse) -> RustBuffer { + return FfiConverterTypeIBtEstimateFeeResponse.lower(value) } -/** - * HD Node Type - */ -public struct HdNodeType { - /** - * Depth - */ - public var depth: UInt32 - /** - * Fingerprint - */ - public var fingerprint: UInt32 - /** - * Child number - */ - public var childNum: UInt32 - /** - * Chain code - */ - public var chainCode: String - /** - * Public key - */ - public var publicKey: String - /** - * Private key (optional) - */ - public var privateKey: String? - /** - * BIP32 derivation path (optional) - */ - public var addressN: [UInt32]? +public struct IBtEstimateFeeResponse2 { + public var feeSat: UInt64 + public var networkFeeSat: UInt64 + public var serviceFeeSat: UInt64 + public var min0ConfTxFee: IBt0ConfMinTxFeeWindow // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Depth - */depth: UInt32, - /** - * Fingerprint - */fingerprint: UInt32, - /** - * Child number - */childNum: UInt32, - /** - * Chain code - */chainCode: String, - /** - * Public key - */publicKey: String, - /** - * Private key (optional) - */privateKey: String?, - /** - * BIP32 derivation path (optional) - */addressN: [UInt32]?) { - self.depth = depth - self.fingerprint = fingerprint - self.childNum = childNum - self.chainCode = chainCode - self.publicKey = publicKey - self.privateKey = privateKey - self.addressN = addressN + public init(feeSat: UInt64, networkFeeSat: UInt64, serviceFeeSat: UInt64, min0ConfTxFee: IBt0ConfMinTxFeeWindow) { + self.feeSat = feeSat + self.networkFeeSat = networkFeeSat + self.serviceFeeSat = serviceFeeSat + self.min0ConfTxFee = min0ConfTxFee } } #if compiler(>=6) -extension HdNodeType: Sendable {} +extension IBtEstimateFeeResponse2: Sendable {} #endif -extension HdNodeType: Equatable, Hashable { - public static func ==(lhs: HdNodeType, rhs: HdNodeType) -> Bool { - if lhs.depth != rhs.depth { - return false - } - if lhs.fingerprint != rhs.fingerprint { - return false - } - if lhs.childNum != rhs.childNum { - return false - } - if lhs.chainCode != rhs.chainCode { +extension IBtEstimateFeeResponse2: Equatable, Hashable { + public static func ==(lhs: IBtEstimateFeeResponse2, rhs: IBtEstimateFeeResponse2) -> Bool { + if lhs.feeSat != rhs.feeSat { return false } - if lhs.publicKey != rhs.publicKey { + if lhs.networkFeeSat != rhs.networkFeeSat { return false } - if lhs.privateKey != rhs.privateKey { + if lhs.serviceFeeSat != rhs.serviceFeeSat { return false } - if lhs.addressN != rhs.addressN { + if lhs.min0ConfTxFee != rhs.min0ConfTxFee { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(depth) - hasher.combine(fingerprint) - hasher.combine(childNum) - hasher.combine(chainCode) - hasher.combine(publicKey) - hasher.combine(privateKey) - hasher.combine(addressN) + hasher.combine(feeSat) + hasher.combine(networkFeeSat) + hasher.combine(serviceFeeSat) + hasher.combine(min0ConfTxFee) } } -extension HdNodeType: Codable {} +extension IBtEstimateFeeResponse2: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeHDNodeType: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HdNodeType { +public struct FfiConverterTypeIBtEstimateFeeResponse2: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtEstimateFeeResponse2 { return - try HdNodeType( - depth: FfiConverterUInt32.read(from: &buf), - fingerprint: FfiConverterUInt32.read(from: &buf), - childNum: FfiConverterUInt32.read(from: &buf), - chainCode: FfiConverterString.read(from: &buf), - publicKey: FfiConverterString.read(from: &buf), - privateKey: FfiConverterOptionString.read(from: &buf), - addressN: FfiConverterOptionSequenceUInt32.read(from: &buf) + try IBtEstimateFeeResponse2( + feeSat: FfiConverterUInt64.read(from: &buf), + networkFeeSat: FfiConverterUInt64.read(from: &buf), + serviceFeeSat: FfiConverterUInt64.read(from: &buf), + min0ConfTxFee: FfiConverterTypeIBt0ConfMinTxFeeWindow.read(from: &buf) ) } - public static func write(_ value: HdNodeType, into buf: inout [UInt8]) { - FfiConverterUInt32.write(value.depth, into: &buf) - FfiConverterUInt32.write(value.fingerprint, into: &buf) - FfiConverterUInt32.write(value.childNum, into: &buf) - FfiConverterString.write(value.chainCode, into: &buf) - FfiConverterString.write(value.publicKey, into: &buf) - FfiConverterOptionString.write(value.privateKey, into: &buf) - FfiConverterOptionSequenceUInt32.write(value.addressN, into: &buf) + public static func write(_ value: IBtEstimateFeeResponse2, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.feeSat, into: &buf) + FfiConverterUInt64.write(value.networkFeeSat, into: &buf) + FfiConverterUInt64.write(value.serviceFeeSat, into: &buf) + FfiConverterTypeIBt0ConfMinTxFeeWindow.write(value.min0ConfTxFee, into: &buf) } } @@ -3175,71 +3184,95 @@ public struct FfiConverterTypeHDNodeType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHDNodeType_lift(_ buf: RustBuffer) throws -> HdNodeType { - return try FfiConverterTypeHDNodeType.lift(buf) +public func FfiConverterTypeIBtEstimateFeeResponse2_lift(_ buf: RustBuffer) throws -> IBtEstimateFeeResponse2 { + return try FfiConverterTypeIBtEstimateFeeResponse2.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHDNodeType_lower(_ value: HdNodeType) -> RustBuffer { - return FfiConverterTypeHDNodeType.lower(value) +public func FfiConverterTypeIBtEstimateFeeResponse2_lower(_ value: IBtEstimateFeeResponse2) -> RustBuffer { + return FfiConverterTypeIBtEstimateFeeResponse2.lower(value) } -public struct IBt0ConfMinTxFeeWindow { - public var satPerVbyte: Double - public var validityEndsAt: String +public struct IBtInfo { + public var version: UInt32 + public var nodes: [ILspNode] + public var options: IBtInfoOptions + public var versions: IBtInfoVersions + public var onchain: IBtInfoOnchain // Default memberwise initializers are never public by default, so we // declare one manually. - public init(satPerVbyte: Double, validityEndsAt: String) { - self.satPerVbyte = satPerVbyte - self.validityEndsAt = validityEndsAt + public init(version: UInt32, nodes: [ILspNode], options: IBtInfoOptions, versions: IBtInfoVersions, onchain: IBtInfoOnchain) { + self.version = version + self.nodes = nodes + self.options = options + self.versions = versions + self.onchain = onchain } } #if compiler(>=6) -extension IBt0ConfMinTxFeeWindow: Sendable {} +extension IBtInfo: Sendable {} #endif -extension IBt0ConfMinTxFeeWindow: Equatable, Hashable { - public static func ==(lhs: IBt0ConfMinTxFeeWindow, rhs: IBt0ConfMinTxFeeWindow) -> Bool { - if lhs.satPerVbyte != rhs.satPerVbyte { +extension IBtInfo: Equatable, Hashable { + public static func ==(lhs: IBtInfo, rhs: IBtInfo) -> Bool { + if lhs.version != rhs.version { return false } - if lhs.validityEndsAt != rhs.validityEndsAt { + if lhs.nodes != rhs.nodes { + return false + } + if lhs.options != rhs.options { + return false + } + if lhs.versions != rhs.versions { + return false + } + if lhs.onchain != rhs.onchain { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(satPerVbyte) - hasher.combine(validityEndsAt) + hasher.combine(version) + hasher.combine(nodes) + hasher.combine(options) + hasher.combine(versions) + hasher.combine(onchain) } } -extension IBt0ConfMinTxFeeWindow: Codable {} +extension IBtInfo: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBt0ConfMinTxFeeWindow: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBt0ConfMinTxFeeWindow { +public struct FfiConverterTypeIBtInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfo { return - try IBt0ConfMinTxFeeWindow( - satPerVbyte: FfiConverterDouble.read(from: &buf), - validityEndsAt: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: IBt0ConfMinTxFeeWindow, into buf: inout [UInt8]) { - FfiConverterDouble.write(value.satPerVbyte, into: &buf) - FfiConverterString.write(value.validityEndsAt, into: &buf) + try IBtInfo( + version: FfiConverterUInt32.read(from: &buf), + nodes: FfiConverterSequenceTypeILspNode.read(from: &buf), + options: FfiConverterTypeIBtInfoOptions.read(from: &buf), + versions: FfiConverterTypeIBtInfoVersions.read(from: &buf), + onchain: FfiConverterTypeIBtInfoOnchain.read(from: &buf) + ) + } + + public static func write(_ value: IBtInfo, into buf: inout [UInt8]) { + FfiConverterUInt32.write(value.version, into: &buf) + FfiConverterSequenceTypeILspNode.write(value.nodes, into: &buf) + FfiConverterTypeIBtInfoOptions.write(value.options, into: &buf) + FfiConverterTypeIBtInfoVersions.write(value.versions, into: &buf) + FfiConverterTypeIBtInfoOnchain.write(value.onchain, into: &buf) } } @@ -3247,87 +3280,71 @@ public struct FfiConverterTypeIBt0ConfMinTxFeeWindow: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBt0ConfMinTxFeeWindow_lift(_ buf: RustBuffer) throws -> IBt0ConfMinTxFeeWindow { - return try FfiConverterTypeIBt0ConfMinTxFeeWindow.lift(buf) +public func FfiConverterTypeIBtInfo_lift(_ buf: RustBuffer) throws -> IBtInfo { + return try FfiConverterTypeIBtInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBt0ConfMinTxFeeWindow_lower(_ value: IBt0ConfMinTxFeeWindow) -> RustBuffer { - return FfiConverterTypeIBt0ConfMinTxFeeWindow.lower(value) +public func FfiConverterTypeIBtInfo_lower(_ value: IBtInfo) -> RustBuffer { + return FfiConverterTypeIBtInfo.lower(value) } -public struct IBtBolt11Invoice { - public var request: String - public var state: BtBolt11InvoiceState - public var expiresAt: String - public var updatedAt: String +public struct IBtInfoOnchain { + public var network: BitcoinNetworkEnum + public var feeRates: FeeRates // Default memberwise initializers are never public by default, so we // declare one manually. - public init(request: String, state: BtBolt11InvoiceState, expiresAt: String, updatedAt: String) { - self.request = request - self.state = state - self.expiresAt = expiresAt - self.updatedAt = updatedAt + public init(network: BitcoinNetworkEnum, feeRates: FeeRates) { + self.network = network + self.feeRates = feeRates } } #if compiler(>=6) -extension IBtBolt11Invoice: Sendable {} +extension IBtInfoOnchain: Sendable {} #endif -extension IBtBolt11Invoice: Equatable, Hashable { - public static func ==(lhs: IBtBolt11Invoice, rhs: IBtBolt11Invoice) -> Bool { - if lhs.request != rhs.request { - return false - } - if lhs.state != rhs.state { - return false - } - if lhs.expiresAt != rhs.expiresAt { +extension IBtInfoOnchain: Equatable, Hashable { + public static func ==(lhs: IBtInfoOnchain, rhs: IBtInfoOnchain) -> Bool { + if lhs.network != rhs.network { return false } - if lhs.updatedAt != rhs.updatedAt { + if lhs.feeRates != rhs.feeRates { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(request) - hasher.combine(state) - hasher.combine(expiresAt) - hasher.combine(updatedAt) + hasher.combine(network) + hasher.combine(feeRates) } } -extension IBtBolt11Invoice: Codable {} +extension IBtInfoOnchain: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtBolt11Invoice: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtBolt11Invoice { +public struct FfiConverterTypeIBtInfoOnchain: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfoOnchain { return - try IBtBolt11Invoice( - request: FfiConverterString.read(from: &buf), - state: FfiConverterTypeBtBolt11InvoiceState.read(from: &buf), - expiresAt: FfiConverterString.read(from: &buf), - updatedAt: FfiConverterString.read(from: &buf) + try IBtInfoOnchain( + network: FfiConverterTypeBitcoinNetworkEnum.read(from: &buf), + feeRates: FfiConverterTypeFeeRates.read(from: &buf) ) } - public static func write(_ value: IBtBolt11Invoice, into buf: inout [UInt8]) { - FfiConverterString.write(value.request, into: &buf) - FfiConverterTypeBtBolt11InvoiceState.write(value.state, into: &buf) - FfiConverterString.write(value.expiresAt, into: &buf) - FfiConverterString.write(value.updatedAt, into: &buf) + public static func write(_ value: IBtInfoOnchain, into buf: inout [UInt8]) { + FfiConverterTypeBitcoinNetworkEnum.write(value.network, into: &buf) + FfiConverterTypeFeeRates.write(value.feeRates, into: &buf) } } @@ -3335,119 +3352,119 @@ public struct FfiConverterTypeIBtBolt11Invoice: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtBolt11Invoice_lift(_ buf: RustBuffer) throws -> IBtBolt11Invoice { - return try FfiConverterTypeIBtBolt11Invoice.lift(buf) +public func FfiConverterTypeIBtInfoOnchain_lift(_ buf: RustBuffer) throws -> IBtInfoOnchain { + return try FfiConverterTypeIBtInfoOnchain.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtBolt11Invoice_lower(_ value: IBtBolt11Invoice) -> RustBuffer { - return FfiConverterTypeIBtBolt11Invoice.lower(value) +public func FfiConverterTypeIBtInfoOnchain_lower(_ value: IBtInfoOnchain) -> RustBuffer { + return FfiConverterTypeIBtInfoOnchain.lower(value) } -public struct IBtChannel { - public var state: BtOpenChannelState - public var lspNodePubkey: String - public var clientNodePubkey: String - public var announceChannel: Bool - public var fundingTx: FundingTx - public var closingTxId: String? - public var close: IBtChannelClose? - public var shortChannelId: String? +public struct IBtInfoOptions { + public var minChannelSizeSat: UInt64 + public var maxChannelSizeSat: UInt64 + public var minExpiryWeeks: UInt32 + public var maxExpiryWeeks: UInt32 + public var minPaymentConfirmations: UInt32 + public var minHighRiskPaymentConfirmations: UInt32 + public var max0ConfClientBalanceSat: UInt64 + public var maxClientBalanceSat: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(state: BtOpenChannelState, lspNodePubkey: String, clientNodePubkey: String, announceChannel: Bool, fundingTx: FundingTx, closingTxId: String?, close: IBtChannelClose?, shortChannelId: String?) { - self.state = state - self.lspNodePubkey = lspNodePubkey - self.clientNodePubkey = clientNodePubkey - self.announceChannel = announceChannel - self.fundingTx = fundingTx - self.closingTxId = closingTxId - self.close = close - self.shortChannelId = shortChannelId + public init(minChannelSizeSat: UInt64, maxChannelSizeSat: UInt64, minExpiryWeeks: UInt32, maxExpiryWeeks: UInt32, minPaymentConfirmations: UInt32, minHighRiskPaymentConfirmations: UInt32, max0ConfClientBalanceSat: UInt64, maxClientBalanceSat: UInt64) { + self.minChannelSizeSat = minChannelSizeSat + self.maxChannelSizeSat = maxChannelSizeSat + self.minExpiryWeeks = minExpiryWeeks + self.maxExpiryWeeks = maxExpiryWeeks + self.minPaymentConfirmations = minPaymentConfirmations + self.minHighRiskPaymentConfirmations = minHighRiskPaymentConfirmations + self.max0ConfClientBalanceSat = max0ConfClientBalanceSat + self.maxClientBalanceSat = maxClientBalanceSat } } #if compiler(>=6) -extension IBtChannel: Sendable {} +extension IBtInfoOptions: Sendable {} #endif -extension IBtChannel: Equatable, Hashable { - public static func ==(lhs: IBtChannel, rhs: IBtChannel) -> Bool { - if lhs.state != rhs.state { +extension IBtInfoOptions: Equatable, Hashable { + public static func ==(lhs: IBtInfoOptions, rhs: IBtInfoOptions) -> Bool { + if lhs.minChannelSizeSat != rhs.minChannelSizeSat { return false } - if lhs.lspNodePubkey != rhs.lspNodePubkey { + if lhs.maxChannelSizeSat != rhs.maxChannelSizeSat { return false } - if lhs.clientNodePubkey != rhs.clientNodePubkey { + if lhs.minExpiryWeeks != rhs.minExpiryWeeks { return false } - if lhs.announceChannel != rhs.announceChannel { + if lhs.maxExpiryWeeks != rhs.maxExpiryWeeks { return false } - if lhs.fundingTx != rhs.fundingTx { + if lhs.minPaymentConfirmations != rhs.minPaymentConfirmations { return false } - if lhs.closingTxId != rhs.closingTxId { + if lhs.minHighRiskPaymentConfirmations != rhs.minHighRiskPaymentConfirmations { return false } - if lhs.close != rhs.close { + if lhs.max0ConfClientBalanceSat != rhs.max0ConfClientBalanceSat { return false } - if lhs.shortChannelId != rhs.shortChannelId { + if lhs.maxClientBalanceSat != rhs.maxClientBalanceSat { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(state) - hasher.combine(lspNodePubkey) - hasher.combine(clientNodePubkey) - hasher.combine(announceChannel) - hasher.combine(fundingTx) - hasher.combine(closingTxId) - hasher.combine(close) - hasher.combine(shortChannelId) + hasher.combine(minChannelSizeSat) + hasher.combine(maxChannelSizeSat) + hasher.combine(minExpiryWeeks) + hasher.combine(maxExpiryWeeks) + hasher.combine(minPaymentConfirmations) + hasher.combine(minHighRiskPaymentConfirmations) + hasher.combine(max0ConfClientBalanceSat) + hasher.combine(maxClientBalanceSat) } } -extension IBtChannel: Codable {} +extension IBtInfoOptions: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtChannel: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtChannel { +public struct FfiConverterTypeIBtInfoOptions: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfoOptions { return - try IBtChannel( - state: FfiConverterTypeBtOpenChannelState.read(from: &buf), - lspNodePubkey: FfiConverterString.read(from: &buf), - clientNodePubkey: FfiConverterString.read(from: &buf), - announceChannel: FfiConverterBool.read(from: &buf), - fundingTx: FfiConverterTypeFundingTx.read(from: &buf), - closingTxId: FfiConverterOptionString.read(from: &buf), - close: FfiConverterOptionTypeIBtChannelClose.read(from: &buf), - shortChannelId: FfiConverterOptionString.read(from: &buf) + try IBtInfoOptions( + minChannelSizeSat: FfiConverterUInt64.read(from: &buf), + maxChannelSizeSat: FfiConverterUInt64.read(from: &buf), + minExpiryWeeks: FfiConverterUInt32.read(from: &buf), + maxExpiryWeeks: FfiConverterUInt32.read(from: &buf), + minPaymentConfirmations: FfiConverterUInt32.read(from: &buf), + minHighRiskPaymentConfirmations: FfiConverterUInt32.read(from: &buf), + max0ConfClientBalanceSat: FfiConverterUInt64.read(from: &buf), + maxClientBalanceSat: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: IBtChannel, into buf: inout [UInt8]) { - FfiConverterTypeBtOpenChannelState.write(value.state, into: &buf) - FfiConverterString.write(value.lspNodePubkey, into: &buf) - FfiConverterString.write(value.clientNodePubkey, into: &buf) - FfiConverterBool.write(value.announceChannel, into: &buf) - FfiConverterTypeFundingTx.write(value.fundingTx, into: &buf) - FfiConverterOptionString.write(value.closingTxId, into: &buf) - FfiConverterOptionTypeIBtChannelClose.write(value.close, into: &buf) - FfiConverterOptionString.write(value.shortChannelId, into: &buf) + public static func write(_ value: IBtInfoOptions, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.minChannelSizeSat, into: &buf) + FfiConverterUInt64.write(value.maxChannelSizeSat, into: &buf) + FfiConverterUInt32.write(value.minExpiryWeeks, into: &buf) + FfiConverterUInt32.write(value.maxExpiryWeeks, into: &buf) + FfiConverterUInt32.write(value.minPaymentConfirmations, into: &buf) + FfiConverterUInt32.write(value.minHighRiskPaymentConfirmations, into: &buf) + FfiConverterUInt64.write(value.max0ConfClientBalanceSat, into: &buf) + FfiConverterUInt64.write(value.maxClientBalanceSat, into: &buf) } } @@ -3455,87 +3472,79 @@ public struct FfiConverterTypeIBtChannel: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtChannel_lift(_ buf: RustBuffer) throws -> IBtChannel { - return try FfiConverterTypeIBtChannel.lift(buf) +public func FfiConverterTypeIBtInfoOptions_lift(_ buf: RustBuffer) throws -> IBtInfoOptions { + return try FfiConverterTypeIBtInfoOptions.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtChannel_lower(_ value: IBtChannel) -> RustBuffer { - return FfiConverterTypeIBtChannel.lower(value) +public func FfiConverterTypeIBtInfoOptions_lower(_ value: IBtInfoOptions) -> RustBuffer { + return FfiConverterTypeIBtInfoOptions.lower(value) } -public struct IBtChannelClose { - public var txId: String - public var closeType: String - public var initiator: String - public var registeredAt: String +public struct IBtInfoVersions { + public var http: String + public var btc: String + public var ln2: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(txId: String, closeType: String, initiator: String, registeredAt: String) { - self.txId = txId - self.closeType = closeType - self.initiator = initiator - self.registeredAt = registeredAt + public init(http: String, btc: String, ln2: String) { + self.http = http + self.btc = btc + self.ln2 = ln2 } } #if compiler(>=6) -extension IBtChannelClose: Sendable {} +extension IBtInfoVersions: Sendable {} #endif -extension IBtChannelClose: Equatable, Hashable { - public static func ==(lhs: IBtChannelClose, rhs: IBtChannelClose) -> Bool { - if lhs.txId != rhs.txId { - return false - } - if lhs.closeType != rhs.closeType { +extension IBtInfoVersions: Equatable, Hashable { + public static func ==(lhs: IBtInfoVersions, rhs: IBtInfoVersions) -> Bool { + if lhs.http != rhs.http { return false } - if lhs.initiator != rhs.initiator { + if lhs.btc != rhs.btc { return false } - if lhs.registeredAt != rhs.registeredAt { + if lhs.ln2 != rhs.ln2 { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txId) - hasher.combine(closeType) - hasher.combine(initiator) - hasher.combine(registeredAt) - } + hasher.combine(http) + hasher.combine(btc) + hasher.combine(ln2) + } } -extension IBtChannelClose: Codable {} +extension IBtInfoVersions: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtChannelClose: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtChannelClose { +public struct FfiConverterTypeIBtInfoVersions: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfoVersions { return - try IBtChannelClose( - txId: FfiConverterString.read(from: &buf), - closeType: FfiConverterString.read(from: &buf), - initiator: FfiConverterString.read(from: &buf), - registeredAt: FfiConverterString.read(from: &buf) + try IBtInfoVersions( + http: FfiConverterString.read(from: &buf), + btc: FfiConverterString.read(from: &buf), + ln2: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: IBtChannelClose, into buf: inout [UInt8]) { - FfiConverterString.write(value.txId, into: &buf) - FfiConverterString.write(value.closeType, into: &buf) - FfiConverterString.write(value.initiator, into: &buf) - FfiConverterString.write(value.registeredAt, into: &buf) + public static func write(_ value: IBtInfoVersions, into buf: inout [UInt8]) { + FfiConverterString.write(value.http, into: &buf) + FfiConverterString.write(value.btc, into: &buf) + FfiConverterString.write(value.ln2, into: &buf) } } @@ -3543,71 +3552,119 @@ public struct FfiConverterTypeIBtChannelClose: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtChannelClose_lift(_ buf: RustBuffer) throws -> IBtChannelClose { - return try FfiConverterTypeIBtChannelClose.lift(buf) +public func FfiConverterTypeIBtInfoVersions_lift(_ buf: RustBuffer) throws -> IBtInfoVersions { + return try FfiConverterTypeIBtInfoVersions.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtChannelClose_lower(_ value: IBtChannelClose) -> RustBuffer { - return FfiConverterTypeIBtChannelClose.lower(value) +public func FfiConverterTypeIBtInfoVersions_lower(_ value: IBtInfoVersions) -> RustBuffer { + return FfiConverterTypeIBtInfoVersions.lower(value) } -public struct IBtEstimateFeeResponse { - public var feeSat: UInt64 - public var min0ConfTxFee: IBt0ConfMinTxFeeWindow +public struct IBtOnchainTransaction { + public var amountSat: UInt64 + public var txId: String + public var vout: UInt32 + public var blockHeight: UInt32? + public var blockConfirmationCount: UInt32 + public var feeRateSatPerVbyte: Double + public var confirmed: Bool + public var suspicious0ConfReason: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(feeSat: UInt64, min0ConfTxFee: IBt0ConfMinTxFeeWindow) { - self.feeSat = feeSat - self.min0ConfTxFee = min0ConfTxFee + public init(amountSat: UInt64, txId: String, vout: UInt32, blockHeight: UInt32?, blockConfirmationCount: UInt32, feeRateSatPerVbyte: Double, confirmed: Bool, suspicious0ConfReason: String) { + self.amountSat = amountSat + self.txId = txId + self.vout = vout + self.blockHeight = blockHeight + self.blockConfirmationCount = blockConfirmationCount + self.feeRateSatPerVbyte = feeRateSatPerVbyte + self.confirmed = confirmed + self.suspicious0ConfReason = suspicious0ConfReason } } #if compiler(>=6) -extension IBtEstimateFeeResponse: Sendable {} +extension IBtOnchainTransaction: Sendable {} #endif -extension IBtEstimateFeeResponse: Equatable, Hashable { - public static func ==(lhs: IBtEstimateFeeResponse, rhs: IBtEstimateFeeResponse) -> Bool { - if lhs.feeSat != rhs.feeSat { +extension IBtOnchainTransaction: Equatable, Hashable { + public static func ==(lhs: IBtOnchainTransaction, rhs: IBtOnchainTransaction) -> Bool { + if lhs.amountSat != rhs.amountSat { return false } - if lhs.min0ConfTxFee != rhs.min0ConfTxFee { + if lhs.txId != rhs.txId { + return false + } + if lhs.vout != rhs.vout { + return false + } + if lhs.blockHeight != rhs.blockHeight { + return false + } + if lhs.blockConfirmationCount != rhs.blockConfirmationCount { + return false + } + if lhs.feeRateSatPerVbyte != rhs.feeRateSatPerVbyte { + return false + } + if lhs.confirmed != rhs.confirmed { + return false + } + if lhs.suspicious0ConfReason != rhs.suspicious0ConfReason { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(feeSat) - hasher.combine(min0ConfTxFee) + hasher.combine(amountSat) + hasher.combine(txId) + hasher.combine(vout) + hasher.combine(blockHeight) + hasher.combine(blockConfirmationCount) + hasher.combine(feeRateSatPerVbyte) + hasher.combine(confirmed) + hasher.combine(suspicious0ConfReason) } } -extension IBtEstimateFeeResponse: Codable {} +extension IBtOnchainTransaction: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtEstimateFeeResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtEstimateFeeResponse { +public struct FfiConverterTypeIBtOnchainTransaction: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtOnchainTransaction { return - try IBtEstimateFeeResponse( - feeSat: FfiConverterUInt64.read(from: &buf), - min0ConfTxFee: FfiConverterTypeIBt0ConfMinTxFeeWindow.read(from: &buf) + try IBtOnchainTransaction( + amountSat: FfiConverterUInt64.read(from: &buf), + txId: FfiConverterString.read(from: &buf), + vout: FfiConverterUInt32.read(from: &buf), + blockHeight: FfiConverterOptionUInt32.read(from: &buf), + blockConfirmationCount: FfiConverterUInt32.read(from: &buf), + feeRateSatPerVbyte: FfiConverterDouble.read(from: &buf), + confirmed: FfiConverterBool.read(from: &buf), + suspicious0ConfReason: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: IBtEstimateFeeResponse, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.feeSat, into: &buf) - FfiConverterTypeIBt0ConfMinTxFeeWindow.write(value.min0ConfTxFee, into: &buf) + public static func write(_ value: IBtOnchainTransaction, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.amountSat, into: &buf) + FfiConverterString.write(value.txId, into: &buf) + FfiConverterUInt32.write(value.vout, into: &buf) + FfiConverterOptionUInt32.write(value.blockHeight, into: &buf) + FfiConverterUInt32.write(value.blockConfirmationCount, into: &buf) + FfiConverterDouble.write(value.feeRateSatPerVbyte, into: &buf) + FfiConverterBool.write(value.confirmed, into: &buf) + FfiConverterString.write(value.suspicious0ConfReason, into: &buf) } } @@ -3615,87 +3672,87 @@ public struct FfiConverterTypeIBtEstimateFeeResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtEstimateFeeResponse_lift(_ buf: RustBuffer) throws -> IBtEstimateFeeResponse { - return try FfiConverterTypeIBtEstimateFeeResponse.lift(buf) +public func FfiConverterTypeIBtOnchainTransaction_lift(_ buf: RustBuffer) throws -> IBtOnchainTransaction { + return try FfiConverterTypeIBtOnchainTransaction.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtEstimateFeeResponse_lower(_ value: IBtEstimateFeeResponse) -> RustBuffer { - return FfiConverterTypeIBtEstimateFeeResponse.lower(value) +public func FfiConverterTypeIBtOnchainTransaction_lower(_ value: IBtOnchainTransaction) -> RustBuffer { + return FfiConverterTypeIBtOnchainTransaction.lower(value) } -public struct IBtEstimateFeeResponse2 { - public var feeSat: UInt64 - public var networkFeeSat: UInt64 - public var serviceFeeSat: UInt64 - public var min0ConfTxFee: IBt0ConfMinTxFeeWindow +public struct IBtOnchainTransactions { + public var address: String + public var confirmedSat: UInt64 + public var requiredConfirmations: UInt32 + public var transactions: [IBtOnchainTransaction] // Default memberwise initializers are never public by default, so we // declare one manually. - public init(feeSat: UInt64, networkFeeSat: UInt64, serviceFeeSat: UInt64, min0ConfTxFee: IBt0ConfMinTxFeeWindow) { - self.feeSat = feeSat - self.networkFeeSat = networkFeeSat - self.serviceFeeSat = serviceFeeSat - self.min0ConfTxFee = min0ConfTxFee + public init(address: String, confirmedSat: UInt64, requiredConfirmations: UInt32, transactions: [IBtOnchainTransaction]) { + self.address = address + self.confirmedSat = confirmedSat + self.requiredConfirmations = requiredConfirmations + self.transactions = transactions } } #if compiler(>=6) -extension IBtEstimateFeeResponse2: Sendable {} +extension IBtOnchainTransactions: Sendable {} #endif -extension IBtEstimateFeeResponse2: Equatable, Hashable { - public static func ==(lhs: IBtEstimateFeeResponse2, rhs: IBtEstimateFeeResponse2) -> Bool { - if lhs.feeSat != rhs.feeSat { +extension IBtOnchainTransactions: Equatable, Hashable { + public static func ==(lhs: IBtOnchainTransactions, rhs: IBtOnchainTransactions) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.networkFeeSat != rhs.networkFeeSat { + if lhs.confirmedSat != rhs.confirmedSat { return false } - if lhs.serviceFeeSat != rhs.serviceFeeSat { + if lhs.requiredConfirmations != rhs.requiredConfirmations { return false } - if lhs.min0ConfTxFee != rhs.min0ConfTxFee { + if lhs.transactions != rhs.transactions { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(feeSat) - hasher.combine(networkFeeSat) - hasher.combine(serviceFeeSat) - hasher.combine(min0ConfTxFee) + hasher.combine(address) + hasher.combine(confirmedSat) + hasher.combine(requiredConfirmations) + hasher.combine(transactions) } } -extension IBtEstimateFeeResponse2: Codable {} +extension IBtOnchainTransactions: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtEstimateFeeResponse2: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtEstimateFeeResponse2 { +public struct FfiConverterTypeIBtOnchainTransactions: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtOnchainTransactions { return - try IBtEstimateFeeResponse2( - feeSat: FfiConverterUInt64.read(from: &buf), - networkFeeSat: FfiConverterUInt64.read(from: &buf), - serviceFeeSat: FfiConverterUInt64.read(from: &buf), - min0ConfTxFee: FfiConverterTypeIBt0ConfMinTxFeeWindow.read(from: &buf) + try IBtOnchainTransactions( + address: FfiConverterString.read(from: &buf), + confirmedSat: FfiConverterUInt64.read(from: &buf), + requiredConfirmations: FfiConverterUInt32.read(from: &buf), + transactions: FfiConverterSequenceTypeIBtOnchainTransaction.read(from: &buf) ) } - public static func write(_ value: IBtEstimateFeeResponse2, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.feeSat, into: &buf) - FfiConverterUInt64.write(value.networkFeeSat, into: &buf) - FfiConverterUInt64.write(value.serviceFeeSat, into: &buf) - FfiConverterTypeIBt0ConfMinTxFeeWindow.write(value.min0ConfTxFee, into: &buf) + public static func write(_ value: IBtOnchainTransactions, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterUInt64.write(value.confirmedSat, into: &buf) + FfiConverterUInt32.write(value.requiredConfirmations, into: &buf) + FfiConverterSequenceTypeIBtOnchainTransaction.write(value.transactions, into: &buf) } } @@ -3703,95 +3760,239 @@ public struct FfiConverterTypeIBtEstimateFeeResponse2: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtEstimateFeeResponse2_lift(_ buf: RustBuffer) throws -> IBtEstimateFeeResponse2 { - return try FfiConverterTypeIBtEstimateFeeResponse2.lift(buf) +public func FfiConverterTypeIBtOnchainTransactions_lift(_ buf: RustBuffer) throws -> IBtOnchainTransactions { + return try FfiConverterTypeIBtOnchainTransactions.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtEstimateFeeResponse2_lower(_ value: IBtEstimateFeeResponse2) -> RustBuffer { - return FfiConverterTypeIBtEstimateFeeResponse2.lower(value) +public func FfiConverterTypeIBtOnchainTransactions_lower(_ value: IBtOnchainTransactions) -> RustBuffer { + return FfiConverterTypeIBtOnchainTransactions.lower(value) } -public struct IBtInfo { - public var version: UInt32 - public var nodes: [ILspNode] - public var options: IBtInfoOptions - public var versions: IBtInfoVersions - public var onchain: IBtInfoOnchain +public struct IBtOrder { + public var id: String + public var state: BtOrderState + public var state2: BtOrderState2? + public var feeSat: UInt64 + public var networkFeeSat: UInt64 + public var serviceFeeSat: UInt64 + public var lspBalanceSat: UInt64 + public var clientBalanceSat: UInt64 + public var zeroConf: Bool + public var zeroReserve: Bool + public var clientNodeId: String? + public var channelExpiryWeeks: UInt32 + public var channelExpiresAt: String + public var orderExpiresAt: String + public var channel: IBtChannel? + public var lspNode: ILspNode? + public var lnurl: String? + public var payment: IBtPayment? + public var couponCode: String? + public var source: String? + public var discount: IDiscount? + public var updatedAt: String + public var createdAt: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(version: UInt32, nodes: [ILspNode], options: IBtInfoOptions, versions: IBtInfoVersions, onchain: IBtInfoOnchain) { - self.version = version - self.nodes = nodes - self.options = options - self.versions = versions - self.onchain = onchain - } -} - -#if compiler(>=6) -extension IBtInfo: Sendable {} -#endif - - -extension IBtInfo: Equatable, Hashable { - public static func ==(lhs: IBtInfo, rhs: IBtInfo) -> Bool { - if lhs.version != rhs.version { + public init(id: String, state: BtOrderState, state2: BtOrderState2?, feeSat: UInt64, networkFeeSat: UInt64, serviceFeeSat: UInt64, lspBalanceSat: UInt64, clientBalanceSat: UInt64, zeroConf: Bool, zeroReserve: Bool, clientNodeId: String?, channelExpiryWeeks: UInt32, channelExpiresAt: String, orderExpiresAt: String, channel: IBtChannel?, lspNode: ILspNode?, lnurl: String?, payment: IBtPayment?, couponCode: String?, source: String?, discount: IDiscount?, updatedAt: String, createdAt: String) { + self.id = id + self.state = state + self.state2 = state2 + self.feeSat = feeSat + self.networkFeeSat = networkFeeSat + self.serviceFeeSat = serviceFeeSat + self.lspBalanceSat = lspBalanceSat + self.clientBalanceSat = clientBalanceSat + self.zeroConf = zeroConf + self.zeroReserve = zeroReserve + self.clientNodeId = clientNodeId + self.channelExpiryWeeks = channelExpiryWeeks + self.channelExpiresAt = channelExpiresAt + self.orderExpiresAt = orderExpiresAt + self.channel = channel + self.lspNode = lspNode + self.lnurl = lnurl + self.payment = payment + self.couponCode = couponCode + self.source = source + self.discount = discount + self.updatedAt = updatedAt + self.createdAt = createdAt + } +} + +#if compiler(>=6) +extension IBtOrder: Sendable {} +#endif + + +extension IBtOrder: Equatable, Hashable { + public static func ==(lhs: IBtOrder, rhs: IBtOrder) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.nodes != rhs.nodes { + if lhs.state != rhs.state { return false } - if lhs.options != rhs.options { + if lhs.state2 != rhs.state2 { return false } - if lhs.versions != rhs.versions { + if lhs.feeSat != rhs.feeSat { return false } - if lhs.onchain != rhs.onchain { + if lhs.networkFeeSat != rhs.networkFeeSat { + return false + } + if lhs.serviceFeeSat != rhs.serviceFeeSat { + return false + } + if lhs.lspBalanceSat != rhs.lspBalanceSat { + return false + } + if lhs.clientBalanceSat != rhs.clientBalanceSat { + return false + } + if lhs.zeroConf != rhs.zeroConf { + return false + } + if lhs.zeroReserve != rhs.zeroReserve { + return false + } + if lhs.clientNodeId != rhs.clientNodeId { + return false + } + if lhs.channelExpiryWeeks != rhs.channelExpiryWeeks { + return false + } + if lhs.channelExpiresAt != rhs.channelExpiresAt { + return false + } + if lhs.orderExpiresAt != rhs.orderExpiresAt { + return false + } + if lhs.channel != rhs.channel { + return false + } + if lhs.lspNode != rhs.lspNode { + return false + } + if lhs.lnurl != rhs.lnurl { + return false + } + if lhs.payment != rhs.payment { + return false + } + if lhs.couponCode != rhs.couponCode { + return false + } + if lhs.source != rhs.source { + return false + } + if lhs.discount != rhs.discount { + return false + } + if lhs.updatedAt != rhs.updatedAt { + return false + } + if lhs.createdAt != rhs.createdAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(version) - hasher.combine(nodes) - hasher.combine(options) - hasher.combine(versions) - hasher.combine(onchain) + hasher.combine(id) + hasher.combine(state) + hasher.combine(state2) + hasher.combine(feeSat) + hasher.combine(networkFeeSat) + hasher.combine(serviceFeeSat) + hasher.combine(lspBalanceSat) + hasher.combine(clientBalanceSat) + hasher.combine(zeroConf) + hasher.combine(zeroReserve) + hasher.combine(clientNodeId) + hasher.combine(channelExpiryWeeks) + hasher.combine(channelExpiresAt) + hasher.combine(orderExpiresAt) + hasher.combine(channel) + hasher.combine(lspNode) + hasher.combine(lnurl) + hasher.combine(payment) + hasher.combine(couponCode) + hasher.combine(source) + hasher.combine(discount) + hasher.combine(updatedAt) + hasher.combine(createdAt) } } -extension IBtInfo: Codable {} +extension IBtOrder: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtInfo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfo { +public struct FfiConverterTypeIBtOrder: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtOrder { return - try IBtInfo( - version: FfiConverterUInt32.read(from: &buf), - nodes: FfiConverterSequenceTypeILspNode.read(from: &buf), - options: FfiConverterTypeIBtInfoOptions.read(from: &buf), - versions: FfiConverterTypeIBtInfoVersions.read(from: &buf), - onchain: FfiConverterTypeIBtInfoOnchain.read(from: &buf) + try IBtOrder( + id: FfiConverterString.read(from: &buf), + state: FfiConverterTypeBtOrderState.read(from: &buf), + state2: FfiConverterOptionTypeBtOrderState2.read(from: &buf), + feeSat: FfiConverterUInt64.read(from: &buf), + networkFeeSat: FfiConverterUInt64.read(from: &buf), + serviceFeeSat: FfiConverterUInt64.read(from: &buf), + lspBalanceSat: FfiConverterUInt64.read(from: &buf), + clientBalanceSat: FfiConverterUInt64.read(from: &buf), + zeroConf: FfiConverterBool.read(from: &buf), + zeroReserve: FfiConverterBool.read(from: &buf), + clientNodeId: FfiConverterOptionString.read(from: &buf), + channelExpiryWeeks: FfiConverterUInt32.read(from: &buf), + channelExpiresAt: FfiConverterString.read(from: &buf), + orderExpiresAt: FfiConverterString.read(from: &buf), + channel: FfiConverterOptionTypeIBtChannel.read(from: &buf), + lspNode: FfiConverterOptionTypeILspNode.read(from: &buf), + lnurl: FfiConverterOptionString.read(from: &buf), + payment: FfiConverterOptionTypeIBtPayment.read(from: &buf), + couponCode: FfiConverterOptionString.read(from: &buf), + source: FfiConverterOptionString.read(from: &buf), + discount: FfiConverterOptionTypeIDiscount.read(from: &buf), + updatedAt: FfiConverterString.read(from: &buf), + createdAt: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: IBtInfo, into buf: inout [UInt8]) { - FfiConverterUInt32.write(value.version, into: &buf) - FfiConverterSequenceTypeILspNode.write(value.nodes, into: &buf) - FfiConverterTypeIBtInfoOptions.write(value.options, into: &buf) - FfiConverterTypeIBtInfoVersions.write(value.versions, into: &buf) - FfiConverterTypeIBtInfoOnchain.write(value.onchain, into: &buf) + public static func write(_ value: IBtOrder, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterTypeBtOrderState.write(value.state, into: &buf) + FfiConverterOptionTypeBtOrderState2.write(value.state2, into: &buf) + FfiConverterUInt64.write(value.feeSat, into: &buf) + FfiConverterUInt64.write(value.networkFeeSat, into: &buf) + FfiConverterUInt64.write(value.serviceFeeSat, into: &buf) + FfiConverterUInt64.write(value.lspBalanceSat, into: &buf) + FfiConverterUInt64.write(value.clientBalanceSat, into: &buf) + FfiConverterBool.write(value.zeroConf, into: &buf) + FfiConverterBool.write(value.zeroReserve, into: &buf) + FfiConverterOptionString.write(value.clientNodeId, into: &buf) + FfiConverterUInt32.write(value.channelExpiryWeeks, into: &buf) + FfiConverterString.write(value.channelExpiresAt, into: &buf) + FfiConverterString.write(value.orderExpiresAt, into: &buf) + FfiConverterOptionTypeIBtChannel.write(value.channel, into: &buf) + FfiConverterOptionTypeILspNode.write(value.lspNode, into: &buf) + FfiConverterOptionString.write(value.lnurl, into: &buf) + FfiConverterOptionTypeIBtPayment.write(value.payment, into: &buf) + FfiConverterOptionString.write(value.couponCode, into: &buf) + FfiConverterOptionString.write(value.source, into: &buf) + FfiConverterOptionTypeIDiscount.write(value.discount, into: &buf) + FfiConverterString.write(value.updatedAt, into: &buf) + FfiConverterString.write(value.createdAt, into: &buf) } } @@ -3799,71 +4000,111 @@ public struct FfiConverterTypeIBtInfo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfo_lift(_ buf: RustBuffer) throws -> IBtInfo { - return try FfiConverterTypeIBtInfo.lift(buf) +public func FfiConverterTypeIBtOrder_lift(_ buf: RustBuffer) throws -> IBtOrder { + return try FfiConverterTypeIBtOrder.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfo_lower(_ value: IBtInfo) -> RustBuffer { - return FfiConverterTypeIBtInfo.lower(value) +public func FfiConverterTypeIBtOrder_lower(_ value: IBtOrder) -> RustBuffer { + return FfiConverterTypeIBtOrder.lower(value) } -public struct IBtInfoOnchain { - public var network: BitcoinNetworkEnum - public var feeRates: FeeRates +public struct IBtPayment { + public var state: BtPaymentState + public var state2: BtPaymentState2? + public var paidSat: UInt64 + public var bolt11Invoice: IBtBolt11Invoice? + public var onchain: IBtOnchainTransactions? + public var isManuallyPaid: Bool? + public var manualRefunds: [IManualRefund]? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(network: BitcoinNetworkEnum, feeRates: FeeRates) { - self.network = network - self.feeRates = feeRates + public init(state: BtPaymentState, state2: BtPaymentState2?, paidSat: UInt64, bolt11Invoice: IBtBolt11Invoice?, onchain: IBtOnchainTransactions?, isManuallyPaid: Bool?, manualRefunds: [IManualRefund]?) { + self.state = state + self.state2 = state2 + self.paidSat = paidSat + self.bolt11Invoice = bolt11Invoice + self.onchain = onchain + self.isManuallyPaid = isManuallyPaid + self.manualRefunds = manualRefunds } } #if compiler(>=6) -extension IBtInfoOnchain: Sendable {} +extension IBtPayment: Sendable {} #endif -extension IBtInfoOnchain: Equatable, Hashable { - public static func ==(lhs: IBtInfoOnchain, rhs: IBtInfoOnchain) -> Bool { - if lhs.network != rhs.network { +extension IBtPayment: Equatable, Hashable { + public static func ==(lhs: IBtPayment, rhs: IBtPayment) -> Bool { + if lhs.state != rhs.state { return false } - if lhs.feeRates != rhs.feeRates { + if lhs.state2 != rhs.state2 { + return false + } + if lhs.paidSat != rhs.paidSat { + return false + } + if lhs.bolt11Invoice != rhs.bolt11Invoice { + return false + } + if lhs.onchain != rhs.onchain { + return false + } + if lhs.isManuallyPaid != rhs.isManuallyPaid { + return false + } + if lhs.manualRefunds != rhs.manualRefunds { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(network) - hasher.combine(feeRates) - } -} - -extension IBtInfoOnchain: Codable {} - + hasher.combine(state) + hasher.combine(state2) + hasher.combine(paidSat) + hasher.combine(bolt11Invoice) + hasher.combine(onchain) + hasher.combine(isManuallyPaid) + hasher.combine(manualRefunds) + } +} + +extension IBtPayment: Codable {} + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtInfoOnchain: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfoOnchain { +public struct FfiConverterTypeIBtPayment: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtPayment { return - try IBtInfoOnchain( - network: FfiConverterTypeBitcoinNetworkEnum.read(from: &buf), - feeRates: FfiConverterTypeFeeRates.read(from: &buf) + try IBtPayment( + state: FfiConverterTypeBtPaymentState.read(from: &buf), + state2: FfiConverterOptionTypeBtPaymentState2.read(from: &buf), + paidSat: FfiConverterUInt64.read(from: &buf), + bolt11Invoice: FfiConverterOptionTypeIBtBolt11Invoice.read(from: &buf), + onchain: FfiConverterOptionTypeIBtOnchainTransactions.read(from: &buf), + isManuallyPaid: FfiConverterOptionBool.read(from: &buf), + manualRefunds: FfiConverterOptionSequenceTypeIManualRefund.read(from: &buf) ) } - public static func write(_ value: IBtInfoOnchain, into buf: inout [UInt8]) { - FfiConverterTypeBitcoinNetworkEnum.write(value.network, into: &buf) - FfiConverterTypeFeeRates.write(value.feeRates, into: &buf) + public static func write(_ value: IBtPayment, into buf: inout [UInt8]) { + FfiConverterTypeBtPaymentState.write(value.state, into: &buf) + FfiConverterOptionTypeBtPaymentState2.write(value.state2, into: &buf) + FfiConverterUInt64.write(value.paidSat, into: &buf) + FfiConverterOptionTypeIBtBolt11Invoice.write(value.bolt11Invoice, into: &buf) + FfiConverterOptionTypeIBtOnchainTransactions.write(value.onchain, into: &buf) + FfiConverterOptionBool.write(value.isManuallyPaid, into: &buf) + FfiConverterOptionSequenceTypeIManualRefund.write(value.manualRefunds, into: &buf) } } @@ -3871,119 +4112,199 @@ public struct FfiConverterTypeIBtInfoOnchain: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfoOnchain_lift(_ buf: RustBuffer) throws -> IBtInfoOnchain { - return try FfiConverterTypeIBtInfoOnchain.lift(buf) +public func FfiConverterTypeIBtPayment_lift(_ buf: RustBuffer) throws -> IBtPayment { + return try FfiConverterTypeIBtPayment.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfoOnchain_lower(_ value: IBtInfoOnchain) -> RustBuffer { - return FfiConverterTypeIBtInfoOnchain.lower(value) +public func FfiConverterTypeIBtPayment_lower(_ value: IBtPayment) -> RustBuffer { + return FfiConverterTypeIBtPayment.lower(value) } -public struct IBtInfoOptions { - public var minChannelSizeSat: UInt64 - public var maxChannelSizeSat: UInt64 - public var minExpiryWeeks: UInt32 - public var maxExpiryWeeks: UInt32 - public var minPaymentConfirmations: UInt32 - public var minHighRiskPaymentConfirmations: UInt32 - public var max0ConfClientBalanceSat: UInt64 - public var maxClientBalanceSat: UInt64 +public struct IcJitEntry { + public var id: String + public var state: CJitStateEnum + public var feeSat: UInt64 + public var networkFeeSat: UInt64 + public var serviceFeeSat: UInt64 + public var channelSizeSat: UInt64 + public var channelExpiryWeeks: UInt32 + public var channelOpenError: String? + public var nodeId: String + public var invoice: IBtBolt11Invoice + public var channel: IBtChannel? + public var lspNode: ILspNode + public var couponCode: String + public var source: String? + public var discount: IDiscount? + public var expiresAt: String + public var updatedAt: String + public var createdAt: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(minChannelSizeSat: UInt64, maxChannelSizeSat: UInt64, minExpiryWeeks: UInt32, maxExpiryWeeks: UInt32, minPaymentConfirmations: UInt32, minHighRiskPaymentConfirmations: UInt32, max0ConfClientBalanceSat: UInt64, maxClientBalanceSat: UInt64) { - self.minChannelSizeSat = minChannelSizeSat - self.maxChannelSizeSat = maxChannelSizeSat - self.minExpiryWeeks = minExpiryWeeks - self.maxExpiryWeeks = maxExpiryWeeks - self.minPaymentConfirmations = minPaymentConfirmations - self.minHighRiskPaymentConfirmations = minHighRiskPaymentConfirmations - self.max0ConfClientBalanceSat = max0ConfClientBalanceSat - self.maxClientBalanceSat = maxClientBalanceSat + public init(id: String, state: CJitStateEnum, feeSat: UInt64, networkFeeSat: UInt64, serviceFeeSat: UInt64, channelSizeSat: UInt64, channelExpiryWeeks: UInt32, channelOpenError: String?, nodeId: String, invoice: IBtBolt11Invoice, channel: IBtChannel?, lspNode: ILspNode, couponCode: String, source: String?, discount: IDiscount?, expiresAt: String, updatedAt: String, createdAt: String) { + self.id = id + self.state = state + self.feeSat = feeSat + self.networkFeeSat = networkFeeSat + self.serviceFeeSat = serviceFeeSat + self.channelSizeSat = channelSizeSat + self.channelExpiryWeeks = channelExpiryWeeks + self.channelOpenError = channelOpenError + self.nodeId = nodeId + self.invoice = invoice + self.channel = channel + self.lspNode = lspNode + self.couponCode = couponCode + self.source = source + self.discount = discount + self.expiresAt = expiresAt + self.updatedAt = updatedAt + self.createdAt = createdAt } } #if compiler(>=6) -extension IBtInfoOptions: Sendable {} +extension IcJitEntry: Sendable {} #endif -extension IBtInfoOptions: Equatable, Hashable { - public static func ==(lhs: IBtInfoOptions, rhs: IBtInfoOptions) -> Bool { - if lhs.minChannelSizeSat != rhs.minChannelSizeSat { +extension IcJitEntry: Equatable, Hashable { + public static func ==(lhs: IcJitEntry, rhs: IcJitEntry) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.maxChannelSizeSat != rhs.maxChannelSizeSat { + if lhs.state != rhs.state { return false } - if lhs.minExpiryWeeks != rhs.minExpiryWeeks { + if lhs.feeSat != rhs.feeSat { return false } - if lhs.maxExpiryWeeks != rhs.maxExpiryWeeks { + if lhs.networkFeeSat != rhs.networkFeeSat { return false } - if lhs.minPaymentConfirmations != rhs.minPaymentConfirmations { + if lhs.serviceFeeSat != rhs.serviceFeeSat { return false } - if lhs.minHighRiskPaymentConfirmations != rhs.minHighRiskPaymentConfirmations { + if lhs.channelSizeSat != rhs.channelSizeSat { return false } - if lhs.max0ConfClientBalanceSat != rhs.max0ConfClientBalanceSat { + if lhs.channelExpiryWeeks != rhs.channelExpiryWeeks { return false } - if lhs.maxClientBalanceSat != rhs.maxClientBalanceSat { + if lhs.channelOpenError != rhs.channelOpenError { + return false + } + if lhs.nodeId != rhs.nodeId { + return false + } + if lhs.invoice != rhs.invoice { + return false + } + if lhs.channel != rhs.channel { + return false + } + if lhs.lspNode != rhs.lspNode { + return false + } + if lhs.couponCode != rhs.couponCode { + return false + } + if lhs.source != rhs.source { + return false + } + if lhs.discount != rhs.discount { + return false + } + if lhs.expiresAt != rhs.expiresAt { + return false + } + if lhs.updatedAt != rhs.updatedAt { + return false + } + if lhs.createdAt != rhs.createdAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(minChannelSizeSat) - hasher.combine(maxChannelSizeSat) - hasher.combine(minExpiryWeeks) - hasher.combine(maxExpiryWeeks) - hasher.combine(minPaymentConfirmations) - hasher.combine(minHighRiskPaymentConfirmations) - hasher.combine(max0ConfClientBalanceSat) - hasher.combine(maxClientBalanceSat) + hasher.combine(id) + hasher.combine(state) + hasher.combine(feeSat) + hasher.combine(networkFeeSat) + hasher.combine(serviceFeeSat) + hasher.combine(channelSizeSat) + hasher.combine(channelExpiryWeeks) + hasher.combine(channelOpenError) + hasher.combine(nodeId) + hasher.combine(invoice) + hasher.combine(channel) + hasher.combine(lspNode) + hasher.combine(couponCode) + hasher.combine(source) + hasher.combine(discount) + hasher.combine(expiresAt) + hasher.combine(updatedAt) + hasher.combine(createdAt) } } -extension IBtInfoOptions: Codable {} +extension IcJitEntry: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtInfoOptions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfoOptions { +public struct FfiConverterTypeICJitEntry: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IcJitEntry { return - try IBtInfoOptions( - minChannelSizeSat: FfiConverterUInt64.read(from: &buf), - maxChannelSizeSat: FfiConverterUInt64.read(from: &buf), - minExpiryWeeks: FfiConverterUInt32.read(from: &buf), - maxExpiryWeeks: FfiConverterUInt32.read(from: &buf), - minPaymentConfirmations: FfiConverterUInt32.read(from: &buf), - minHighRiskPaymentConfirmations: FfiConverterUInt32.read(from: &buf), - max0ConfClientBalanceSat: FfiConverterUInt64.read(from: &buf), - maxClientBalanceSat: FfiConverterUInt64.read(from: &buf) + try IcJitEntry( + id: FfiConverterString.read(from: &buf), + state: FfiConverterTypeCJitStateEnum.read(from: &buf), + feeSat: FfiConverterUInt64.read(from: &buf), + networkFeeSat: FfiConverterUInt64.read(from: &buf), + serviceFeeSat: FfiConverterUInt64.read(from: &buf), + channelSizeSat: FfiConverterUInt64.read(from: &buf), + channelExpiryWeeks: FfiConverterUInt32.read(from: &buf), + channelOpenError: FfiConverterOptionString.read(from: &buf), + nodeId: FfiConverterString.read(from: &buf), + invoice: FfiConverterTypeIBtBolt11Invoice.read(from: &buf), + channel: FfiConverterOptionTypeIBtChannel.read(from: &buf), + lspNode: FfiConverterTypeILspNode.read(from: &buf), + couponCode: FfiConverterString.read(from: &buf), + source: FfiConverterOptionString.read(from: &buf), + discount: FfiConverterOptionTypeIDiscount.read(from: &buf), + expiresAt: FfiConverterString.read(from: &buf), + updatedAt: FfiConverterString.read(from: &buf), + createdAt: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: IBtInfoOptions, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.minChannelSizeSat, into: &buf) - FfiConverterUInt64.write(value.maxChannelSizeSat, into: &buf) - FfiConverterUInt32.write(value.minExpiryWeeks, into: &buf) - FfiConverterUInt32.write(value.maxExpiryWeeks, into: &buf) - FfiConverterUInt32.write(value.minPaymentConfirmations, into: &buf) - FfiConverterUInt32.write(value.minHighRiskPaymentConfirmations, into: &buf) - FfiConverterUInt64.write(value.max0ConfClientBalanceSat, into: &buf) - FfiConverterUInt64.write(value.maxClientBalanceSat, into: &buf) + public static func write(_ value: IcJitEntry, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterTypeCJitStateEnum.write(value.state, into: &buf) + FfiConverterUInt64.write(value.feeSat, into: &buf) + FfiConverterUInt64.write(value.networkFeeSat, into: &buf) + FfiConverterUInt64.write(value.serviceFeeSat, into: &buf) + FfiConverterUInt64.write(value.channelSizeSat, into: &buf) + FfiConverterUInt32.write(value.channelExpiryWeeks, into: &buf) + FfiConverterOptionString.write(value.channelOpenError, into: &buf) + FfiConverterString.write(value.nodeId, into: &buf) + FfiConverterTypeIBtBolt11Invoice.write(value.invoice, into: &buf) + FfiConverterOptionTypeIBtChannel.write(value.channel, into: &buf) + FfiConverterTypeILspNode.write(value.lspNode, into: &buf) + FfiConverterString.write(value.couponCode, into: &buf) + FfiConverterOptionString.write(value.source, into: &buf) + FfiConverterOptionTypeIDiscount.write(value.discount, into: &buf) + FfiConverterString.write(value.expiresAt, into: &buf) + FfiConverterString.write(value.updatedAt, into: &buf) + FfiConverterString.write(value.createdAt, into: &buf) } } @@ -3991,79 +4312,87 @@ public struct FfiConverterTypeIBtInfoOptions: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfoOptions_lift(_ buf: RustBuffer) throws -> IBtInfoOptions { - return try FfiConverterTypeIBtInfoOptions.lift(buf) +public func FfiConverterTypeICJitEntry_lift(_ buf: RustBuffer) throws -> IcJitEntry { + return try FfiConverterTypeICJitEntry.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfoOptions_lower(_ value: IBtInfoOptions) -> RustBuffer { - return FfiConverterTypeIBtInfoOptions.lower(value) +public func FfiConverterTypeICJitEntry_lower(_ value: IcJitEntry) -> RustBuffer { + return FfiConverterTypeICJitEntry.lower(value) } -public struct IBtInfoVersions { - public var http: String - public var btc: String - public var ln2: String - - // Default memberwise initializers are never public by default, so we +public struct IDiscount { + public var code: String + public var absoluteSat: UInt64 + public var relative: Double + public var overallSat: UInt64 + + // Default memberwise initializers are never public by default, so we // declare one manually. - public init(http: String, btc: String, ln2: String) { - self.http = http - self.btc = btc - self.ln2 = ln2 + public init(code: String, absoluteSat: UInt64, relative: Double, overallSat: UInt64) { + self.code = code + self.absoluteSat = absoluteSat + self.relative = relative + self.overallSat = overallSat } } #if compiler(>=6) -extension IBtInfoVersions: Sendable {} +extension IDiscount: Sendable {} #endif -extension IBtInfoVersions: Equatable, Hashable { - public static func ==(lhs: IBtInfoVersions, rhs: IBtInfoVersions) -> Bool { - if lhs.http != rhs.http { +extension IDiscount: Equatable, Hashable { + public static func ==(lhs: IDiscount, rhs: IDiscount) -> Bool { + if lhs.code != rhs.code { return false } - if lhs.btc != rhs.btc { + if lhs.absoluteSat != rhs.absoluteSat { return false } - if lhs.ln2 != rhs.ln2 { + if lhs.relative != rhs.relative { + return false + } + if lhs.overallSat != rhs.overallSat { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(http) - hasher.combine(btc) - hasher.combine(ln2) + hasher.combine(code) + hasher.combine(absoluteSat) + hasher.combine(relative) + hasher.combine(overallSat) } } -extension IBtInfoVersions: Codable {} +extension IDiscount: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtInfoVersions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtInfoVersions { +public struct FfiConverterTypeIDiscount: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IDiscount { return - try IBtInfoVersions( - http: FfiConverterString.read(from: &buf), - btc: FfiConverterString.read(from: &buf), - ln2: FfiConverterString.read(from: &buf) + try IDiscount( + code: FfiConverterString.read(from: &buf), + absoluteSat: FfiConverterUInt64.read(from: &buf), + relative: FfiConverterDouble.read(from: &buf), + overallSat: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: IBtInfoVersions, into buf: inout [UInt8]) { - FfiConverterString.write(value.http, into: &buf) - FfiConverterString.write(value.btc, into: &buf) - FfiConverterString.write(value.ln2, into: &buf) + public static func write(_ value: IDiscount, into buf: inout [UInt8]) { + FfiConverterString.write(value.code, into: &buf) + FfiConverterUInt64.write(value.absoluteSat, into: &buf) + FfiConverterDouble.write(value.relative, into: &buf) + FfiConverterUInt64.write(value.overallSat, into: &buf) } } @@ -4071,119 +4400,135 @@ public struct FfiConverterTypeIBtInfoVersions: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfoVersions_lift(_ buf: RustBuffer) throws -> IBtInfoVersions { - return try FfiConverterTypeIBtInfoVersions.lift(buf) +public func FfiConverterTypeIDiscount_lift(_ buf: RustBuffer) throws -> IDiscount { + return try FfiConverterTypeIDiscount.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtInfoVersions_lower(_ value: IBtInfoVersions) -> RustBuffer { - return FfiConverterTypeIBtInfoVersions.lower(value) +public func FfiConverterTypeIDiscount_lower(_ value: IDiscount) -> RustBuffer { + return FfiConverterTypeIDiscount.lower(value) } -public struct IBtOnchainTransaction { - public var amountSat: UInt64 - public var txId: String - public var vout: UInt32 - public var blockHeight: UInt32? - public var blockConfirmationCount: UInt32 - public var feeRateSatPerVbyte: Double - public var confirmed: Bool - public var suspicious0ConfReason: String +public struct IGift { + public var id: String + public var nodeId: String + public var orderId: String? + public var order: IGiftOrder? + public var bolt11PaymentId: String? + public var bolt11Payment: IGiftPayment? + public var appliedGiftCodeId: String? + public var appliedGiftCode: IGiftCode? + public var createdAt: String? + public var updatedAt: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(amountSat: UInt64, txId: String, vout: UInt32, blockHeight: UInt32?, blockConfirmationCount: UInt32, feeRateSatPerVbyte: Double, confirmed: Bool, suspicious0ConfReason: String) { - self.amountSat = amountSat - self.txId = txId - self.vout = vout - self.blockHeight = blockHeight - self.blockConfirmationCount = blockConfirmationCount - self.feeRateSatPerVbyte = feeRateSatPerVbyte - self.confirmed = confirmed - self.suspicious0ConfReason = suspicious0ConfReason + public init(id: String, nodeId: String, orderId: String?, order: IGiftOrder?, bolt11PaymentId: String?, bolt11Payment: IGiftPayment?, appliedGiftCodeId: String?, appliedGiftCode: IGiftCode?, createdAt: String?, updatedAt: String?) { + self.id = id + self.nodeId = nodeId + self.orderId = orderId + self.order = order + self.bolt11PaymentId = bolt11PaymentId + self.bolt11Payment = bolt11Payment + self.appliedGiftCodeId = appliedGiftCodeId + self.appliedGiftCode = appliedGiftCode + self.createdAt = createdAt + self.updatedAt = updatedAt } } #if compiler(>=6) -extension IBtOnchainTransaction: Sendable {} +extension IGift: Sendable {} #endif -extension IBtOnchainTransaction: Equatable, Hashable { - public static func ==(lhs: IBtOnchainTransaction, rhs: IBtOnchainTransaction) -> Bool { - if lhs.amountSat != rhs.amountSat { +extension IGift: Equatable, Hashable { + public static func ==(lhs: IGift, rhs: IGift) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.txId != rhs.txId { + if lhs.nodeId != rhs.nodeId { return false } - if lhs.vout != rhs.vout { + if lhs.orderId != rhs.orderId { return false } - if lhs.blockHeight != rhs.blockHeight { + if lhs.order != rhs.order { return false } - if lhs.blockConfirmationCount != rhs.blockConfirmationCount { + if lhs.bolt11PaymentId != rhs.bolt11PaymentId { return false } - if lhs.feeRateSatPerVbyte != rhs.feeRateSatPerVbyte { + if lhs.bolt11Payment != rhs.bolt11Payment { return false } - if lhs.confirmed != rhs.confirmed { + if lhs.appliedGiftCodeId != rhs.appliedGiftCodeId { return false } - if lhs.suspicious0ConfReason != rhs.suspicious0ConfReason { + if lhs.appliedGiftCode != rhs.appliedGiftCode { + return false + } + if lhs.createdAt != rhs.createdAt { + return false + } + if lhs.updatedAt != rhs.updatedAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(amountSat) - hasher.combine(txId) - hasher.combine(vout) - hasher.combine(blockHeight) - hasher.combine(blockConfirmationCount) - hasher.combine(feeRateSatPerVbyte) - hasher.combine(confirmed) - hasher.combine(suspicious0ConfReason) + hasher.combine(id) + hasher.combine(nodeId) + hasher.combine(orderId) + hasher.combine(order) + hasher.combine(bolt11PaymentId) + hasher.combine(bolt11Payment) + hasher.combine(appliedGiftCodeId) + hasher.combine(appliedGiftCode) + hasher.combine(createdAt) + hasher.combine(updatedAt) } } -extension IBtOnchainTransaction: Codable {} +extension IGift: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtOnchainTransaction: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtOnchainTransaction { +public struct FfiConverterTypeIGift: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGift { return - try IBtOnchainTransaction( - amountSat: FfiConverterUInt64.read(from: &buf), - txId: FfiConverterString.read(from: &buf), - vout: FfiConverterUInt32.read(from: &buf), - blockHeight: FfiConverterOptionUInt32.read(from: &buf), - blockConfirmationCount: FfiConverterUInt32.read(from: &buf), - feeRateSatPerVbyte: FfiConverterDouble.read(from: &buf), - confirmed: FfiConverterBool.read(from: &buf), - suspicious0ConfReason: FfiConverterString.read(from: &buf) + try IGift( + id: FfiConverterString.read(from: &buf), + nodeId: FfiConverterString.read(from: &buf), + orderId: FfiConverterOptionString.read(from: &buf), + order: FfiConverterOptionTypeIGiftOrder.read(from: &buf), + bolt11PaymentId: FfiConverterOptionString.read(from: &buf), + bolt11Payment: FfiConverterOptionTypeIGiftPayment.read(from: &buf), + appliedGiftCodeId: FfiConverterOptionString.read(from: &buf), + appliedGiftCode: FfiConverterOptionTypeIGiftCode.read(from: &buf), + createdAt: FfiConverterOptionString.read(from: &buf), + updatedAt: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: IBtOnchainTransaction, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.amountSat, into: &buf) - FfiConverterString.write(value.txId, into: &buf) - FfiConverterUInt32.write(value.vout, into: &buf) - FfiConverterOptionUInt32.write(value.blockHeight, into: &buf) - FfiConverterUInt32.write(value.blockConfirmationCount, into: &buf) - FfiConverterDouble.write(value.feeRateSatPerVbyte, into: &buf) - FfiConverterBool.write(value.confirmed, into: &buf) - FfiConverterString.write(value.suspicious0ConfReason, into: &buf) + public static func write(_ value: IGift, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.nodeId, into: &buf) + FfiConverterOptionString.write(value.orderId, into: &buf) + FfiConverterOptionTypeIGiftOrder.write(value.order, into: &buf) + FfiConverterOptionString.write(value.bolt11PaymentId, into: &buf) + FfiConverterOptionTypeIGiftPayment.write(value.bolt11Payment, into: &buf) + FfiConverterOptionString.write(value.appliedGiftCodeId, into: &buf) + FfiConverterOptionTypeIGiftCode.write(value.appliedGiftCode, into: &buf) + FfiConverterOptionString.write(value.createdAt, into: &buf) + FfiConverterOptionString.write(value.updatedAt, into: &buf) } } @@ -4191,87 +4536,143 @@ public struct FfiConverterTypeIBtOnchainTransaction: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtOnchainTransaction_lift(_ buf: RustBuffer) throws -> IBtOnchainTransaction { - return try FfiConverterTypeIBtOnchainTransaction.lift(buf) +public func FfiConverterTypeIGift_lift(_ buf: RustBuffer) throws -> IGift { + return try FfiConverterTypeIGift.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtOnchainTransaction_lower(_ value: IBtOnchainTransaction) -> RustBuffer { - return FfiConverterTypeIBtOnchainTransaction.lower(value) +public func FfiConverterTypeIGift_lower(_ value: IGift) -> RustBuffer { + return FfiConverterTypeIGift.lower(value) } -public struct IBtOnchainTransactions { - public var address: String - public var confirmedSat: UInt64 - public var requiredConfirmations: UInt32 - public var transactions: [IBtOnchainTransaction] +public struct IGiftBolt11Invoice { + public var id: String + public var request: String + public var state: String + public var isHodlInvoice: Bool? + public var paymentHash: String? + public var amountSat: UInt64? + public var amountMsat: String? + public var internalNodePubkey: String? + public var updatedAt: String? + public var createdAt: String? + public var expiresAt: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(address: String, confirmedSat: UInt64, requiredConfirmations: UInt32, transactions: [IBtOnchainTransaction]) { - self.address = address - self.confirmedSat = confirmedSat - self.requiredConfirmations = requiredConfirmations - self.transactions = transactions + public init(id: String, request: String, state: String, isHodlInvoice: Bool?, paymentHash: String?, amountSat: UInt64?, amountMsat: String?, internalNodePubkey: String?, updatedAt: String?, createdAt: String?, expiresAt: String?) { + self.id = id + self.request = request + self.state = state + self.isHodlInvoice = isHodlInvoice + self.paymentHash = paymentHash + self.amountSat = amountSat + self.amountMsat = amountMsat + self.internalNodePubkey = internalNodePubkey + self.updatedAt = updatedAt + self.createdAt = createdAt + self.expiresAt = expiresAt } } #if compiler(>=6) -extension IBtOnchainTransactions: Sendable {} +extension IGiftBolt11Invoice: Sendable {} #endif -extension IBtOnchainTransactions: Equatable, Hashable { - public static func ==(lhs: IBtOnchainTransactions, rhs: IBtOnchainTransactions) -> Bool { - if lhs.address != rhs.address { +extension IGiftBolt11Invoice: Equatable, Hashable { + public static func ==(lhs: IGiftBolt11Invoice, rhs: IGiftBolt11Invoice) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.confirmedSat != rhs.confirmedSat { + if lhs.request != rhs.request { return false } - if lhs.requiredConfirmations != rhs.requiredConfirmations { + if lhs.state != rhs.state { return false } - if lhs.transactions != rhs.transactions { + if lhs.isHodlInvoice != rhs.isHodlInvoice { + return false + } + if lhs.paymentHash != rhs.paymentHash { + return false + } + if lhs.amountSat != rhs.amountSat { + return false + } + if lhs.amountMsat != rhs.amountMsat { + return false + } + if lhs.internalNodePubkey != rhs.internalNodePubkey { + return false + } + if lhs.updatedAt != rhs.updatedAt { + return false + } + if lhs.createdAt != rhs.createdAt { + return false + } + if lhs.expiresAt != rhs.expiresAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(confirmedSat) - hasher.combine(requiredConfirmations) - hasher.combine(transactions) + hasher.combine(id) + hasher.combine(request) + hasher.combine(state) + hasher.combine(isHodlInvoice) + hasher.combine(paymentHash) + hasher.combine(amountSat) + hasher.combine(amountMsat) + hasher.combine(internalNodePubkey) + hasher.combine(updatedAt) + hasher.combine(createdAt) + hasher.combine(expiresAt) } } -extension IBtOnchainTransactions: Codable {} +extension IGiftBolt11Invoice: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtOnchainTransactions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtOnchainTransactions { +public struct FfiConverterTypeIGiftBolt11Invoice: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftBolt11Invoice { return - try IBtOnchainTransactions( - address: FfiConverterString.read(from: &buf), - confirmedSat: FfiConverterUInt64.read(from: &buf), - requiredConfirmations: FfiConverterUInt32.read(from: &buf), - transactions: FfiConverterSequenceTypeIBtOnchainTransaction.read(from: &buf) + try IGiftBolt11Invoice( + id: FfiConverterString.read(from: &buf), + request: FfiConverterString.read(from: &buf), + state: FfiConverterString.read(from: &buf), + isHodlInvoice: FfiConverterOptionBool.read(from: &buf), + paymentHash: FfiConverterOptionString.read(from: &buf), + amountSat: FfiConverterOptionUInt64.read(from: &buf), + amountMsat: FfiConverterOptionString.read(from: &buf), + internalNodePubkey: FfiConverterOptionString.read(from: &buf), + updatedAt: FfiConverterOptionString.read(from: &buf), + createdAt: FfiConverterOptionString.read(from: &buf), + expiresAt: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: IBtOnchainTransactions, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterUInt64.write(value.confirmedSat, into: &buf) - FfiConverterUInt32.write(value.requiredConfirmations, into: &buf) - FfiConverterSequenceTypeIBtOnchainTransaction.write(value.transactions, into: &buf) + public static func write(_ value: IGiftBolt11Invoice, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.request, into: &buf) + FfiConverterString.write(value.state, into: &buf) + FfiConverterOptionBool.write(value.isHodlInvoice, into: &buf) + FfiConverterOptionString.write(value.paymentHash, into: &buf) + FfiConverterOptionUInt64.write(value.amountSat, into: &buf) + FfiConverterOptionString.write(value.amountMsat, into: &buf) + FfiConverterOptionString.write(value.internalNodePubkey, into: &buf) + FfiConverterOptionString.write(value.updatedAt, into: &buf) + FfiConverterOptionString.write(value.createdAt, into: &buf) + FfiConverterOptionString.write(value.expiresAt, into: &buf) } } @@ -4279,140 +4680,70 @@ public struct FfiConverterTypeIBtOnchainTransactions: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtOnchainTransactions_lift(_ buf: RustBuffer) throws -> IBtOnchainTransactions { - return try FfiConverterTypeIBtOnchainTransactions.lift(buf) +public func FfiConverterTypeIGiftBolt11Invoice_lift(_ buf: RustBuffer) throws -> IGiftBolt11Invoice { + return try FfiConverterTypeIGiftBolt11Invoice.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtOnchainTransactions_lower(_ value: IBtOnchainTransactions) -> RustBuffer { - return FfiConverterTypeIBtOnchainTransactions.lower(value) +public func FfiConverterTypeIGiftBolt11Invoice_lower(_ value: IGiftBolt11Invoice) -> RustBuffer { + return FfiConverterTypeIGiftBolt11Invoice.lower(value) } -public struct IBtOrder { +public struct IGiftBtcAddress { public var id: String - public var state: BtOrderState - public var state2: BtOrderState2? - public var feeSat: UInt64 - public var networkFeeSat: UInt64 - public var serviceFeeSat: UInt64 - public var lspBalanceSat: UInt64 - public var clientBalanceSat: UInt64 - public var zeroConf: Bool - public var zeroReserve: Bool - public var clientNodeId: String? - public var channelExpiryWeeks: UInt32 - public var channelExpiresAt: String - public var orderExpiresAt: String - public var channel: IBtChannel? - public var lspNode: ILspNode? - public var lnurl: String? - public var payment: IBtPayment? - public var couponCode: String? - public var source: String? - public var discount: IDiscount? - public var updatedAt: String - public var createdAt: String + public var address: String + public var transactions: [String] + public var allTransactions: [String] + public var isBlacklisted: Bool? + public var watchUntil: String? + public var watchForBlockConfirmations: UInt32? + public var updatedAt: String? + public var createdAt: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, state: BtOrderState, state2: BtOrderState2?, feeSat: UInt64, networkFeeSat: UInt64, serviceFeeSat: UInt64, lspBalanceSat: UInt64, clientBalanceSat: UInt64, zeroConf: Bool, zeroReserve: Bool, clientNodeId: String?, channelExpiryWeeks: UInt32, channelExpiresAt: String, orderExpiresAt: String, channel: IBtChannel?, lspNode: ILspNode?, lnurl: String?, payment: IBtPayment?, couponCode: String?, source: String?, discount: IDiscount?, updatedAt: String, createdAt: String) { + public init(id: String, address: String, transactions: [String], allTransactions: [String], isBlacklisted: Bool?, watchUntil: String?, watchForBlockConfirmations: UInt32?, updatedAt: String?, createdAt: String?) { self.id = id - self.state = state - self.state2 = state2 - self.feeSat = feeSat - self.networkFeeSat = networkFeeSat - self.serviceFeeSat = serviceFeeSat - self.lspBalanceSat = lspBalanceSat - self.clientBalanceSat = clientBalanceSat - self.zeroConf = zeroConf - self.zeroReserve = zeroReserve - self.clientNodeId = clientNodeId - self.channelExpiryWeeks = channelExpiryWeeks - self.channelExpiresAt = channelExpiresAt - self.orderExpiresAt = orderExpiresAt - self.channel = channel - self.lspNode = lspNode - self.lnurl = lnurl - self.payment = payment - self.couponCode = couponCode - self.source = source - self.discount = discount + self.address = address + self.transactions = transactions + self.allTransactions = allTransactions + self.isBlacklisted = isBlacklisted + self.watchUntil = watchUntil + self.watchForBlockConfirmations = watchForBlockConfirmations self.updatedAt = updatedAt self.createdAt = createdAt } } #if compiler(>=6) -extension IBtOrder: Sendable {} +extension IGiftBtcAddress: Sendable {} #endif -extension IBtOrder: Equatable, Hashable { - public static func ==(lhs: IBtOrder, rhs: IBtOrder) -> Bool { +extension IGiftBtcAddress: Equatable, Hashable { + public static func ==(lhs: IGiftBtcAddress, rhs: IGiftBtcAddress) -> Bool { if lhs.id != rhs.id { return false } - if lhs.state != rhs.state { - return false - } - if lhs.state2 != rhs.state2 { - return false - } - if lhs.feeSat != rhs.feeSat { - return false - } - if lhs.networkFeeSat != rhs.networkFeeSat { - return false - } - if lhs.serviceFeeSat != rhs.serviceFeeSat { - return false - } - if lhs.lspBalanceSat != rhs.lspBalanceSat { - return false - } - if lhs.clientBalanceSat != rhs.clientBalanceSat { - return false - } - if lhs.zeroConf != rhs.zeroConf { - return false - } - if lhs.zeroReserve != rhs.zeroReserve { - return false - } - if lhs.clientNodeId != rhs.clientNodeId { - return false - } - if lhs.channelExpiryWeeks != rhs.channelExpiryWeeks { - return false - } - if lhs.channelExpiresAt != rhs.channelExpiresAt { - return false - } - if lhs.orderExpiresAt != rhs.orderExpiresAt { - return false - } - if lhs.channel != rhs.channel { - return false - } - if lhs.lspNode != rhs.lspNode { + if lhs.address != rhs.address { return false } - if lhs.lnurl != rhs.lnurl { + if lhs.transactions != rhs.transactions { return false } - if lhs.payment != rhs.payment { + if lhs.allTransactions != rhs.allTransactions { return false } - if lhs.couponCode != rhs.couponCode { + if lhs.isBlacklisted != rhs.isBlacklisted { return false } - if lhs.source != rhs.source { + if lhs.watchUntil != rhs.watchUntil { return false } - if lhs.discount != rhs.discount { + if lhs.watchForBlockConfirmations != rhs.watchForBlockConfirmations { return false } if lhs.updatedAt != rhs.updatedAt { @@ -4426,92 +4757,50 @@ extension IBtOrder: Equatable, Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(id) - hasher.combine(state) - hasher.combine(state2) - hasher.combine(feeSat) - hasher.combine(networkFeeSat) - hasher.combine(serviceFeeSat) - hasher.combine(lspBalanceSat) - hasher.combine(clientBalanceSat) - hasher.combine(zeroConf) - hasher.combine(zeroReserve) - hasher.combine(clientNodeId) - hasher.combine(channelExpiryWeeks) - hasher.combine(channelExpiresAt) - hasher.combine(orderExpiresAt) - hasher.combine(channel) - hasher.combine(lspNode) - hasher.combine(lnurl) - hasher.combine(payment) - hasher.combine(couponCode) - hasher.combine(source) - hasher.combine(discount) + hasher.combine(address) + hasher.combine(transactions) + hasher.combine(allTransactions) + hasher.combine(isBlacklisted) + hasher.combine(watchUntil) + hasher.combine(watchForBlockConfirmations) hasher.combine(updatedAt) hasher.combine(createdAt) } } -extension IBtOrder: Codable {} +extension IGiftBtcAddress: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtOrder: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtOrder { +public struct FfiConverterTypeIGiftBtcAddress: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftBtcAddress { return - try IBtOrder( + try IGiftBtcAddress( id: FfiConverterString.read(from: &buf), - state: FfiConverterTypeBtOrderState.read(from: &buf), - state2: FfiConverterOptionTypeBtOrderState2.read(from: &buf), - feeSat: FfiConverterUInt64.read(from: &buf), - networkFeeSat: FfiConverterUInt64.read(from: &buf), - serviceFeeSat: FfiConverterUInt64.read(from: &buf), - lspBalanceSat: FfiConverterUInt64.read(from: &buf), - clientBalanceSat: FfiConverterUInt64.read(from: &buf), - zeroConf: FfiConverterBool.read(from: &buf), - zeroReserve: FfiConverterBool.read(from: &buf), - clientNodeId: FfiConverterOptionString.read(from: &buf), - channelExpiryWeeks: FfiConverterUInt32.read(from: &buf), - channelExpiresAt: FfiConverterString.read(from: &buf), - orderExpiresAt: FfiConverterString.read(from: &buf), - channel: FfiConverterOptionTypeIBtChannel.read(from: &buf), - lspNode: FfiConverterOptionTypeILspNode.read(from: &buf), - lnurl: FfiConverterOptionString.read(from: &buf), - payment: FfiConverterOptionTypeIBtPayment.read(from: &buf), - couponCode: FfiConverterOptionString.read(from: &buf), - source: FfiConverterOptionString.read(from: &buf), - discount: FfiConverterOptionTypeIDiscount.read(from: &buf), - updatedAt: FfiConverterString.read(from: &buf), - createdAt: FfiConverterString.read(from: &buf) + address: FfiConverterString.read(from: &buf), + transactions: FfiConverterSequenceString.read(from: &buf), + allTransactions: FfiConverterSequenceString.read(from: &buf), + isBlacklisted: FfiConverterOptionBool.read(from: &buf), + watchUntil: FfiConverterOptionString.read(from: &buf), + watchForBlockConfirmations: FfiConverterOptionUInt32.read(from: &buf), + updatedAt: FfiConverterOptionString.read(from: &buf), + createdAt: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: IBtOrder, into buf: inout [UInt8]) { + public static func write(_ value: IGiftBtcAddress, into buf: inout [UInt8]) { FfiConverterString.write(value.id, into: &buf) - FfiConverterTypeBtOrderState.write(value.state, into: &buf) - FfiConverterOptionTypeBtOrderState2.write(value.state2, into: &buf) - FfiConverterUInt64.write(value.feeSat, into: &buf) - FfiConverterUInt64.write(value.networkFeeSat, into: &buf) - FfiConverterUInt64.write(value.serviceFeeSat, into: &buf) - FfiConverterUInt64.write(value.lspBalanceSat, into: &buf) - FfiConverterUInt64.write(value.clientBalanceSat, into: &buf) - FfiConverterBool.write(value.zeroConf, into: &buf) - FfiConverterBool.write(value.zeroReserve, into: &buf) - FfiConverterOptionString.write(value.clientNodeId, into: &buf) - FfiConverterUInt32.write(value.channelExpiryWeeks, into: &buf) - FfiConverterString.write(value.channelExpiresAt, into: &buf) - FfiConverterString.write(value.orderExpiresAt, into: &buf) - FfiConverterOptionTypeIBtChannel.write(value.channel, into: &buf) - FfiConverterOptionTypeILspNode.write(value.lspNode, into: &buf) - FfiConverterOptionString.write(value.lnurl, into: &buf) - FfiConverterOptionTypeIBtPayment.write(value.payment, into: &buf) - FfiConverterOptionString.write(value.couponCode, into: &buf) - FfiConverterOptionString.write(value.source, into: &buf) - FfiConverterOptionTypeIDiscount.write(value.discount, into: &buf) - FfiConverterString.write(value.updatedAt, into: &buf) - FfiConverterString.write(value.createdAt, into: &buf) + FfiConverterString.write(value.address, into: &buf) + FfiConverterSequenceString.write(value.transactions, into: &buf) + FfiConverterSequenceString.write(value.allTransactions, into: &buf) + FfiConverterOptionBool.write(value.isBlacklisted, into: &buf) + FfiConverterOptionString.write(value.watchUntil, into: &buf) + FfiConverterOptionUInt32.write(value.watchForBlockConfirmations, into: &buf) + FfiConverterOptionString.write(value.updatedAt, into: &buf) + FfiConverterOptionString.write(value.createdAt, into: &buf) } } @@ -4519,111 +4808,119 @@ public struct FfiConverterTypeIBtOrder: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtOrder_lift(_ buf: RustBuffer) throws -> IBtOrder { - return try FfiConverterTypeIBtOrder.lift(buf) +public func FfiConverterTypeIGiftBtcAddress_lift(_ buf: RustBuffer) throws -> IGiftBtcAddress { + return try FfiConverterTypeIGiftBtcAddress.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtOrder_lower(_ value: IBtOrder) -> RustBuffer { - return FfiConverterTypeIBtOrder.lower(value) +public func FfiConverterTypeIGiftBtcAddress_lower(_ value: IGiftBtcAddress) -> RustBuffer { + return FfiConverterTypeIGiftBtcAddress.lower(value) } -public struct IBtPayment { - public var state: BtPaymentState - public var state2: BtPaymentState2? - public var paidSat: UInt64 - public var bolt11Invoice: IBtBolt11Invoice? - public var onchain: IBtOnchainTransactions? - public var isManuallyPaid: Bool? - public var manualRefunds: [IManualRefund]? +public struct IGiftCode { + public var id: String + public var code: String + public var createdAt: String + public var updatedAt: String + public var expiresAt: String + public var giftSat: UInt64? + public var scope: String? + public var maxCount: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(state: BtPaymentState, state2: BtPaymentState2?, paidSat: UInt64, bolt11Invoice: IBtBolt11Invoice?, onchain: IBtOnchainTransactions?, isManuallyPaid: Bool?, manualRefunds: [IManualRefund]?) { - self.state = state - self.state2 = state2 - self.paidSat = paidSat - self.bolt11Invoice = bolt11Invoice - self.onchain = onchain - self.isManuallyPaid = isManuallyPaid - self.manualRefunds = manualRefunds + public init(id: String, code: String, createdAt: String, updatedAt: String, expiresAt: String, giftSat: UInt64?, scope: String?, maxCount: UInt32?) { + self.id = id + self.code = code + self.createdAt = createdAt + self.updatedAt = updatedAt + self.expiresAt = expiresAt + self.giftSat = giftSat + self.scope = scope + self.maxCount = maxCount } } #if compiler(>=6) -extension IBtPayment: Sendable {} +extension IGiftCode: Sendable {} #endif -extension IBtPayment: Equatable, Hashable { - public static func ==(lhs: IBtPayment, rhs: IBtPayment) -> Bool { - if lhs.state != rhs.state { +extension IGiftCode: Equatable, Hashable { + public static func ==(lhs: IGiftCode, rhs: IGiftCode) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.state2 != rhs.state2 { + if lhs.code != rhs.code { return false } - if lhs.paidSat != rhs.paidSat { + if lhs.createdAt != rhs.createdAt { return false } - if lhs.bolt11Invoice != rhs.bolt11Invoice { + if lhs.updatedAt != rhs.updatedAt { return false } - if lhs.onchain != rhs.onchain { + if lhs.expiresAt != rhs.expiresAt { return false } - if lhs.isManuallyPaid != rhs.isManuallyPaid { + if lhs.giftSat != rhs.giftSat { return false } - if lhs.manualRefunds != rhs.manualRefunds { + if lhs.scope != rhs.scope { + return false + } + if lhs.maxCount != rhs.maxCount { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(state) - hasher.combine(state2) - hasher.combine(paidSat) - hasher.combine(bolt11Invoice) - hasher.combine(onchain) - hasher.combine(isManuallyPaid) - hasher.combine(manualRefunds) + hasher.combine(id) + hasher.combine(code) + hasher.combine(createdAt) + hasher.combine(updatedAt) + hasher.combine(expiresAt) + hasher.combine(giftSat) + hasher.combine(scope) + hasher.combine(maxCount) } } -extension IBtPayment: Codable {} +extension IGiftCode: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIBtPayment: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IBtPayment { +public struct FfiConverterTypeIGiftCode: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftCode { return - try IBtPayment( - state: FfiConverterTypeBtPaymentState.read(from: &buf), - state2: FfiConverterOptionTypeBtPaymentState2.read(from: &buf), - paidSat: FfiConverterUInt64.read(from: &buf), - bolt11Invoice: FfiConverterOptionTypeIBtBolt11Invoice.read(from: &buf), - onchain: FfiConverterOptionTypeIBtOnchainTransactions.read(from: &buf), - isManuallyPaid: FfiConverterOptionBool.read(from: &buf), - manualRefunds: FfiConverterOptionSequenceTypeIManualRefund.read(from: &buf) + try IGiftCode( + id: FfiConverterString.read(from: &buf), + code: FfiConverterString.read(from: &buf), + createdAt: FfiConverterString.read(from: &buf), + updatedAt: FfiConverterString.read(from: &buf), + expiresAt: FfiConverterString.read(from: &buf), + giftSat: FfiConverterOptionUInt64.read(from: &buf), + scope: FfiConverterOptionString.read(from: &buf), + maxCount: FfiConverterOptionUInt32.read(from: &buf) ) } - public static func write(_ value: IBtPayment, into buf: inout [UInt8]) { - FfiConverterTypeBtPaymentState.write(value.state, into: &buf) - FfiConverterOptionTypeBtPaymentState2.write(value.state2, into: &buf) - FfiConverterUInt64.write(value.paidSat, into: &buf) - FfiConverterOptionTypeIBtBolt11Invoice.write(value.bolt11Invoice, into: &buf) - FfiConverterOptionTypeIBtOnchainTransactions.write(value.onchain, into: &buf) - FfiConverterOptionBool.write(value.isManuallyPaid, into: &buf) - FfiConverterOptionSequenceTypeIManualRefund.write(value.manualRefunds, into: &buf) + public static func write(_ value: IGiftCode, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.code, into: &buf) + FfiConverterString.write(value.createdAt, into: &buf) + FfiConverterString.write(value.updatedAt, into: &buf) + FfiConverterString.write(value.expiresAt, into: &buf) + FfiConverterOptionUInt64.write(value.giftSat, into: &buf) + FfiConverterOptionString.write(value.scope, into: &buf) + FfiConverterOptionUInt32.write(value.maxCount, into: &buf) } } @@ -4631,199 +4928,79 @@ public struct FfiConverterTypeIBtPayment: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtPayment_lift(_ buf: RustBuffer) throws -> IBtPayment { - return try FfiConverterTypeIBtPayment.lift(buf) +public func FfiConverterTypeIGiftCode_lift(_ buf: RustBuffer) throws -> IGiftCode { + return try FfiConverterTypeIGiftCode.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIBtPayment_lower(_ value: IBtPayment) -> RustBuffer { - return FfiConverterTypeIBtPayment.lower(value) +public func FfiConverterTypeIGiftCode_lower(_ value: IGiftCode) -> RustBuffer { + return FfiConverterTypeIGiftCode.lower(value) } -public struct IcJitEntry { - public var id: String - public var state: CJitStateEnum - public var feeSat: UInt64 - public var networkFeeSat: UInt64 - public var serviceFeeSat: UInt64 - public var channelSizeSat: UInt64 - public var channelExpiryWeeks: UInt32 - public var channelOpenError: String? - public var nodeId: String - public var invoice: IBtBolt11Invoice - public var channel: IBtChannel? - public var lspNode: ILspNode - public var couponCode: String - public var source: String? - public var discount: IDiscount? - public var expiresAt: String - public var updatedAt: String - public var createdAt: String +public struct IGiftLspNode { + public var alias: String + public var pubkey: String + public var connectionStrings: [String] // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, state: CJitStateEnum, feeSat: UInt64, networkFeeSat: UInt64, serviceFeeSat: UInt64, channelSizeSat: UInt64, channelExpiryWeeks: UInt32, channelOpenError: String?, nodeId: String, invoice: IBtBolt11Invoice, channel: IBtChannel?, lspNode: ILspNode, couponCode: String, source: String?, discount: IDiscount?, expiresAt: String, updatedAt: String, createdAt: String) { - self.id = id - self.state = state - self.feeSat = feeSat - self.networkFeeSat = networkFeeSat - self.serviceFeeSat = serviceFeeSat - self.channelSizeSat = channelSizeSat - self.channelExpiryWeeks = channelExpiryWeeks - self.channelOpenError = channelOpenError - self.nodeId = nodeId - self.invoice = invoice - self.channel = channel - self.lspNode = lspNode - self.couponCode = couponCode - self.source = source - self.discount = discount - self.expiresAt = expiresAt - self.updatedAt = updatedAt - self.createdAt = createdAt + public init(alias: String, pubkey: String, connectionStrings: [String]) { + self.alias = alias + self.pubkey = pubkey + self.connectionStrings = connectionStrings } } #if compiler(>=6) -extension IcJitEntry: Sendable {} +extension IGiftLspNode: Sendable {} #endif -extension IcJitEntry: Equatable, Hashable { - public static func ==(lhs: IcJitEntry, rhs: IcJitEntry) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.state != rhs.state { - return false - } - if lhs.feeSat != rhs.feeSat { - return false - } - if lhs.networkFeeSat != rhs.networkFeeSat { - return false - } - if lhs.serviceFeeSat != rhs.serviceFeeSat { - return false - } - if lhs.channelSizeSat != rhs.channelSizeSat { - return false - } - if lhs.channelExpiryWeeks != rhs.channelExpiryWeeks { - return false - } - if lhs.channelOpenError != rhs.channelOpenError { - return false - } - if lhs.nodeId != rhs.nodeId { +extension IGiftLspNode: Equatable, Hashable { + public static func ==(lhs: IGiftLspNode, rhs: IGiftLspNode) -> Bool { + if lhs.alias != rhs.alias { return false } - if lhs.invoice != rhs.invoice { + if lhs.pubkey != rhs.pubkey { return false } - if lhs.channel != rhs.channel { - return false - } - if lhs.lspNode != rhs.lspNode { - return false - } - if lhs.couponCode != rhs.couponCode { - return false - } - if lhs.source != rhs.source { - return false - } - if lhs.discount != rhs.discount { - return false - } - if lhs.expiresAt != rhs.expiresAt { - return false - } - if lhs.updatedAt != rhs.updatedAt { - return false - } - if lhs.createdAt != rhs.createdAt { + if lhs.connectionStrings != rhs.connectionStrings { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(state) - hasher.combine(feeSat) - hasher.combine(networkFeeSat) - hasher.combine(serviceFeeSat) - hasher.combine(channelSizeSat) - hasher.combine(channelExpiryWeeks) - hasher.combine(channelOpenError) - hasher.combine(nodeId) - hasher.combine(invoice) - hasher.combine(channel) - hasher.combine(lspNode) - hasher.combine(couponCode) - hasher.combine(source) - hasher.combine(discount) - hasher.combine(expiresAt) - hasher.combine(updatedAt) - hasher.combine(createdAt) + hasher.combine(alias) + hasher.combine(pubkey) + hasher.combine(connectionStrings) } } -extension IcJitEntry: Codable {} +extension IGiftLspNode: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeICJitEntry: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IcJitEntry { +public struct FfiConverterTypeIGiftLspNode: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftLspNode { return - try IcJitEntry( - id: FfiConverterString.read(from: &buf), - state: FfiConverterTypeCJitStateEnum.read(from: &buf), - feeSat: FfiConverterUInt64.read(from: &buf), - networkFeeSat: FfiConverterUInt64.read(from: &buf), - serviceFeeSat: FfiConverterUInt64.read(from: &buf), - channelSizeSat: FfiConverterUInt64.read(from: &buf), - channelExpiryWeeks: FfiConverterUInt32.read(from: &buf), - channelOpenError: FfiConverterOptionString.read(from: &buf), - nodeId: FfiConverterString.read(from: &buf), - invoice: FfiConverterTypeIBtBolt11Invoice.read(from: &buf), - channel: FfiConverterOptionTypeIBtChannel.read(from: &buf), - lspNode: FfiConverterTypeILspNode.read(from: &buf), - couponCode: FfiConverterString.read(from: &buf), - source: FfiConverterOptionString.read(from: &buf), - discount: FfiConverterOptionTypeIDiscount.read(from: &buf), - expiresAt: FfiConverterString.read(from: &buf), - updatedAt: FfiConverterString.read(from: &buf), - createdAt: FfiConverterString.read(from: &buf) + try IGiftLspNode( + alias: FfiConverterString.read(from: &buf), + pubkey: FfiConverterString.read(from: &buf), + connectionStrings: FfiConverterSequenceString.read(from: &buf) ) } - public static func write(_ value: IcJitEntry, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterTypeCJitStateEnum.write(value.state, into: &buf) - FfiConverterUInt64.write(value.feeSat, into: &buf) - FfiConverterUInt64.write(value.networkFeeSat, into: &buf) - FfiConverterUInt64.write(value.serviceFeeSat, into: &buf) - FfiConverterUInt64.write(value.channelSizeSat, into: &buf) - FfiConverterUInt32.write(value.channelExpiryWeeks, into: &buf) - FfiConverterOptionString.write(value.channelOpenError, into: &buf) - FfiConverterString.write(value.nodeId, into: &buf) - FfiConverterTypeIBtBolt11Invoice.write(value.invoice, into: &buf) - FfiConverterOptionTypeIBtChannel.write(value.channel, into: &buf) - FfiConverterTypeILspNode.write(value.lspNode, into: &buf) - FfiConverterString.write(value.couponCode, into: &buf) - FfiConverterOptionString.write(value.source, into: &buf) - FfiConverterOptionTypeIDiscount.write(value.discount, into: &buf) - FfiConverterString.write(value.expiresAt, into: &buf) - FfiConverterString.write(value.updatedAt, into: &buf) - FfiConverterString.write(value.createdAt, into: &buf) + public static func write(_ value: IGiftLspNode, into buf: inout [UInt8]) { + FfiConverterString.write(value.alias, into: &buf) + FfiConverterString.write(value.pubkey, into: &buf) + FfiConverterSequenceString.write(value.connectionStrings, into: &buf) } } @@ -4831,87 +5008,231 @@ public struct FfiConverterTypeICJitEntry: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeICJitEntry_lift(_ buf: RustBuffer) throws -> IcJitEntry { - return try FfiConverterTypeICJitEntry.lift(buf) +public func FfiConverterTypeIGiftLspNode_lift(_ buf: RustBuffer) throws -> IGiftLspNode { + return try FfiConverterTypeIGiftLspNode.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeICJitEntry_lower(_ value: IcJitEntry) -> RustBuffer { - return FfiConverterTypeICJitEntry.lower(value) +public func FfiConverterTypeIGiftLspNode_lower(_ value: IGiftLspNode) -> RustBuffer { + return FfiConverterTypeIGiftLspNode.lower(value) } -public struct IDiscount { - public var code: String - public var absoluteSat: UInt64 - public var relative: Double - public var overallSat: UInt64 +public struct IGiftOrder { + public var id: String + public var state: String + public var oldState: String? + public var isChannelExpired: Bool? + public var isOrderExpired: Bool? + public var lspBalanceSat: UInt64? + public var clientBalanceSat: UInt64? + public var channelExpiryWeeks: UInt32? + public var zeroConf: Bool? + public var zeroReserve: Bool? + public var announced: Bool? + public var clientNodeId: String? + public var channelExpiresAt: String? + public var orderExpiresAt: String? + public var feeSat: UInt64? + public var networkFeeSat: UInt64? + public var serviceFeeSat: UInt64? + public var payment: IGiftPayment? + public var lspNode: IGiftLspNode? + public var updatedAt: String? + public var createdAt: String? + public var nodeIdVerified: Bool? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(code: String, absoluteSat: UInt64, relative: Double, overallSat: UInt64) { - self.code = code - self.absoluteSat = absoluteSat - self.relative = relative - self.overallSat = overallSat + public init(id: String, state: String, oldState: String?, isChannelExpired: Bool?, isOrderExpired: Bool?, lspBalanceSat: UInt64?, clientBalanceSat: UInt64?, channelExpiryWeeks: UInt32?, zeroConf: Bool?, zeroReserve: Bool?, announced: Bool?, clientNodeId: String?, channelExpiresAt: String?, orderExpiresAt: String?, feeSat: UInt64?, networkFeeSat: UInt64?, serviceFeeSat: UInt64?, payment: IGiftPayment?, lspNode: IGiftLspNode?, updatedAt: String?, createdAt: String?, nodeIdVerified: Bool?) { + self.id = id + self.state = state + self.oldState = oldState + self.isChannelExpired = isChannelExpired + self.isOrderExpired = isOrderExpired + self.lspBalanceSat = lspBalanceSat + self.clientBalanceSat = clientBalanceSat + self.channelExpiryWeeks = channelExpiryWeeks + self.zeroConf = zeroConf + self.zeroReserve = zeroReserve + self.announced = announced + self.clientNodeId = clientNodeId + self.channelExpiresAt = channelExpiresAt + self.orderExpiresAt = orderExpiresAt + self.feeSat = feeSat + self.networkFeeSat = networkFeeSat + self.serviceFeeSat = serviceFeeSat + self.payment = payment + self.lspNode = lspNode + self.updatedAt = updatedAt + self.createdAt = createdAt + self.nodeIdVerified = nodeIdVerified } } #if compiler(>=6) -extension IDiscount: Sendable {} +extension IGiftOrder: Sendable {} #endif -extension IDiscount: Equatable, Hashable { - public static func ==(lhs: IDiscount, rhs: IDiscount) -> Bool { - if lhs.code != rhs.code { +extension IGiftOrder: Equatable, Hashable { + public static func ==(lhs: IGiftOrder, rhs: IGiftOrder) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.absoluteSat != rhs.absoluteSat { + if lhs.state != rhs.state { return false } - if lhs.relative != rhs.relative { + if lhs.oldState != rhs.oldState { return false } - if lhs.overallSat != rhs.overallSat { + if lhs.isChannelExpired != rhs.isChannelExpired { + return false + } + if lhs.isOrderExpired != rhs.isOrderExpired { + return false + } + if lhs.lspBalanceSat != rhs.lspBalanceSat { + return false + } + if lhs.clientBalanceSat != rhs.clientBalanceSat { + return false + } + if lhs.channelExpiryWeeks != rhs.channelExpiryWeeks { + return false + } + if lhs.zeroConf != rhs.zeroConf { + return false + } + if lhs.zeroReserve != rhs.zeroReserve { + return false + } + if lhs.announced != rhs.announced { + return false + } + if lhs.clientNodeId != rhs.clientNodeId { + return false + } + if lhs.channelExpiresAt != rhs.channelExpiresAt { + return false + } + if lhs.orderExpiresAt != rhs.orderExpiresAt { + return false + } + if lhs.feeSat != rhs.feeSat { + return false + } + if lhs.networkFeeSat != rhs.networkFeeSat { + return false + } + if lhs.serviceFeeSat != rhs.serviceFeeSat { + return false + } + if lhs.payment != rhs.payment { + return false + } + if lhs.lspNode != rhs.lspNode { + return false + } + if lhs.updatedAt != rhs.updatedAt { + return false + } + if lhs.createdAt != rhs.createdAt { + return false + } + if lhs.nodeIdVerified != rhs.nodeIdVerified { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(code) - hasher.combine(absoluteSat) - hasher.combine(relative) - hasher.combine(overallSat) + hasher.combine(id) + hasher.combine(state) + hasher.combine(oldState) + hasher.combine(isChannelExpired) + hasher.combine(isOrderExpired) + hasher.combine(lspBalanceSat) + hasher.combine(clientBalanceSat) + hasher.combine(channelExpiryWeeks) + hasher.combine(zeroConf) + hasher.combine(zeroReserve) + hasher.combine(announced) + hasher.combine(clientNodeId) + hasher.combine(channelExpiresAt) + hasher.combine(orderExpiresAt) + hasher.combine(feeSat) + hasher.combine(networkFeeSat) + hasher.combine(serviceFeeSat) + hasher.combine(payment) + hasher.combine(lspNode) + hasher.combine(updatedAt) + hasher.combine(createdAt) + hasher.combine(nodeIdVerified) } } -extension IDiscount: Codable {} +extension IGiftOrder: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIDiscount: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IDiscount { +public struct FfiConverterTypeIGiftOrder: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftOrder { return - try IDiscount( - code: FfiConverterString.read(from: &buf), - absoluteSat: FfiConverterUInt64.read(from: &buf), - relative: FfiConverterDouble.read(from: &buf), - overallSat: FfiConverterUInt64.read(from: &buf) + try IGiftOrder( + id: FfiConverterString.read(from: &buf), + state: FfiConverterString.read(from: &buf), + oldState: FfiConverterOptionString.read(from: &buf), + isChannelExpired: FfiConverterOptionBool.read(from: &buf), + isOrderExpired: FfiConverterOptionBool.read(from: &buf), + lspBalanceSat: FfiConverterOptionUInt64.read(from: &buf), + clientBalanceSat: FfiConverterOptionUInt64.read(from: &buf), + channelExpiryWeeks: FfiConverterOptionUInt32.read(from: &buf), + zeroConf: FfiConverterOptionBool.read(from: &buf), + zeroReserve: FfiConverterOptionBool.read(from: &buf), + announced: FfiConverterOptionBool.read(from: &buf), + clientNodeId: FfiConverterOptionString.read(from: &buf), + channelExpiresAt: FfiConverterOptionString.read(from: &buf), + orderExpiresAt: FfiConverterOptionString.read(from: &buf), + feeSat: FfiConverterOptionUInt64.read(from: &buf), + networkFeeSat: FfiConverterOptionUInt64.read(from: &buf), + serviceFeeSat: FfiConverterOptionUInt64.read(from: &buf), + payment: FfiConverterOptionTypeIGiftPayment.read(from: &buf), + lspNode: FfiConverterOptionTypeIGiftLspNode.read(from: &buf), + updatedAt: FfiConverterOptionString.read(from: &buf), + createdAt: FfiConverterOptionString.read(from: &buf), + nodeIdVerified: FfiConverterOptionBool.read(from: &buf) ) } - public static func write(_ value: IDiscount, into buf: inout [UInt8]) { - FfiConverterString.write(value.code, into: &buf) - FfiConverterUInt64.write(value.absoluteSat, into: &buf) - FfiConverterDouble.write(value.relative, into: &buf) - FfiConverterUInt64.write(value.overallSat, into: &buf) + public static func write(_ value: IGiftOrder, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.state, into: &buf) + FfiConverterOptionString.write(value.oldState, into: &buf) + FfiConverterOptionBool.write(value.isChannelExpired, into: &buf) + FfiConverterOptionBool.write(value.isOrderExpired, into: &buf) + FfiConverterOptionUInt64.write(value.lspBalanceSat, into: &buf) + FfiConverterOptionUInt64.write(value.clientBalanceSat, into: &buf) + FfiConverterOptionUInt32.write(value.channelExpiryWeeks, into: &buf) + FfiConverterOptionBool.write(value.zeroConf, into: &buf) + FfiConverterOptionBool.write(value.zeroReserve, into: &buf) + FfiConverterOptionBool.write(value.announced, into: &buf) + FfiConverterOptionString.write(value.clientNodeId, into: &buf) + FfiConverterOptionString.write(value.channelExpiresAt, into: &buf) + FfiConverterOptionString.write(value.orderExpiresAt, into: &buf) + FfiConverterOptionUInt64.write(value.feeSat, into: &buf) + FfiConverterOptionUInt64.write(value.networkFeeSat, into: &buf) + FfiConverterOptionUInt64.write(value.serviceFeeSat, into: &buf) + FfiConverterOptionTypeIGiftPayment.write(value.payment, into: &buf) + FfiConverterOptionTypeIGiftLspNode.write(value.lspNode, into: &buf) + FfiConverterOptionString.write(value.updatedAt, into: &buf) + FfiConverterOptionString.write(value.createdAt, into: &buf) + FfiConverterOptionBool.write(value.nodeIdVerified, into: &buf) } } @@ -4919,81 +5240,131 @@ public struct FfiConverterTypeIDiscount: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIDiscount_lift(_ buf: RustBuffer) throws -> IDiscount { - return try FfiConverterTypeIDiscount.lift(buf) +public func FfiConverterTypeIGiftOrder_lift(_ buf: RustBuffer) throws -> IGiftOrder { + return try FfiConverterTypeIGiftOrder.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIDiscount_lower(_ value: IDiscount) -> RustBuffer { - return FfiConverterTypeIDiscount.lower(value) +public func FfiConverterTypeIGiftOrder_lower(_ value: IGiftOrder) -> RustBuffer { + return FfiConverterTypeIGiftOrder.lower(value) } -public struct IGift { +public struct IGiftPayment { public var id: String - public var nodeId: String - public var orderId: String? - public var order: IGiftOrder? - public var bolt11PaymentId: String? - public var bolt11Payment: IGiftPayment? - public var appliedGiftCodeId: String? - public var appliedGiftCode: IGiftCode? - public var createdAt: String? - public var updatedAt: String? + public var state: String + public var oldState: String? + public var onchainState: String? + public var lnState: String? + public var paidOnchainSat: UInt64? + public var paidLnSat: UInt64? + public var paidSat: UInt64? + public var isOverpaid: Bool? + public var isRefunded: Bool? + public var overpaidAmountSat: UInt64? + public var requiredOnchainConfirmations: UInt32? + public var settlementState: String? + public var expectedAmountSat: UInt64? + public var isManuallyPaid: Bool? + public var btcAddress: IGiftBtcAddress? + public var btcAddressId: String? + public var bolt11Invoice: IGiftBolt11Invoice? + public var bolt11InvoiceId: String? + public var manualRefunds: [String] // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, nodeId: String, orderId: String?, order: IGiftOrder?, bolt11PaymentId: String?, bolt11Payment: IGiftPayment?, appliedGiftCodeId: String?, appliedGiftCode: IGiftCode?, createdAt: String?, updatedAt: String?) { + public init(id: String, state: String, oldState: String?, onchainState: String?, lnState: String?, paidOnchainSat: UInt64?, paidLnSat: UInt64?, paidSat: UInt64?, isOverpaid: Bool?, isRefunded: Bool?, overpaidAmountSat: UInt64?, requiredOnchainConfirmations: UInt32?, settlementState: String?, expectedAmountSat: UInt64?, isManuallyPaid: Bool?, btcAddress: IGiftBtcAddress?, btcAddressId: String?, bolt11Invoice: IGiftBolt11Invoice?, bolt11InvoiceId: String?, manualRefunds: [String]) { self.id = id - self.nodeId = nodeId - self.orderId = orderId - self.order = order - self.bolt11PaymentId = bolt11PaymentId - self.bolt11Payment = bolt11Payment - self.appliedGiftCodeId = appliedGiftCodeId - self.appliedGiftCode = appliedGiftCode - self.createdAt = createdAt - self.updatedAt = updatedAt + self.state = state + self.oldState = oldState + self.onchainState = onchainState + self.lnState = lnState + self.paidOnchainSat = paidOnchainSat + self.paidLnSat = paidLnSat + self.paidSat = paidSat + self.isOverpaid = isOverpaid + self.isRefunded = isRefunded + self.overpaidAmountSat = overpaidAmountSat + self.requiredOnchainConfirmations = requiredOnchainConfirmations + self.settlementState = settlementState + self.expectedAmountSat = expectedAmountSat + self.isManuallyPaid = isManuallyPaid + self.btcAddress = btcAddress + self.btcAddressId = btcAddressId + self.bolt11Invoice = bolt11Invoice + self.bolt11InvoiceId = bolt11InvoiceId + self.manualRefunds = manualRefunds } } #if compiler(>=6) -extension IGift: Sendable {} +extension IGiftPayment: Sendable {} #endif -extension IGift: Equatable, Hashable { - public static func ==(lhs: IGift, rhs: IGift) -> Bool { +extension IGiftPayment: Equatable, Hashable { + public static func ==(lhs: IGiftPayment, rhs: IGiftPayment) -> Bool { if lhs.id != rhs.id { return false } - if lhs.nodeId != rhs.nodeId { + if lhs.state != rhs.state { return false } - if lhs.orderId != rhs.orderId { + if lhs.oldState != rhs.oldState { return false } - if lhs.order != rhs.order { + if lhs.onchainState != rhs.onchainState { return false } - if lhs.bolt11PaymentId != rhs.bolt11PaymentId { + if lhs.lnState != rhs.lnState { return false } - if lhs.bolt11Payment != rhs.bolt11Payment { + if lhs.paidOnchainSat != rhs.paidOnchainSat { return false } - if lhs.appliedGiftCodeId != rhs.appliedGiftCodeId { + if lhs.paidLnSat != rhs.paidLnSat { return false } - if lhs.appliedGiftCode != rhs.appliedGiftCode { + if lhs.paidSat != rhs.paidSat { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.isOverpaid != rhs.isOverpaid { return false } - if lhs.updatedAt != rhs.updatedAt { + if lhs.isRefunded != rhs.isRefunded { + return false + } + if lhs.overpaidAmountSat != rhs.overpaidAmountSat { + return false + } + if lhs.requiredOnchainConfirmations != rhs.requiredOnchainConfirmations { + return false + } + if lhs.settlementState != rhs.settlementState { + return false + } + if lhs.expectedAmountSat != rhs.expectedAmountSat { + return false + } + if lhs.isManuallyPaid != rhs.isManuallyPaid { + return false + } + if lhs.btcAddress != rhs.btcAddress { + return false + } + if lhs.btcAddressId != rhs.btcAddressId { + return false + } + if lhs.bolt11Invoice != rhs.bolt11Invoice { + return false + } + if lhs.bolt11InvoiceId != rhs.bolt11InvoiceId { + return false + } + if lhs.manualRefunds != rhs.manualRefunds { return false } return true @@ -5001,197 +5372,171 @@ extension IGift: Equatable, Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(id) - hasher.combine(nodeId) - hasher.combine(orderId) - hasher.combine(order) - hasher.combine(bolt11PaymentId) - hasher.combine(bolt11Payment) - hasher.combine(appliedGiftCodeId) - hasher.combine(appliedGiftCode) - hasher.combine(createdAt) - hasher.combine(updatedAt) + hasher.combine(state) + hasher.combine(oldState) + hasher.combine(onchainState) + hasher.combine(lnState) + hasher.combine(paidOnchainSat) + hasher.combine(paidLnSat) + hasher.combine(paidSat) + hasher.combine(isOverpaid) + hasher.combine(isRefunded) + hasher.combine(overpaidAmountSat) + hasher.combine(requiredOnchainConfirmations) + hasher.combine(settlementState) + hasher.combine(expectedAmountSat) + hasher.combine(isManuallyPaid) + hasher.combine(btcAddress) + hasher.combine(btcAddressId) + hasher.combine(bolt11Invoice) + hasher.combine(bolt11InvoiceId) + hasher.combine(manualRefunds) } } -extension IGift: Codable {} +extension IGiftPayment: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIGift: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGift { +public struct FfiConverterTypeIGiftPayment: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftPayment { return - try IGift( + try IGiftPayment( id: FfiConverterString.read(from: &buf), - nodeId: FfiConverterString.read(from: &buf), - orderId: FfiConverterOptionString.read(from: &buf), - order: FfiConverterOptionTypeIGiftOrder.read(from: &buf), - bolt11PaymentId: FfiConverterOptionString.read(from: &buf), - bolt11Payment: FfiConverterOptionTypeIGiftPayment.read(from: &buf), - appliedGiftCodeId: FfiConverterOptionString.read(from: &buf), - appliedGiftCode: FfiConverterOptionTypeIGiftCode.read(from: &buf), - createdAt: FfiConverterOptionString.read(from: &buf), - updatedAt: FfiConverterOptionString.read(from: &buf) + state: FfiConverterString.read(from: &buf), + oldState: FfiConverterOptionString.read(from: &buf), + onchainState: FfiConverterOptionString.read(from: &buf), + lnState: FfiConverterOptionString.read(from: &buf), + paidOnchainSat: FfiConverterOptionUInt64.read(from: &buf), + paidLnSat: FfiConverterOptionUInt64.read(from: &buf), + paidSat: FfiConverterOptionUInt64.read(from: &buf), + isOverpaid: FfiConverterOptionBool.read(from: &buf), + isRefunded: FfiConverterOptionBool.read(from: &buf), + overpaidAmountSat: FfiConverterOptionUInt64.read(from: &buf), + requiredOnchainConfirmations: FfiConverterOptionUInt32.read(from: &buf), + settlementState: FfiConverterOptionString.read(from: &buf), + expectedAmountSat: FfiConverterOptionUInt64.read(from: &buf), + isManuallyPaid: FfiConverterOptionBool.read(from: &buf), + btcAddress: FfiConverterOptionTypeIGiftBtcAddress.read(from: &buf), + btcAddressId: FfiConverterOptionString.read(from: &buf), + bolt11Invoice: FfiConverterOptionTypeIGiftBolt11Invoice.read(from: &buf), + bolt11InvoiceId: FfiConverterOptionString.read(from: &buf), + manualRefunds: FfiConverterSequenceString.read(from: &buf) ) } - public static func write(_ value: IGift, into buf: inout [UInt8]) { + public static func write(_ value: IGiftPayment, into buf: inout [UInt8]) { FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.nodeId, into: &buf) - FfiConverterOptionString.write(value.orderId, into: &buf) - FfiConverterOptionTypeIGiftOrder.write(value.order, into: &buf) - FfiConverterOptionString.write(value.bolt11PaymentId, into: &buf) - FfiConverterOptionTypeIGiftPayment.write(value.bolt11Payment, into: &buf) - FfiConverterOptionString.write(value.appliedGiftCodeId, into: &buf) - FfiConverterOptionTypeIGiftCode.write(value.appliedGiftCode, into: &buf) - FfiConverterOptionString.write(value.createdAt, into: &buf) - FfiConverterOptionString.write(value.updatedAt, into: &buf) - } + FfiConverterString.write(value.state, into: &buf) + FfiConverterOptionString.write(value.oldState, into: &buf) + FfiConverterOptionString.write(value.onchainState, into: &buf) + FfiConverterOptionString.write(value.lnState, into: &buf) + FfiConverterOptionUInt64.write(value.paidOnchainSat, into: &buf) + FfiConverterOptionUInt64.write(value.paidLnSat, into: &buf) + FfiConverterOptionUInt64.write(value.paidSat, into: &buf) + FfiConverterOptionBool.write(value.isOverpaid, into: &buf) + FfiConverterOptionBool.write(value.isRefunded, into: &buf) + FfiConverterOptionUInt64.write(value.overpaidAmountSat, into: &buf) + FfiConverterOptionUInt32.write(value.requiredOnchainConfirmations, into: &buf) + FfiConverterOptionString.write(value.settlementState, into: &buf) + FfiConverterOptionUInt64.write(value.expectedAmountSat, into: &buf) + FfiConverterOptionBool.write(value.isManuallyPaid, into: &buf) + FfiConverterOptionTypeIGiftBtcAddress.write(value.btcAddress, into: &buf) + FfiConverterOptionString.write(value.btcAddressId, into: &buf) + FfiConverterOptionTypeIGiftBolt11Invoice.write(value.bolt11Invoice, into: &buf) + FfiConverterOptionString.write(value.bolt11InvoiceId, into: &buf) + FfiConverterSequenceString.write(value.manualRefunds, into: &buf) + } } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGift_lift(_ buf: RustBuffer) throws -> IGift { - return try FfiConverterTypeIGift.lift(buf) +public func FfiConverterTypeIGiftPayment_lift(_ buf: RustBuffer) throws -> IGiftPayment { + return try FfiConverterTypeIGiftPayment.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGift_lower(_ value: IGift) -> RustBuffer { - return FfiConverterTypeIGift.lower(value) +public func FfiConverterTypeIGiftPayment_lower(_ value: IGiftPayment) -> RustBuffer { + return FfiConverterTypeIGiftPayment.lower(value) } -public struct IGiftBolt11Invoice { - public var id: String - public var request: String - public var state: String - public var isHodlInvoice: Bool? - public var paymentHash: String? - public var amountSat: UInt64? - public var amountMsat: String? - public var internalNodePubkey: String? - public var updatedAt: String? - public var createdAt: String? - public var expiresAt: String? +public struct ILspNode { + public var alias: String + public var pubkey: String + public var connectionStrings: [String] + public var readonly: Bool? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, request: String, state: String, isHodlInvoice: Bool?, paymentHash: String?, amountSat: UInt64?, amountMsat: String?, internalNodePubkey: String?, updatedAt: String?, createdAt: String?, expiresAt: String?) { - self.id = id - self.request = request - self.state = state - self.isHodlInvoice = isHodlInvoice - self.paymentHash = paymentHash - self.amountSat = amountSat - self.amountMsat = amountMsat - self.internalNodePubkey = internalNodePubkey - self.updatedAt = updatedAt - self.createdAt = createdAt - self.expiresAt = expiresAt + public init(alias: String, pubkey: String, connectionStrings: [String], readonly: Bool?) { + self.alias = alias + self.pubkey = pubkey + self.connectionStrings = connectionStrings + self.readonly = readonly } } #if compiler(>=6) -extension IGiftBolt11Invoice: Sendable {} +extension ILspNode: Sendable {} #endif -extension IGiftBolt11Invoice: Equatable, Hashable { - public static func ==(lhs: IGiftBolt11Invoice, rhs: IGiftBolt11Invoice) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.request != rhs.request { - return false - } - if lhs.state != rhs.state { - return false - } - if lhs.isHodlInvoice != rhs.isHodlInvoice { - return false - } - if lhs.paymentHash != rhs.paymentHash { - return false - } - if lhs.amountSat != rhs.amountSat { - return false - } - if lhs.amountMsat != rhs.amountMsat { - return false - } - if lhs.internalNodePubkey != rhs.internalNodePubkey { +extension ILspNode: Equatable, Hashable { + public static func ==(lhs: ILspNode, rhs: ILspNode) -> Bool { + if lhs.alias != rhs.alias { return false } - if lhs.updatedAt != rhs.updatedAt { + if lhs.pubkey != rhs.pubkey { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.connectionStrings != rhs.connectionStrings { return false } - if lhs.expiresAt != rhs.expiresAt { + if lhs.readonly != rhs.readonly { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(request) - hasher.combine(state) - hasher.combine(isHodlInvoice) - hasher.combine(paymentHash) - hasher.combine(amountSat) - hasher.combine(amountMsat) - hasher.combine(internalNodePubkey) - hasher.combine(updatedAt) - hasher.combine(createdAt) - hasher.combine(expiresAt) + hasher.combine(alias) + hasher.combine(pubkey) + hasher.combine(connectionStrings) + hasher.combine(readonly) } } -extension IGiftBolt11Invoice: Codable {} +extension ILspNode: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIGiftBolt11Invoice: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftBolt11Invoice { +public struct FfiConverterTypeILspNode: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ILspNode { return - try IGiftBolt11Invoice( - id: FfiConverterString.read(from: &buf), - request: FfiConverterString.read(from: &buf), - state: FfiConverterString.read(from: &buf), - isHodlInvoice: FfiConverterOptionBool.read(from: &buf), - paymentHash: FfiConverterOptionString.read(from: &buf), - amountSat: FfiConverterOptionUInt64.read(from: &buf), - amountMsat: FfiConverterOptionString.read(from: &buf), - internalNodePubkey: FfiConverterOptionString.read(from: &buf), - updatedAt: FfiConverterOptionString.read(from: &buf), - createdAt: FfiConverterOptionString.read(from: &buf), - expiresAt: FfiConverterOptionString.read(from: &buf) + try ILspNode( + alias: FfiConverterString.read(from: &buf), + pubkey: FfiConverterString.read(from: &buf), + connectionStrings: FfiConverterSequenceString.read(from: &buf), + readonly: FfiConverterOptionBool.read(from: &buf) ) } - public static func write(_ value: IGiftBolt11Invoice, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.request, into: &buf) - FfiConverterString.write(value.state, into: &buf) - FfiConverterOptionBool.write(value.isHodlInvoice, into: &buf) - FfiConverterOptionString.write(value.paymentHash, into: &buf) - FfiConverterOptionUInt64.write(value.amountSat, into: &buf) - FfiConverterOptionString.write(value.amountMsat, into: &buf) - FfiConverterOptionString.write(value.internalNodePubkey, into: &buf) - FfiConverterOptionString.write(value.updatedAt, into: &buf) - FfiConverterOptionString.write(value.createdAt, into: &buf) - FfiConverterOptionString.write(value.expiresAt, into: &buf) + public static func write(_ value: ILspNode, into buf: inout [UInt8]) { + FfiConverterString.write(value.alias, into: &buf) + FfiConverterString.write(value.pubkey, into: &buf) + FfiConverterSequenceString.write(value.connectionStrings, into: &buf) + FfiConverterOptionBool.write(value.readonly, into: &buf) } } @@ -5199,127 +5544,111 @@ public struct FfiConverterTypeIGiftBolt11Invoice: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftBolt11Invoice_lift(_ buf: RustBuffer) throws -> IGiftBolt11Invoice { - return try FfiConverterTypeIGiftBolt11Invoice.lift(buf) +public func FfiConverterTypeILspNode_lift(_ buf: RustBuffer) throws -> ILspNode { + return try FfiConverterTypeILspNode.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftBolt11Invoice_lower(_ value: IGiftBolt11Invoice) -> RustBuffer { - return FfiConverterTypeIGiftBolt11Invoice.lower(value) +public func FfiConverterTypeILspNode_lower(_ value: ILspNode) -> RustBuffer { + return FfiConverterTypeILspNode.lower(value) } -public struct IGiftBtcAddress { - public var id: String - public var address: String - public var transactions: [String] - public var allTransactions: [String] - public var isBlacklisted: Bool? - public var watchUntil: String? - public var watchForBlockConfirmations: UInt32? - public var updatedAt: String? - public var createdAt: String? +public struct IManualRefund { + public var amountSat: UInt64 + public var target: String + public var state: ManualRefundStateEnum + public var createdByName: String + public var votedByName: String? + public var reason: String? + public var targetType: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, address: String, transactions: [String], allTransactions: [String], isBlacklisted: Bool?, watchUntil: String?, watchForBlockConfirmations: UInt32?, updatedAt: String?, createdAt: String?) { - self.id = id - self.address = address - self.transactions = transactions - self.allTransactions = allTransactions - self.isBlacklisted = isBlacklisted - self.watchUntil = watchUntil - self.watchForBlockConfirmations = watchForBlockConfirmations - self.updatedAt = updatedAt - self.createdAt = createdAt + public init(amountSat: UInt64, target: String, state: ManualRefundStateEnum, createdByName: String, votedByName: String?, reason: String?, targetType: String) { + self.amountSat = amountSat + self.target = target + self.state = state + self.createdByName = createdByName + self.votedByName = votedByName + self.reason = reason + self.targetType = targetType } } #if compiler(>=6) -extension IGiftBtcAddress: Sendable {} +extension IManualRefund: Sendable {} #endif -extension IGiftBtcAddress: Equatable, Hashable { - public static func ==(lhs: IGiftBtcAddress, rhs: IGiftBtcAddress) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.address != rhs.address { - return false - } - if lhs.transactions != rhs.transactions { +extension IManualRefund: Equatable, Hashable { + public static func ==(lhs: IManualRefund, rhs: IManualRefund) -> Bool { + if lhs.amountSat != rhs.amountSat { return false } - if lhs.allTransactions != rhs.allTransactions { + if lhs.target != rhs.target { return false } - if lhs.isBlacklisted != rhs.isBlacklisted { + if lhs.state != rhs.state { return false } - if lhs.watchUntil != rhs.watchUntil { + if lhs.createdByName != rhs.createdByName { return false } - if lhs.watchForBlockConfirmations != rhs.watchForBlockConfirmations { + if lhs.votedByName != rhs.votedByName { return false } - if lhs.updatedAt != rhs.updatedAt { + if lhs.reason != rhs.reason { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.targetType != rhs.targetType { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(address) - hasher.combine(transactions) - hasher.combine(allTransactions) - hasher.combine(isBlacklisted) - hasher.combine(watchUntil) - hasher.combine(watchForBlockConfirmations) - hasher.combine(updatedAt) - hasher.combine(createdAt) + hasher.combine(amountSat) + hasher.combine(target) + hasher.combine(state) + hasher.combine(createdByName) + hasher.combine(votedByName) + hasher.combine(reason) + hasher.combine(targetType) } } -extension IGiftBtcAddress: Codable {} +extension IManualRefund: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIGiftBtcAddress: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftBtcAddress { +public struct FfiConverterTypeIManualRefund: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IManualRefund { return - try IGiftBtcAddress( - id: FfiConverterString.read(from: &buf), - address: FfiConverterString.read(from: &buf), - transactions: FfiConverterSequenceString.read(from: &buf), - allTransactions: FfiConverterSequenceString.read(from: &buf), - isBlacklisted: FfiConverterOptionBool.read(from: &buf), - watchUntil: FfiConverterOptionString.read(from: &buf), - watchForBlockConfirmations: FfiConverterOptionUInt32.read(from: &buf), - updatedAt: FfiConverterOptionString.read(from: &buf), - createdAt: FfiConverterOptionString.read(from: &buf) - ) - } + try IManualRefund( + amountSat: FfiConverterUInt64.read(from: &buf), + target: FfiConverterString.read(from: &buf), + state: FfiConverterTypeManualRefundStateEnum.read(from: &buf), + createdByName: FfiConverterString.read(from: &buf), + votedByName: FfiConverterOptionString.read(from: &buf), + reason: FfiConverterOptionString.read(from: &buf), + targetType: FfiConverterString.read(from: &buf) + ) + } - public static func write(_ value: IGiftBtcAddress, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.address, into: &buf) - FfiConverterSequenceString.write(value.transactions, into: &buf) - FfiConverterSequenceString.write(value.allTransactions, into: &buf) - FfiConverterOptionBool.write(value.isBlacklisted, into: &buf) - FfiConverterOptionString.write(value.watchUntil, into: &buf) - FfiConverterOptionUInt32.write(value.watchForBlockConfirmations, into: &buf) - FfiConverterOptionString.write(value.updatedAt, into: &buf) - FfiConverterOptionString.write(value.createdAt, into: &buf) + public static func write(_ value: IManualRefund, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.amountSat, into: &buf) + FfiConverterString.write(value.target, into: &buf) + FfiConverterTypeManualRefundStateEnum.write(value.state, into: &buf) + FfiConverterString.write(value.createdByName, into: &buf) + FfiConverterOptionString.write(value.votedByName, into: &buf) + FfiConverterOptionString.write(value.reason, into: &buf) + FfiConverterString.write(value.targetType, into: &buf) } } @@ -5327,71 +5656,91 @@ public struct FfiConverterTypeIGiftBtcAddress: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftBtcAddress_lift(_ buf: RustBuffer) throws -> IGiftBtcAddress { - return try FfiConverterTypeIGiftBtcAddress.lift(buf) +public func FfiConverterTypeIManualRefund_lift(_ buf: RustBuffer) throws -> IManualRefund { + return try FfiConverterTypeIManualRefund.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftBtcAddress_lower(_ value: IGiftBtcAddress) -> RustBuffer { - return FfiConverterTypeIGiftBtcAddress.lower(value) +public func FfiConverterTypeIManualRefund_lower(_ value: IManualRefund) -> RustBuffer { + return FfiConverterTypeIManualRefund.lower(value) } -public struct IGiftCode { +public struct LightningActivity { public var id: String - public var code: String - public var createdAt: String - public var updatedAt: String - public var expiresAt: String - public var giftSat: UInt64? - public var scope: String? - public var maxCount: UInt32? + 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 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(id: String, code: String, createdAt: String, updatedAt: String, expiresAt: String, giftSat: UInt64?, scope: String?, maxCount: UInt32?) { + public init(id: String, txType: PaymentType, status: PaymentState, value: UInt64, fee: UInt64?, invoice: String, message: String, timestamp: UInt64, preimage: String?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { self.id = id - self.code = code + 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.createdAt = createdAt self.updatedAt = updatedAt - self.expiresAt = expiresAt - self.giftSat = giftSat - self.scope = scope - self.maxCount = maxCount + self.seenAt = seenAt } } #if compiler(>=6) -extension IGiftCode: Sendable {} +extension LightningActivity: Sendable {} #endif -extension IGiftCode: Equatable, Hashable { - public static func ==(lhs: IGiftCode, rhs: IGiftCode) -> Bool { +extension LightningActivity: Equatable, Hashable { + public static func ==(lhs: LightningActivity, rhs: LightningActivity) -> Bool { if lhs.id != rhs.id { return false } - if lhs.code != rhs.code { + if lhs.txType != rhs.txType { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.status != rhs.status { return false } - if lhs.updatedAt != rhs.updatedAt { + if lhs.value != rhs.value { return false } - if lhs.expiresAt != rhs.expiresAt { + if lhs.fee != rhs.fee { return false } - if lhs.giftSat != rhs.giftSat { + if lhs.invoice != rhs.invoice { return false } - if lhs.scope != rhs.scope { + if lhs.message != rhs.message { return false } - if lhs.maxCount != rhs.maxCount { + if lhs.timestamp != rhs.timestamp { + return false + } + if lhs.preimage != rhs.preimage { + 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 @@ -5399,47 +5748,59 @@ extension IGiftCode: Equatable, Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(id) - hasher.combine(code) + 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(createdAt) hasher.combine(updatedAt) - hasher.combine(expiresAt) - hasher.combine(giftSat) - hasher.combine(scope) - hasher.combine(maxCount) + hasher.combine(seenAt) } } -extension IGiftCode: Codable {} +extension LightningActivity: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIGiftCode: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftCode { +public struct FfiConverterTypeLightningActivity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LightningActivity { return - try IGiftCode( + try LightningActivity( id: FfiConverterString.read(from: &buf), - code: FfiConverterString.read(from: &buf), - createdAt: FfiConverterString.read(from: &buf), - updatedAt: FfiConverterString.read(from: &buf), - expiresAt: FfiConverterString.read(from: &buf), - giftSat: FfiConverterOptionUInt64.read(from: &buf), - scope: FfiConverterOptionString.read(from: &buf), - maxCount: FfiConverterOptionUInt32.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), + createdAt: FfiConverterOptionUInt64.read(from: &buf), + updatedAt: FfiConverterOptionUInt64.read(from: &buf), + seenAt: FfiConverterOptionUInt64.read(from: &buf) ) } - public static func write(_ value: IGiftCode, into buf: inout [UInt8]) { + public static func write(_ value: LightningActivity, into buf: inout [UInt8]) { FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.code, into: &buf) - FfiConverterString.write(value.createdAt, into: &buf) - FfiConverterString.write(value.updatedAt, into: &buf) - FfiConverterString.write(value.expiresAt, into: &buf) - FfiConverterOptionUInt64.write(value.giftSat, into: &buf) - FfiConverterOptionString.write(value.scope, into: &buf) - FfiConverterOptionUInt32.write(value.maxCount, 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) + FfiConverterOptionUInt64.write(value.createdAt, into: &buf) + FfiConverterOptionUInt64.write(value.updatedAt, into: &buf) + FfiConverterOptionUInt64.write(value.seenAt, into: &buf) } } @@ -5447,79 +5808,127 @@ public struct FfiConverterTypeIGiftCode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftCode_lift(_ buf: RustBuffer) throws -> IGiftCode { - return try FfiConverterTypeIGiftCode.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 FfiConverterTypeIGiftCode_lower(_ value: IGiftCode) -> RustBuffer { - return FfiConverterTypeIGiftCode.lower(value) +public func FfiConverterTypeLightningActivity_lower(_ value: LightningActivity) -> RustBuffer { + return FfiConverterTypeLightningActivity.lower(value) } -public struct IGiftLspNode { - public var alias: String - public var pubkey: String - public var connectionStrings: [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(alias: String, pubkey: String, connectionStrings: [String]) { - self.alias = alias - self.pubkey = pubkey - self.connectionStrings = connectionStrings + 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 IGiftLspNode: Sendable {} +extension LightningInvoice: Sendable {} #endif -extension IGiftLspNode: Equatable, Hashable { - public static func ==(lhs: IGiftLspNode, rhs: IGiftLspNode) -> Bool { - if lhs.alias != rhs.alias { +extension LightningInvoice: Equatable, Hashable { + public static func ==(lhs: LightningInvoice, rhs: LightningInvoice) -> Bool { + if lhs.bolt11 != rhs.bolt11 { return false } - if lhs.pubkey != rhs.pubkey { + if lhs.paymentHash != rhs.paymentHash { return false } - if lhs.connectionStrings != rhs.connectionStrings { + 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(alias) - hasher.combine(pubkey) - hasher.combine(connectionStrings) + 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 IGiftLspNode: Codable {} +extension LightningInvoice: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIGiftLspNode: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftLspNode { +public struct FfiConverterTypeLightningInvoice: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LightningInvoice { return - try IGiftLspNode( - alias: FfiConverterString.read(from: &buf), - pubkey: FfiConverterString.read(from: &buf), - connectionStrings: FfiConverterSequenceString.read(from: &buf) - ) - } - - public static func write(_ value: IGiftLspNode, into buf: inout [UInt8]) { - FfiConverterString.write(value.alias, into: &buf) - FfiConverterString.write(value.pubkey, into: &buf) - FfiConverterSequenceString.write(value.connectionStrings, into: &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: 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) } } @@ -5527,231 +5936,79 @@ public struct FfiConverterTypeIGiftLspNode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftLspNode_lift(_ buf: RustBuffer) throws -> IGiftLspNode { - return try FfiConverterTypeIGiftLspNode.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 FfiConverterTypeIGiftLspNode_lower(_ value: IGiftLspNode) -> RustBuffer { - return FfiConverterTypeIGiftLspNode.lower(value) +public func FfiConverterTypeLightningInvoice_lower(_ value: LightningInvoice) -> RustBuffer { + return FfiConverterTypeLightningInvoice.lower(value) } -public struct IGiftOrder { - public var id: String - public var state: String - public var oldState: String? - public var isChannelExpired: Bool? - public var isOrderExpired: Bool? - public var lspBalanceSat: UInt64? - public var clientBalanceSat: UInt64? - public var channelExpiryWeeks: UInt32? - public var zeroConf: Bool? - public var zeroReserve: Bool? - public var announced: Bool? - public var clientNodeId: String? - public var channelExpiresAt: String? - public var orderExpiresAt: String? - public var feeSat: UInt64? - public var networkFeeSat: UInt64? - public var serviceFeeSat: UInt64? - public var payment: IGiftPayment? - public var lspNode: IGiftLspNode? - public var updatedAt: String? - public var createdAt: String? - public var nodeIdVerified: Bool? +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(id: String, state: String, oldState: String?, isChannelExpired: Bool?, isOrderExpired: Bool?, lspBalanceSat: UInt64?, clientBalanceSat: UInt64?, channelExpiryWeeks: UInt32?, zeroConf: Bool?, zeroReserve: Bool?, announced: Bool?, clientNodeId: String?, channelExpiresAt: String?, orderExpiresAt: String?, feeSat: UInt64?, networkFeeSat: UInt64?, serviceFeeSat: UInt64?, payment: IGiftPayment?, lspNode: IGiftLspNode?, updatedAt: String?, createdAt: String?, nodeIdVerified: Bool?) { - self.id = id - self.state = state - self.oldState = oldState - self.isChannelExpired = isChannelExpired - self.isOrderExpired = isOrderExpired - self.lspBalanceSat = lspBalanceSat - self.clientBalanceSat = clientBalanceSat - self.channelExpiryWeeks = channelExpiryWeeks - self.zeroConf = zeroConf - self.zeroReserve = zeroReserve - self.announced = announced - self.clientNodeId = clientNodeId - self.channelExpiresAt = channelExpiresAt - self.orderExpiresAt = orderExpiresAt - self.feeSat = feeSat - self.networkFeeSat = networkFeeSat - self.serviceFeeSat = serviceFeeSat - self.payment = payment - self.lspNode = lspNode - self.updatedAt = updatedAt - self.createdAt = createdAt - self.nodeIdVerified = nodeIdVerified + public init(uri: String, domain: String, username: String) { + self.uri = uri + self.domain = domain + self.username = username } } #if compiler(>=6) -extension IGiftOrder: Sendable {} +extension LnurlAddressData: Sendable {} #endif -extension IGiftOrder: Equatable, Hashable { - public static func ==(lhs: IGiftOrder, rhs: IGiftOrder) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.state != rhs.state { - return false - } - if lhs.oldState != rhs.oldState { - return false - } - if lhs.isChannelExpired != rhs.isChannelExpired { - return false - } - if lhs.isOrderExpired != rhs.isOrderExpired { - return false - } - if lhs.lspBalanceSat != rhs.lspBalanceSat { - return false - } - if lhs.clientBalanceSat != rhs.clientBalanceSat { - return false - } - if lhs.channelExpiryWeeks != rhs.channelExpiryWeeks { - return false - } - if lhs.zeroConf != rhs.zeroConf { - return false - } - if lhs.zeroReserve != rhs.zeroReserve { - return false - } - if lhs.announced != rhs.announced { - return false - } - if lhs.clientNodeId != rhs.clientNodeId { - return false - } - if lhs.channelExpiresAt != rhs.channelExpiresAt { - return false - } - if lhs.orderExpiresAt != rhs.orderExpiresAt { - return false - } - if lhs.feeSat != rhs.feeSat { - return false - } - if lhs.networkFeeSat != rhs.networkFeeSat { - return false - } - if lhs.serviceFeeSat != rhs.serviceFeeSat { - return false - } - if lhs.payment != rhs.payment { - return false - } - if lhs.lspNode != rhs.lspNode { - return false - } - if lhs.updatedAt != rhs.updatedAt { +extension LnurlAddressData: Equatable, Hashable { + public static func ==(lhs: LnurlAddressData, rhs: LnurlAddressData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.domain != rhs.domain { return false } - if lhs.nodeIdVerified != rhs.nodeIdVerified { + if lhs.username != rhs.username { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(state) - hasher.combine(oldState) - hasher.combine(isChannelExpired) - hasher.combine(isOrderExpired) - hasher.combine(lspBalanceSat) - hasher.combine(clientBalanceSat) - hasher.combine(channelExpiryWeeks) - hasher.combine(zeroConf) - hasher.combine(zeroReserve) - hasher.combine(announced) - hasher.combine(clientNodeId) - hasher.combine(channelExpiresAt) - hasher.combine(orderExpiresAt) - hasher.combine(feeSat) - hasher.combine(networkFeeSat) - hasher.combine(serviceFeeSat) - hasher.combine(payment) - hasher.combine(lspNode) - hasher.combine(updatedAt) - hasher.combine(createdAt) - hasher.combine(nodeIdVerified) + hasher.combine(uri) + hasher.combine(domain) + hasher.combine(username) } } -extension IGiftOrder: Codable {} +extension LnurlAddressData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIGiftOrder: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftOrder { +public struct FfiConverterTypeLnurlAddressData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlAddressData { return - try IGiftOrder( - id: FfiConverterString.read(from: &buf), - state: FfiConverterString.read(from: &buf), - oldState: FfiConverterOptionString.read(from: &buf), - isChannelExpired: FfiConverterOptionBool.read(from: &buf), - isOrderExpired: FfiConverterOptionBool.read(from: &buf), - lspBalanceSat: FfiConverterOptionUInt64.read(from: &buf), - clientBalanceSat: FfiConverterOptionUInt64.read(from: &buf), - channelExpiryWeeks: FfiConverterOptionUInt32.read(from: &buf), - zeroConf: FfiConverterOptionBool.read(from: &buf), - zeroReserve: FfiConverterOptionBool.read(from: &buf), - announced: FfiConverterOptionBool.read(from: &buf), - clientNodeId: FfiConverterOptionString.read(from: &buf), - channelExpiresAt: FfiConverterOptionString.read(from: &buf), - orderExpiresAt: FfiConverterOptionString.read(from: &buf), - feeSat: FfiConverterOptionUInt64.read(from: &buf), - networkFeeSat: FfiConverterOptionUInt64.read(from: &buf), - serviceFeeSat: FfiConverterOptionUInt64.read(from: &buf), - payment: FfiConverterOptionTypeIGiftPayment.read(from: &buf), - lspNode: FfiConverterOptionTypeIGiftLspNode.read(from: &buf), - updatedAt: FfiConverterOptionString.read(from: &buf), - createdAt: FfiConverterOptionString.read(from: &buf), - nodeIdVerified: FfiConverterOptionBool.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: IGiftOrder, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.state, into: &buf) - FfiConverterOptionString.write(value.oldState, into: &buf) - FfiConverterOptionBool.write(value.isChannelExpired, into: &buf) - FfiConverterOptionBool.write(value.isOrderExpired, into: &buf) - FfiConverterOptionUInt64.write(value.lspBalanceSat, into: &buf) - FfiConverterOptionUInt64.write(value.clientBalanceSat, into: &buf) - FfiConverterOptionUInt32.write(value.channelExpiryWeeks, into: &buf) - FfiConverterOptionBool.write(value.zeroConf, into: &buf) - FfiConverterOptionBool.write(value.zeroReserve, into: &buf) - FfiConverterOptionBool.write(value.announced, into: &buf) - FfiConverterOptionString.write(value.clientNodeId, into: &buf) - FfiConverterOptionString.write(value.channelExpiresAt, into: &buf) - FfiConverterOptionString.write(value.orderExpiresAt, into: &buf) - FfiConverterOptionUInt64.write(value.feeSat, into: &buf) - FfiConverterOptionUInt64.write(value.networkFeeSat, into: &buf) - FfiConverterOptionUInt64.write(value.serviceFeeSat, into: &buf) - FfiConverterOptionTypeIGiftPayment.write(value.payment, into: &buf) - FfiConverterOptionTypeIGiftLspNode.write(value.lspNode, into: &buf) - FfiConverterOptionString.write(value.updatedAt, into: &buf) - FfiConverterOptionString.write(value.createdAt, into: &buf) - FfiConverterOptionBool.write(value.nodeIdVerified, 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) } } @@ -5759,215 +6016,87 @@ public struct FfiConverterTypeIGiftOrder: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftOrder_lift(_ buf: RustBuffer) throws -> IGiftOrder { - return try FfiConverterTypeIGiftOrder.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 FfiConverterTypeIGiftOrder_lower(_ value: IGiftOrder) -> RustBuffer { - return FfiConverterTypeIGiftOrder.lower(value) +public func FfiConverterTypeLnurlAddressData_lower(_ value: LnurlAddressData) -> RustBuffer { + return FfiConverterTypeLnurlAddressData.lower(value) } -public struct IGiftPayment { - public var id: String - public var state: String - public var oldState: String? - public var onchainState: String? - public var lnState: String? - public var paidOnchainSat: UInt64? - public var paidLnSat: UInt64? - public var paidSat: UInt64? - public var isOverpaid: Bool? - public var isRefunded: Bool? - public var overpaidAmountSat: UInt64? - public var requiredOnchainConfirmations: UInt32? - public var settlementState: String? - public var expectedAmountSat: UInt64? - public var isManuallyPaid: Bool? - public var btcAddress: IGiftBtcAddress? - public var btcAddressId: String? - public var bolt11Invoice: IGiftBolt11Invoice? - public var bolt11InvoiceId: String? - public var manualRefunds: [String] +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(id: String, state: String, oldState: String?, onchainState: String?, lnState: String?, paidOnchainSat: UInt64?, paidLnSat: UInt64?, paidSat: UInt64?, isOverpaid: Bool?, isRefunded: Bool?, overpaidAmountSat: UInt64?, requiredOnchainConfirmations: UInt32?, settlementState: String?, expectedAmountSat: UInt64?, isManuallyPaid: Bool?, btcAddress: IGiftBtcAddress?, btcAddressId: String?, bolt11Invoice: IGiftBolt11Invoice?, bolt11InvoiceId: String?, manualRefunds: [String]) { - self.id = id - self.state = state - self.oldState = oldState - self.onchainState = onchainState - self.lnState = lnState - self.paidOnchainSat = paidOnchainSat - self.paidLnSat = paidLnSat - self.paidSat = paidSat - self.isOverpaid = isOverpaid - self.isRefunded = isRefunded - self.overpaidAmountSat = overpaidAmountSat - self.requiredOnchainConfirmations = requiredOnchainConfirmations - self.settlementState = settlementState - self.expectedAmountSat = expectedAmountSat - self.isManuallyPaid = isManuallyPaid - self.btcAddress = btcAddress - self.btcAddressId = btcAddressId - self.bolt11Invoice = bolt11Invoice - self.bolt11InvoiceId = bolt11InvoiceId - self.manualRefunds = manualRefunds + 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 IGiftPayment: Sendable {} +extension LnurlAuthData: Sendable {} #endif -extension IGiftPayment: Equatable, Hashable { - public static func ==(lhs: IGiftPayment, rhs: IGiftPayment) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.state != rhs.state { - return false - } - if lhs.oldState != rhs.oldState { - return false - } - if lhs.onchainState != rhs.onchainState { - return false - } - if lhs.lnState != rhs.lnState { - return false - } - if lhs.paidOnchainSat != rhs.paidOnchainSat { - return false - } - if lhs.paidLnSat != rhs.paidLnSat { - return false - } - if lhs.paidSat != rhs.paidSat { - return false - } - if lhs.isOverpaid != rhs.isOverpaid { - return false - } - if lhs.isRefunded != rhs.isRefunded { - return false - } - if lhs.overpaidAmountSat != rhs.overpaidAmountSat { - return false - } - if lhs.requiredOnchainConfirmations != rhs.requiredOnchainConfirmations { - return false - } - if lhs.settlementState != rhs.settlementState { - return false - } - if lhs.expectedAmountSat != rhs.expectedAmountSat { - return false - } - if lhs.isManuallyPaid != rhs.isManuallyPaid { - return false - } - if lhs.btcAddress != rhs.btcAddress { - return false - } - if lhs.btcAddressId != rhs.btcAddressId { +extension LnurlAuthData: Equatable, Hashable { + public static func ==(lhs: LnurlAuthData, rhs: LnurlAuthData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.bolt11Invoice != rhs.bolt11Invoice { + if lhs.tag != rhs.tag { return false } - if lhs.bolt11InvoiceId != rhs.bolt11InvoiceId { + if lhs.k1 != rhs.k1 { return false } - if lhs.manualRefunds != rhs.manualRefunds { + if lhs.domain != rhs.domain { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(state) - hasher.combine(oldState) - hasher.combine(onchainState) - hasher.combine(lnState) - hasher.combine(paidOnchainSat) - hasher.combine(paidLnSat) - hasher.combine(paidSat) - hasher.combine(isOverpaid) - hasher.combine(isRefunded) - hasher.combine(overpaidAmountSat) - hasher.combine(requiredOnchainConfirmations) - hasher.combine(settlementState) - hasher.combine(expectedAmountSat) - hasher.combine(isManuallyPaid) - hasher.combine(btcAddress) - hasher.combine(btcAddressId) - hasher.combine(bolt11Invoice) - hasher.combine(bolt11InvoiceId) - hasher.combine(manualRefunds) + hasher.combine(uri) + hasher.combine(tag) + hasher.combine(k1) + hasher.combine(domain) } } -extension IGiftPayment: Codable {} +extension LnurlAuthData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIGiftPayment: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IGiftPayment { +public struct FfiConverterTypeLnurlAuthData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlAuthData { return - try IGiftPayment( - id: FfiConverterString.read(from: &buf), - state: FfiConverterString.read(from: &buf), - oldState: FfiConverterOptionString.read(from: &buf), - onchainState: FfiConverterOptionString.read(from: &buf), - lnState: FfiConverterOptionString.read(from: &buf), - paidOnchainSat: FfiConverterOptionUInt64.read(from: &buf), - paidLnSat: FfiConverterOptionUInt64.read(from: &buf), - paidSat: FfiConverterOptionUInt64.read(from: &buf), - isOverpaid: FfiConverterOptionBool.read(from: &buf), - isRefunded: FfiConverterOptionBool.read(from: &buf), - overpaidAmountSat: FfiConverterOptionUInt64.read(from: &buf), - requiredOnchainConfirmations: FfiConverterOptionUInt32.read(from: &buf), - settlementState: FfiConverterOptionString.read(from: &buf), - expectedAmountSat: FfiConverterOptionUInt64.read(from: &buf), - isManuallyPaid: FfiConverterOptionBool.read(from: &buf), - btcAddress: FfiConverterOptionTypeIGiftBtcAddress.read(from: &buf), - btcAddressId: FfiConverterOptionString.read(from: &buf), - bolt11Invoice: FfiConverterOptionTypeIGiftBolt11Invoice.read(from: &buf), - bolt11InvoiceId: FfiConverterOptionString.read(from: &buf), - manualRefunds: FfiConverterSequenceString.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: IGiftPayment, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.state, into: &buf) - FfiConverterOptionString.write(value.oldState, into: &buf) - FfiConverterOptionString.write(value.onchainState, into: &buf) - FfiConverterOptionString.write(value.lnState, into: &buf) - FfiConverterOptionUInt64.write(value.paidOnchainSat, into: &buf) - FfiConverterOptionUInt64.write(value.paidLnSat, into: &buf) - FfiConverterOptionUInt64.write(value.paidSat, into: &buf) - FfiConverterOptionBool.write(value.isOverpaid, into: &buf) - FfiConverterOptionBool.write(value.isRefunded, into: &buf) - FfiConverterOptionUInt64.write(value.overpaidAmountSat, into: &buf) - FfiConverterOptionUInt32.write(value.requiredOnchainConfirmations, into: &buf) - FfiConverterOptionString.write(value.settlementState, into: &buf) - FfiConverterOptionUInt64.write(value.expectedAmountSat, into: &buf) - FfiConverterOptionBool.write(value.isManuallyPaid, into: &buf) - FfiConverterOptionTypeIGiftBtcAddress.write(value.btcAddress, into: &buf) - FfiConverterOptionString.write(value.btcAddressId, into: &buf) - FfiConverterOptionTypeIGiftBolt11Invoice.write(value.bolt11Invoice, into: &buf) - FfiConverterOptionString.write(value.bolt11InvoiceId, into: &buf) - FfiConverterSequenceString.write(value.manualRefunds, 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) } } @@ -5975,87 +6104,87 @@ public struct FfiConverterTypeIGiftPayment: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIGiftPayment_lift(_ buf: RustBuffer) throws -> IGiftPayment { - return try FfiConverterTypeIGiftPayment.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 FfiConverterTypeIGiftPayment_lower(_ value: IGiftPayment) -> RustBuffer { - return FfiConverterTypeIGiftPayment.lower(value) +public func FfiConverterTypeLnurlAuthData_lower(_ value: LnurlAuthData) -> RustBuffer { + return FfiConverterTypeLnurlAuthData.lower(value) } -public struct ILspNode { - public var alias: String - public var pubkey: String - public var connectionStrings: [String] - public var readonly: Bool? +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(alias: String, pubkey: String, connectionStrings: [String], readonly: Bool?) { - self.alias = alias - self.pubkey = pubkey - self.connectionStrings = connectionStrings - self.readonly = readonly + 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 ILspNode: Sendable {} +extension LnurlChannelData: Sendable {} #endif -extension ILspNode: Equatable, Hashable { - public static func ==(lhs: ILspNode, rhs: ILspNode) -> Bool { - if lhs.alias != rhs.alias { +extension LnurlChannelData: Equatable, Hashable { + public static func ==(lhs: LnurlChannelData, rhs: LnurlChannelData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.pubkey != rhs.pubkey { + if lhs.callback != rhs.callback { return false } - if lhs.connectionStrings != rhs.connectionStrings { + if lhs.k1 != rhs.k1 { return false } - if lhs.readonly != rhs.readonly { + if lhs.tag != rhs.tag { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(alias) - hasher.combine(pubkey) - hasher.combine(connectionStrings) - hasher.combine(readonly) + hasher.combine(uri) + hasher.combine(callback) + hasher.combine(k1) + hasher.combine(tag) } } -extension ILspNode: Codable {} +extension LnurlChannelData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeILspNode: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ILspNode { +public struct FfiConverterTypeLnurlChannelData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlChannelData { return - try ILspNode( - alias: FfiConverterString.read(from: &buf), - pubkey: FfiConverterString.read(from: &buf), - connectionStrings: FfiConverterSequenceString.read(from: &buf), - readonly: FfiConverterOptionBool.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: ILspNode, into buf: inout [UInt8]) { - FfiConverterString.write(value.alias, into: &buf) - FfiConverterString.write(value.pubkey, into: &buf) - FfiConverterSequenceString.write(value.connectionStrings, into: &buf) - FfiConverterOptionBool.write(value.readonly, 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) } } @@ -6063,111 +6192,119 @@ public struct FfiConverterTypeILspNode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeILspNode_lift(_ buf: RustBuffer) throws -> ILspNode { - return try FfiConverterTypeILspNode.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 FfiConverterTypeILspNode_lower(_ value: ILspNode) -> RustBuffer { - return FfiConverterTypeILspNode.lower(value) +public func FfiConverterTypeLnurlChannelData_lower(_ value: LnurlChannelData) -> RustBuffer { + return FfiConverterTypeLnurlChannelData.lower(value) } -public struct IManualRefund { - public var amountSat: UInt64 - public var target: String - public var state: ManualRefundStateEnum - public var createdByName: String - public var votedByName: String? - public var reason: String? - public var targetType: 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(amountSat: UInt64, target: String, state: ManualRefundStateEnum, createdByName: String, votedByName: String?, reason: String?, targetType: String) { - self.amountSat = amountSat - self.target = target - self.state = state - self.createdByName = createdByName - self.votedByName = votedByName - self.reason = reason - self.targetType = targetType + 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 IManualRefund: Sendable {} +extension LnurlPayData: Sendable {} #endif -extension IManualRefund: Equatable, Hashable { - public static func ==(lhs: IManualRefund, rhs: IManualRefund) -> Bool { - if lhs.amountSat != rhs.amountSat { +extension LnurlPayData: Equatable, Hashable { + public static func ==(lhs: LnurlPayData, rhs: LnurlPayData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.target != rhs.target { + if lhs.callback != rhs.callback { return false } - if lhs.state != rhs.state { + if lhs.minSendable != rhs.minSendable { return false } - if lhs.createdByName != rhs.createdByName { + if lhs.maxSendable != rhs.maxSendable { return false } - if lhs.votedByName != rhs.votedByName { + if lhs.metadataStr != rhs.metadataStr { return false } - if lhs.reason != rhs.reason { + if lhs.commentAllowed != rhs.commentAllowed { return false } - if lhs.targetType != rhs.targetType { + 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(amountSat) - hasher.combine(target) - hasher.combine(state) - hasher.combine(createdByName) - hasher.combine(votedByName) - hasher.combine(reason) - hasher.combine(targetType) + 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 IManualRefund: Codable {} +extension LnurlPayData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeIManualRefund: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IManualRefund { +public struct FfiConverterTypeLnurlPayData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlPayData { return - try IManualRefund( - amountSat: FfiConverterUInt64.read(from: &buf), - target: FfiConverterString.read(from: &buf), - state: FfiConverterTypeManualRefundStateEnum.read(from: &buf), - createdByName: FfiConverterString.read(from: &buf), - votedByName: FfiConverterOptionString.read(from: &buf), - reason: FfiConverterOptionString.read(from: &buf), - targetType: FfiConverterString.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: IManualRefund, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.amountSat, into: &buf) - FfiConverterString.write(value.target, into: &buf) - FfiConverterTypeManualRefundStateEnum.write(value.state, into: &buf) - FfiConverterString.write(value.createdByName, into: &buf) - FfiConverterOptionString.write(value.votedByName, into: &buf) - FfiConverterOptionString.write(value.reason, into: &buf) - FfiConverterString.write(value.targetType, 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) } } @@ -6175,151 +6312,111 @@ public struct FfiConverterTypeIManualRefund: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeIManualRefund_lift(_ buf: RustBuffer) throws -> IManualRefund { - return try FfiConverterTypeIManualRefund.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 FfiConverterTypeIManualRefund_lower(_ value: IManualRefund) -> RustBuffer { - return FfiConverterTypeIManualRefund.lower(value) +public func FfiConverterTypeLnurlPayData_lower(_ value: LnurlPayData) -> RustBuffer { + return FfiConverterTypeLnurlPayData.lower(value) } -public struct LightningActivity { - 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 createdAt: UInt64? - public var updatedAt: UInt64? - public var seenAt: UInt64? +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(id: String, txType: PaymentType, status: PaymentState, value: UInt64, fee: UInt64?, invoice: String, message: String, timestamp: UInt64, preimage: String?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { - 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.createdAt = createdAt - self.updatedAt = updatedAt - self.seenAt = seenAt + 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 LightningActivity: Sendable {} +extension LnurlWithdrawData: Sendable {} #endif -extension LightningActivity: Equatable, Hashable { - public static func ==(lhs: LightningActivity, rhs: LightningActivity) -> Bool { - 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 { +extension LnurlWithdrawData: Equatable, Hashable { + public static func ==(lhs: LnurlWithdrawData, rhs: LnurlWithdrawData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.message != rhs.message { + if lhs.callback != rhs.callback { return false } - if lhs.timestamp != rhs.timestamp { + if lhs.k1 != rhs.k1 { return false } - if lhs.preimage != rhs.preimage { + if lhs.defaultDescription != rhs.defaultDescription { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.minWithdrawable != rhs.minWithdrawable { return false } - if lhs.updatedAt != rhs.updatedAt { + if lhs.maxWithdrawable != rhs.maxWithdrawable { return false } - if lhs.seenAt != rhs.seenAt { + if lhs.tag != rhs.tag { return false } return true } public func hash(into hasher: inout Hasher) { - 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(createdAt) - hasher.combine(updatedAt) - hasher.combine(seenAt) + hasher.combine(uri) + hasher.combine(callback) + hasher.combine(k1) + hasher.combine(defaultDescription) + hasher.combine(minWithdrawable) + hasher.combine(maxWithdrawable) + hasher.combine(tag) } } -extension LightningActivity: Codable {} +extension LnurlWithdrawData: 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 FfiConverterTypeLnurlWithdrawData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlWithdrawData { return - try LightningActivity( - 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), - createdAt: FfiConverterOptionUInt64.read(from: &buf), - updatedAt: FfiConverterOptionUInt64.read(from: &buf), - seenAt: FfiConverterOptionUInt64.read(from: &buf) - ) - } - - public static func write(_ value: LightningActivity, into buf: inout [UInt8]) { - 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) - FfiConverterOptionUInt64.write(value.createdAt, into: &buf) - FfiConverterOptionUInt64.write(value.updatedAt, into: &buf) - FfiConverterOptionUInt64.write(value.seenAt, into: &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: 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) } } @@ -6327,127 +6424,128 @@ 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 FfiConverterTypeLnurlWithdrawData_lift(_ buf: RustBuffer) throws -> LnurlWithdrawData { + return try FfiConverterTypeLnurlWithdrawData.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLightningActivity_lower(_ value: LightningActivity) -> RustBuffer { - return FfiConverterTypeLightningActivity.lower(value) +public func FfiConverterTypeLnurlWithdrawData_lower(_ value: LnurlWithdrawData) -> RustBuffer { + return FfiConverterTypeLnurlWithdrawData.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? +/** + * 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(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( + /** + * 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 LightningInvoice: Sendable {} +extension NativeDeviceInfo: 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 { +extension NativeDeviceInfo: Equatable, Hashable { + public static func ==(lhs: NativeDeviceInfo, rhs: NativeDeviceInfo) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.isExpired != rhs.isExpired { + if lhs.transportType != rhs.transportType { return false } - if lhs.description != rhs.description { + if lhs.name != rhs.name { return false } - if lhs.networkType != rhs.networkType { + if lhs.vendorId != rhs.vendorId { return false } - if lhs.payeeNodeId != rhs.payeeNodeId { + if lhs.productId != rhs.productId { 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(transportType) + hasher.combine(name) + hasher.combine(vendorId) + hasher.combine(productId) } } -extension LightningInvoice: Codable {} +extension NativeDeviceInfo: 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 FfiConverterTypeNativeDeviceInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeDeviceInfo { 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 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: 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: 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) } } @@ -6455,79 +6553,95 @@ 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 FfiConverterTypeNativeDeviceInfo_lift(_ buf: RustBuffer) throws -> NativeDeviceInfo { + return try FfiConverterTypeNativeDeviceInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLightningInvoice_lower(_ value: LightningInvoice) -> RustBuffer { - return FfiConverterTypeLightningInvoice.lower(value) +public func FfiConverterTypeNativeDeviceInfo_lower(_ value: NativeDeviceInfo) -> RustBuffer { + return FfiConverterTypeNativeDeviceInfo.lower(value) } -public struct LnurlAddressData { - public var uri: String - public var domain: String - public var username: String +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(uri: String, domain: String, username: String) { - self.uri = uri - self.domain = domain - self.username = username + 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 LnurlAddressData: Sendable {} +extension OnChainInvoice: Sendable {} #endif -extension LnurlAddressData: Equatable, Hashable { - public static func ==(lhs: LnurlAddressData, rhs: LnurlAddressData) -> Bool { - if lhs.uri != rhs.uri { +extension OnChainInvoice: Equatable, Hashable { + public static func ==(lhs: OnChainInvoice, rhs: OnChainInvoice) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.domain != rhs.domain { + if lhs.amountSatoshis != rhs.amountSatoshis { return false } - if lhs.username != rhs.username { + if lhs.label != rhs.label { + return false + } + if lhs.message != rhs.message { + return false + } + if lhs.params != rhs.params { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(uri) - hasher.combine(domain) - hasher.combine(username) + hasher.combine(address) + hasher.combine(amountSatoshis) + hasher.combine(label) + hasher.combine(message) + hasher.combine(params) } } -extension LnurlAddressData: Codable {} +extension OnChainInvoice: 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 FfiConverterTypeOnChainInvoice: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnChainInvoice { return - try LnurlAddressData( - uri: FfiConverterString.read(from: &buf), - domain: FfiConverterString.read(from: &buf), - username: FfiConverterString.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: 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: 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) } } @@ -6535,87 +6649,207 @@ 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 FfiConverterTypeOnChainInvoice_lift(_ buf: RustBuffer) throws -> OnChainInvoice { + return try FfiConverterTypeOnChainInvoice.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlAddressData_lower(_ value: LnurlAddressData) -> RustBuffer { - return FfiConverterTypeLnurlAddressData.lower(value) +public func FfiConverterTypeOnChainInvoice_lower(_ value: OnChainInvoice) -> RustBuffer { + return FfiConverterTypeOnChainInvoice.lower(value) } -public struct LnurlAuthData { - public var uri: String - public var tag: String - public var k1: String - public var domain: String +public struct OnchainActivity { + 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 + 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 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(uri: String, tag: String, k1: String, domain: String) { - self.uri = uri - self.tag = tag - self.k1 = k1 - self.domain = domain - } -} - -#if compiler(>=6) -extension LnurlAuthData: Sendable {} + public init(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?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { + self.id = id + self.txType = txType + self.txId = txId + self.value = value + self.fee = fee + self.feeRate = feeRate + self.address = address + 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.createdAt = createdAt + self.updatedAt = updatedAt + self.seenAt = seenAt + } +} + +#if compiler(>=6) +extension OnchainActivity: Sendable {} #endif -extension LnurlAuthData: Equatable, Hashable { - public static func ==(lhs: LnurlAuthData, rhs: LnurlAuthData) -> Bool { - if lhs.uri != rhs.uri { +extension OnchainActivity: Equatable, Hashable { + public static func ==(lhs: OnchainActivity, rhs: OnchainActivity) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.tag != rhs.tag { + if lhs.txType != rhs.txType { return false } - if lhs.k1 != rhs.k1 { + if lhs.txId != rhs.txId { return false } - if lhs.domain != rhs.domain { + 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.confirmed != rhs.confirmed { + 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 { + 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(uri) - hasher.combine(tag) - hasher.combine(k1) - hasher.combine(domain) + hasher.combine(id) + hasher.combine(txType) + hasher.combine(txId) + hasher.combine(value) + hasher.combine(fee) + hasher.combine(feeRate) + hasher.combine(address) + 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(createdAt) + hasher.combine(updatedAt) + hasher.combine(seenAt) } } -extension LnurlAuthData: Codable {} +extension OnchainActivity: 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 FfiConverterTypeOnchainActivity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnchainActivity { return - try LnurlAuthData( - uri: FfiConverterString.read(from: &buf), - tag: FfiConverterString.read(from: &buf), - k1: FfiConverterString.read(from: &buf), - domain: FfiConverterString.read(from: &buf) + try OnchainActivity( + 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), + 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), + createdAt: FfiConverterOptionUInt64.read(from: &buf), + updatedAt: FfiConverterOptionUInt64.read(from: &buf), + seenAt: FfiConverterOptionUInt64.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: OnchainActivity, into buf: inout [UInt8]) { + 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) + 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) + FfiConverterOptionUInt64.write(value.createdAt, into: &buf) + FfiConverterOptionUInt64.write(value.updatedAt, into: &buf) + FfiConverterOptionUInt64.write(value.seenAt, into: &buf) } } @@ -6623,87 +6857,135 @@ 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 FfiConverterTypeOnchainActivity_lift(_ buf: RustBuffer) throws -> OnchainActivity { + return try FfiConverterTypeOnchainActivity.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlAuthData_lower(_ value: LnurlAuthData) -> RustBuffer { - return FfiConverterTypeLnurlAuthData.lower(value) +public func FfiConverterTypeOnchainActivity_lower(_ value: OnchainActivity) -> RustBuffer { + return FfiConverterTypeOnchainActivity.lower(value) } -public struct LnurlChannelData { - public var uri: String - public var callback: String - public var k1: String - public var tag: String +public struct PreActivityMetadata { + 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(uri: String, callback: String, k1: String, tag: String) { - self.uri = uri - self.callback = callback - self.k1 = k1 - self.tag = tag + public init(paymentId: String, tags: [String], paymentHash: String?, txId: String?, address: String?, isReceive: Bool, feeRate: UInt64, isTransfer: Bool, channelId: String?, createdAt: UInt64) { + 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 LnurlChannelData: Sendable {} +extension PreActivityMetadata: Sendable {} #endif -extension LnurlChannelData: Equatable, Hashable { - public static func ==(lhs: LnurlChannelData, rhs: LnurlChannelData) -> Bool { - if lhs.uri != rhs.uri { +extension PreActivityMetadata: Equatable, Hashable { + public static func ==(lhs: PreActivityMetadata, rhs: PreActivityMetadata) -> Bool { + if lhs.paymentId != rhs.paymentId { return false } - if lhs.callback != rhs.callback { + if lhs.tags != rhs.tags { return false } - if lhs.k1 != rhs.k1 { + if lhs.paymentHash != rhs.paymentHash { return false } - if lhs.tag != rhs.tag { + 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(uri) - hasher.combine(callback) - hasher.combine(k1) - hasher.combine(tag) + 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 LnurlChannelData: Codable {} +extension PreActivityMetadata: 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 FfiConverterTypePreActivityMetadata: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PreActivityMetadata { return - try LnurlChannelData( - uri: FfiConverterString.read(from: &buf), - callback: FfiConverterString.read(from: &buf), - k1: FfiConverterString.read(from: &buf), - tag: FfiConverterString.read(from: &buf) + try PreActivityMetadata( + 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: 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: PreActivityMetadata, into buf: inout [UInt8]) { + 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) } } @@ -6711,119 +6993,63 @@ 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 FfiConverterTypePreActivityMetadata_lift(_ buf: RustBuffer) throws -> PreActivityMetadata { + return try FfiConverterTypePreActivityMetadata.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlChannelData_lower(_ value: LnurlChannelData) -> RustBuffer { - return FfiConverterTypeLnurlChannelData.lower(value) +public func FfiConverterTypePreActivityMetadata_lower(_ value: PreActivityMetadata) -> RustBuffer { + return FfiConverterTypePreActivityMetadata.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 PubkyAuth { + public var data: String // 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(data: String) { + self.data = data } } #if compiler(>=6) -extension LnurlPayData: Sendable {} +extension PubkyAuth: Sendable {} #endif -extension LnurlPayData: Equatable, Hashable { - public static func ==(lhs: LnurlPayData, rhs: LnurlPayData) -> Bool { - if lhs.uri != rhs.uri { - return false - } - if lhs.callback != rhs.callback { - return false - } - if lhs.minSendable != rhs.minSendable { - return false - } - if lhs.maxSendable != rhs.maxSendable { - return false - } - 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 { +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(uri) - hasher.combine(callback) - hasher.combine(minSendable) - hasher.combine(maxSendable) - hasher.combine(metadataStr) - hasher.combine(commentAllowed) - hasher.combine(allowsNostr) - hasher.combine(nostrPubkey) + hasher.combine(data) } } -extension LnurlPayData: Codable {} +extension PubkyAuth: 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 FfiConverterTypePubkyAuth: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyAuth { 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 PubkyAuth( + data: FfiConverterString.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: PubkyAuth, into buf: inout [UInt8]) { + FfiConverterString.write(value.data, into: &buf) } } @@ -6831,111 +7057,111 @@ 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 FfiConverterTypePubkyAuth_lift(_ buf: RustBuffer) throws -> PubkyAuth { + return try FfiConverterTypePubkyAuth.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlPayData_lower(_ value: LnurlPayData) -> RustBuffer { - return FfiConverterTypeLnurlPayData.lower(value) +public func FfiConverterTypePubkyAuth_lower(_ value: PubkyAuth) -> RustBuffer { + return FfiConverterTypePubkyAuth.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 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 // 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( + /** + * 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 } } #if compiler(>=6) -extension LnurlWithdrawData: Sendable {} +extension SweepResult: 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 { +extension SweepResult: Equatable, Hashable { + public static func ==(lhs: SweepResult, rhs: SweepResult) -> Bool { + if lhs.txid != rhs.txid { return false } - if lhs.minWithdrawable != rhs.minWithdrawable { + if lhs.amountSwept != rhs.amountSwept { return false } - if lhs.maxWithdrawable != rhs.maxWithdrawable { + if lhs.feePaid != rhs.feePaid { return false } - if lhs.tag != rhs.tag { + if lhs.utxosSwept != rhs.utxosSwept { 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(txid) + hasher.combine(amountSwept) + hasher.combine(feePaid) + hasher.combine(utxosSwept) } } -extension LnurlWithdrawData: Codable {} +extension SweepResult: 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 FfiConverterTypeSweepResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepResult { 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 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: 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: 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) } } @@ -6943,86 +7169,153 @@ 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 FfiConverterTypeSweepResult_lift(_ buf: RustBuffer) throws -> SweepResult { + return try FfiConverterTypeSweepResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlWithdrawData_lower(_ value: LnurlWithdrawData) -> RustBuffer { - return FfiConverterTypeLnurlWithdrawData.lower(value) -} +public func FfiConverterTypeSweepResult_lower(_ value: SweepResult) -> RustBuffer { + return FfiConverterTypeSweepResult.lower(value) +} -/** - * Message signature response - */ -public struct MessageSignatureResponse { +public struct SweepTransactionPreview { /** - * Signer address + * The PSBT (Partially Signed Bitcoin Transaction) in base64 format */ - public var address: String + public var psbt: String /** - * Signature in base64 format + * The total amount available to sweep (in satoshis) */ - public var signature: String + 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 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Signer address - */address: String, + * The PSBT (Partially Signed Bitcoin Transaction) in base64 format + */psbt: String, /** - * Signature in base64 format - */signature: String) { - self.address = address - self.signature = signature + * 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 } } #if compiler(>=6) -extension MessageSignatureResponse: Sendable {} +extension SweepTransactionPreview: Sendable {} #endif -extension MessageSignatureResponse: Equatable, Hashable { - public static func ==(lhs: MessageSignatureResponse, rhs: MessageSignatureResponse) -> Bool { - if lhs.address != rhs.address { +extension SweepTransactionPreview: Equatable, Hashable { + public static func ==(lhs: SweepTransactionPreview, rhs: SweepTransactionPreview) -> Bool { + if lhs.psbt != rhs.psbt { return false } - if lhs.signature != rhs.signature { + 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 { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(signature) + hasher.combine(psbt) + hasher.combine(totalAmount) + hasher.combine(estimatedFee) + hasher.combine(estimatedVsize) + hasher.combine(utxosCount) + hasher.combine(destinationAddress) + hasher.combine(amountAfterFees) } } -extension MessageSignatureResponse: Codable {} +extension SweepTransactionPreview: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeMessageSignatureResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MessageSignatureResponse { +public struct FfiConverterTypeSweepTransactionPreview: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepTransactionPreview { return - try MessageSignatureResponse( - address: FfiConverterString.read(from: &buf), - signature: FfiConverterString.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: MessageSignatureResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.signature, 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) } } @@ -7030,128 +7323,167 @@ public struct FfiConverterTypeMessageSignatureResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeMessageSignatureResponse_lift(_ buf: RustBuffer) throws -> MessageSignatureResponse { - return try FfiConverterTypeMessageSignatureResponse.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 FfiConverterTypeMessageSignatureResponse_lower(_ value: MessageSignatureResponse) -> RustBuffer { - return FfiConverterTypeMessageSignatureResponse.lower(value) +public func FfiConverterTypeSweepTransactionPreview_lower(_ value: SweepTransactionPreview) -> RustBuffer { + return FfiConverterTypeSweepTransactionPreview.lower(value) } -/** - * Multisig Redeem Script Type - */ -public struct MultisigRedeemScriptType { +public struct SweepableBalances { /** - * Public keys + * Balance in legacy (P2PKH) addresses (in satoshis) */ - public var pubkeys: [HdNodePathType] + public var legacyBalance: UInt64 /** - * Signatures + * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) */ - public var signatures: [String] + public var p2shBalance: UInt64 /** - * M-of-N threshold + * Balance in Taproot (P2TR) addresses (in satoshis) + */ + public var taprootBalance: UInt64 + /** + * Total balance across all wallet types (in satoshis) + */ + public var totalBalance: UInt64 + /** + * Number of UTXOs in legacy wallet + */ + public var legacyUtxosCount: UInt32 + /** + * Number of UTXOs in P2SH-SegWit wallet */ - public var m: UInt32 + public var p2shUtxosCount: UInt32 /** - * Nodes (optional) + * Number of UTXOs in Taproot wallet */ - public var nodes: [HdNodeType]? + public var taprootUtxosCount: UInt32 /** - * Pubkeys order (optional): 0 for PRESERVED, 1 for LEXICOGRAPHIC + * Total number of UTXOs across all wallet types */ - public var pubkeysOrder: UInt8? + public var totalUtxosCount: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Public keys - */pubkeys: [HdNodePathType], + * Balance in legacy (P2PKH) addresses (in satoshis) + */legacyBalance: UInt64, + /** + * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) + */p2shBalance: UInt64, /** - * Signatures - */signatures: [String], + * Balance in Taproot (P2TR) addresses (in satoshis) + */taprootBalance: UInt64, /** - * M-of-N threshold - */m: UInt32, + * Total balance across all wallet types (in satoshis) + */totalBalance: UInt64, /** - * Nodes (optional) - */nodes: [HdNodeType]?, + * Number of UTXOs in legacy wallet + */legacyUtxosCount: UInt32, /** - * Pubkeys order (optional): 0 for PRESERVED, 1 for LEXICOGRAPHIC - */pubkeysOrder: UInt8?) { - self.pubkeys = pubkeys - self.signatures = signatures - self.m = m - self.nodes = nodes - self.pubkeysOrder = pubkeysOrder + * 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 MultisigRedeemScriptType: Sendable {} +extension SweepableBalances: Sendable {} #endif -extension MultisigRedeemScriptType: Equatable, Hashable { - public static func ==(lhs: MultisigRedeemScriptType, rhs: MultisigRedeemScriptType) -> Bool { - if lhs.pubkeys != rhs.pubkeys { +extension SweepableBalances: Equatable, Hashable { + public static func ==(lhs: SweepableBalances, rhs: SweepableBalances) -> Bool { + if lhs.legacyBalance != rhs.legacyBalance { return false } - if lhs.signatures != rhs.signatures { + if lhs.p2shBalance != rhs.p2shBalance { return false } - if lhs.m != rhs.m { + if lhs.taprootBalance != rhs.taprootBalance { return false } - if lhs.nodes != rhs.nodes { + 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.pubkeysOrder != rhs.pubkeysOrder { + if lhs.totalUtxosCount != rhs.totalUtxosCount { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(pubkeys) - hasher.combine(signatures) - hasher.combine(m) - hasher.combine(nodes) - hasher.combine(pubkeysOrder) + 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 MultisigRedeemScriptType: Codable {} +extension SweepableBalances: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeMultisigRedeemScriptType: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MultisigRedeemScriptType { +public struct FfiConverterTypeSweepableBalances: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepableBalances { return - try MultisigRedeemScriptType( - pubkeys: FfiConverterSequenceTypeHDNodePathType.read(from: &buf), - signatures: FfiConverterSequenceString.read(from: &buf), - m: FfiConverterUInt32.read(from: &buf), - nodes: FfiConverterOptionSequenceTypeHDNodeType.read(from: &buf), - pubkeysOrder: FfiConverterOptionUInt8.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: MultisigRedeemScriptType, into buf: inout [UInt8]) { - FfiConverterSequenceTypeHDNodePathType.write(value.pubkeys, into: &buf) - FfiConverterSequenceString.write(value.signatures, into: &buf) - FfiConverterUInt32.write(value.m, into: &buf) - FfiConverterOptionSequenceTypeHDNodeType.write(value.nodes, into: &buf) - FfiConverterOptionUInt8.write(value.pubkeysOrder, 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) } } @@ -7159,95 +7491,124 @@ public struct FfiConverterTypeMultisigRedeemScriptType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeMultisigRedeemScriptType_lift(_ buf: RustBuffer) throws -> MultisigRedeemScriptType { - return try FfiConverterTypeMultisigRedeemScriptType.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 FfiConverterTypeMultisigRedeemScriptType_lower(_ value: MultisigRedeemScriptType) -> RustBuffer { - return FfiConverterTypeMultisigRedeemScriptType.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]? - - // 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 func FfiConverterTypeSweepableBalances_lower(_ value: SweepableBalances) -> RustBuffer { + return FfiConverterTypeSweepableBalances.lower(value) } -#if compiler(>=6) -extension OnChainInvoice: Sendable {} -#endif - -extension OnChainInvoice: Equatable, Hashable { - public static func ==(lhs: OnChainInvoice, rhs: OnChainInvoice) -> Bool { - if lhs.address != rhs.address { - return false - } - if lhs.amountSatoshis != rhs.amountSatoshis { +/** + * Details about an onchain transaction. + */ +public struct TransactionDetails { + /** + * The transaction ID. + */ + public var txId: 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. + */ + public var amountSats: Int64 + /** + * The transaction inputs with full details. + */ + public var inputs: [TxInput] + /** + * The transaction outputs with full details. + */ + public var outputs: [TxOutput] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * The transaction ID. + */txId: 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, + /** + * The transaction inputs with full details. + */inputs: [TxInput], + /** + * The transaction outputs with full details. + */outputs: [TxOutput]) { + self.txId = txId + self.amountSats = amountSats + self.inputs = inputs + self.outputs = outputs + } +} + +#if compiler(>=6) +extension TransactionDetails: Sendable {} +#endif + + +extension TransactionDetails: Equatable, Hashable { + public static func ==(lhs: TransactionDetails, rhs: TransactionDetails) -> Bool { + if lhs.txId != rhs.txId { return false } - if lhs.label != rhs.label { + if lhs.amountSats != rhs.amountSats { return false } - if lhs.message != rhs.message { + if lhs.inputs != rhs.inputs { return false } - if lhs.params != rhs.params { + if lhs.outputs != rhs.outputs { 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(txId) + hasher.combine(amountSats) + hasher.combine(inputs) + hasher.combine(outputs) } } -extension OnChainInvoice: Codable {} +extension TransactionDetails: 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 FfiConverterTypeTransactionDetails: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetails { 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 TransactionDetails( + 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: 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: TransactionDetails, into buf: inout [UInt8]) { + FfiConverterString.write(value.txId, into: &buf) + FfiConverterInt64.write(value.amountSats, into: &buf) + FfiConverterSequenceTypeTxInput.write(value.inputs, into: &buf) + FfiConverterSequenceTypeTxOutput.write(value.outputs, into: &buf) } } @@ -7255,207 +7616,86 @@ 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 FfiConverterTypeTransactionDetails_lift(_ buf: RustBuffer) throws -> TransactionDetails { + return try FfiConverterTypeTransactionDetails.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeOnChainInvoice_lower(_ value: OnChainInvoice) -> RustBuffer { - return FfiConverterTypeOnChainInvoice.lower(value) +public func FfiConverterTypeTransactionDetails_lower(_ value: TransactionDetails) -> RustBuffer { + return FfiConverterTypeTransactionDetails.lower(value) } -public struct OnchainActivity { - public var id: String - public var txType: PaymentType - public var txId: String - public var value: UInt64 - public var fee: UInt64 - public var feeRate: UInt64 +/** + * Address response from device. + */ +public struct TrezorAddressResponse { + /** + * The Bitcoin address + */ public var address: String - 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 createdAt: UInt64? - public var updatedAt: UInt64? - public var seenAt: UInt64? + /** + * The serialized path (e.g., "m/84'/0'/0'/0/0") + */ + public var path: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(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?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { - self.id = id - self.txType = txType - self.txId = txId - self.value = value - self.fee = fee - self.feeRate = feeRate + public init( + /** + * The Bitcoin address + */address: String, + /** + * The serialized path (e.g., "m/84'/0'/0'/0/0") + */path: String) { self.address = address - 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.createdAt = createdAt - self.updatedAt = updatedAt - self.seenAt = seenAt + self.path = path } } #if compiler(>=6) -extension OnchainActivity: Sendable {} +extension TrezorAddressResponse: Sendable {} #endif -extension OnchainActivity: Equatable, Hashable { - public static func ==(lhs: OnchainActivity, rhs: OnchainActivity) -> Bool { - 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 - } +extension TrezorAddressResponse: Equatable, Hashable { + public static func ==(lhs: TrezorAddressResponse, rhs: TrezorAddressResponse) -> Bool { if lhs.address != rhs.address { return false } - if lhs.confirmed != rhs.confirmed { - 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 { - return false - } - if lhs.createdAt != rhs.createdAt { - return false - } - if lhs.updatedAt != rhs.updatedAt { - return false - } - if lhs.seenAt != rhs.seenAt { + if lhs.path != rhs.path { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(txType) - hasher.combine(txId) - hasher.combine(value) - hasher.combine(fee) - hasher.combine(feeRate) hasher.combine(address) - 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(createdAt) - hasher.combine(updatedAt) - hasher.combine(seenAt) + hasher.combine(path) } } -extension OnchainActivity: Codable {} +extension TrezorAddressResponse: 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 FfiConverterTypeTrezorAddressResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorAddressResponse { return - try OnchainActivity( - 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), + try TrezorAddressResponse( address: FfiConverterString.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), - createdAt: FfiConverterOptionUInt64.read(from: &buf), - updatedAt: FfiConverterOptionUInt64.read(from: &buf), - seenAt: FfiConverterOptionUInt64.read(from: &buf) + path: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: OnchainActivity, into buf: inout [UInt8]) { - 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) + public static func write(_ value: TrezorAddressResponse, into buf: inout [UInt8]) { FfiConverterString.write(value.address, 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) - FfiConverterOptionUInt64.write(value.createdAt, into: &buf) - FfiConverterOptionUInt64.write(value.updatedAt, into: &buf) - FfiConverterOptionUInt64.write(value.seenAt, into: &buf) + FfiConverterString.write(value.path, into: &buf) } } @@ -7463,100 +7703,114 @@ 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 FfiConverterTypeTrezorAddressResponse_lift(_ buf: RustBuffer) throws -> TrezorAddressResponse { + return try FfiConverterTypeTrezorAddressResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeOnchainActivity_lower(_ value: OnchainActivity) -> RustBuffer { - return FfiConverterTypeOnchainActivity.lower(value) +public func FfiConverterTypeTrezorAddressResponse_lower(_ value: TrezorAddressResponse) -> RustBuffer { + return FfiConverterTypeTrezorAddressResponse.lower(value) } /** - * Payment request memo types + * Result from a high-level message call (for BLE/THP devices) */ -public struct PaymentRequestMemo { +public struct TrezorCallMessageResult { /** - * Text memo + * Whether the call succeeded */ - public var textMemo: TextMemo? + public var success: Bool /** - * Refund memo + * Response message type */ - public var refundMemo: RefundMemo? + public var messageType: UInt16 /** - * Coin purchase memo + * Response protobuf data */ - public var coinPurchaseMemo: CoinPurchaseMemo? + public var data: Data + /** + * Error message (empty on success) + */ + public var error: String // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Text memo - */textMemo: TextMemo?, + * Whether the call succeeded + */success: Bool, /** - * Refund memo - */refundMemo: RefundMemo?, + * Response message type + */messageType: UInt16, /** - * Coin purchase memo - */coinPurchaseMemo: CoinPurchaseMemo?) { - self.textMemo = textMemo - self.refundMemo = refundMemo - self.coinPurchaseMemo = coinPurchaseMemo + * Response protobuf data + */data: Data, + /** + * Error message (empty on success) + */error: String) { + self.success = success + self.messageType = messageType + self.data = data + self.error = error } } #if compiler(>=6) -extension PaymentRequestMemo: Sendable {} +extension TrezorCallMessageResult: Sendable {} #endif -extension PaymentRequestMemo: Equatable, Hashable { - public static func ==(lhs: PaymentRequestMemo, rhs: PaymentRequestMemo) -> Bool { - if lhs.textMemo != rhs.textMemo { +extension TrezorCallMessageResult: Equatable, Hashable { + public static func ==(lhs: TrezorCallMessageResult, rhs: TrezorCallMessageResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.refundMemo != rhs.refundMemo { + if lhs.messageType != rhs.messageType { return false } - if lhs.coinPurchaseMemo != rhs.coinPurchaseMemo { + if lhs.data != rhs.data { + return false + } + if lhs.error != rhs.error { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(textMemo) - hasher.combine(refundMemo) - hasher.combine(coinPurchaseMemo) + hasher.combine(success) + hasher.combine(messageType) + hasher.combine(data) + hasher.combine(error) } } -extension PaymentRequestMemo: Codable {} +extension TrezorCallMessageResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePaymentRequestMemo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PaymentRequestMemo { +public struct FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorCallMessageResult { return - try PaymentRequestMemo( - textMemo: FfiConverterOptionTypeTextMemo.read(from: &buf), - refundMemo: FfiConverterOptionTypeRefundMemo.read(from: &buf), - coinPurchaseMemo: FfiConverterOptionTypeCoinPurchaseMemo.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) ) } - public static func write(_ value: PaymentRequestMemo, into buf: inout [UInt8]) { - FfiConverterOptionTypeTextMemo.write(value.textMemo, into: &buf) - FfiConverterOptionTypeRefundMemo.write(value.refundMemo, into: &buf) - FfiConverterOptionTypeCoinPurchaseMemo.write(value.coinPurchaseMemo, 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) } } @@ -7564,135 +7818,156 @@ public struct FfiConverterTypePaymentRequestMemo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePaymentRequestMemo_lift(_ buf: RustBuffer) throws -> PaymentRequestMemo { - return try FfiConverterTypePaymentRequestMemo.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 FfiConverterTypePaymentRequestMemo_lower(_ value: PaymentRequestMemo) -> RustBuffer { - return FfiConverterTypePaymentRequestMemo.lower(value) +public func FfiConverterTypeTrezorCallMessageResult_lower(_ value: TrezorCallMessageResult) -> RustBuffer { + return FfiConverterTypeTrezorCallMessageResult.lower(value) } -public struct PreActivityMetadata { - 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 +/** + * 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? + /** + * Transport-specific path (used internally for connection) + */ + public var path: String + /** + * Device label (set by user during device setup) + */ + public var label: String? + /** + * Device model (e.g., "T2", "Safe 5", "Safe 7") + */ + 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(paymentId: String, tags: [String], paymentHash: String?, txId: String?, address: String?, isReceive: Bool, feeRate: UInt64, isTransfer: Bool, channelId: String?, createdAt: UInt64) { - 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( + /** + * 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, + /** + * Device label (set by user during device setup) + */label: String?, + /** + * 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 PreActivityMetadata: Sendable {} +extension TrezorDeviceInfo: Sendable {} #endif -extension PreActivityMetadata: Equatable, Hashable { - public static func ==(lhs: PreActivityMetadata, rhs: PreActivityMetadata) -> Bool { - 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 { +extension TrezorDeviceInfo: Equatable, Hashable { + public static func ==(lhs: TrezorDeviceInfo, rhs: TrezorDeviceInfo) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.address != rhs.address { + if lhs.transportType != rhs.transportType { return false } - if lhs.isReceive != rhs.isReceive { + if lhs.name != rhs.name { return false } - if lhs.feeRate != rhs.feeRate { + if lhs.path != rhs.path { return false } - if lhs.isTransfer != rhs.isTransfer { + if lhs.label != rhs.label { return false } - if lhs.channelId != rhs.channelId { + if lhs.model != rhs.model { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.isBootloader != rhs.isBootloader { return false } return true } public func hash(into hasher: inout Hasher) { - 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(id) + hasher.combine(transportType) + hasher.combine(name) + hasher.combine(path) + hasher.combine(label) + hasher.combine(model) + hasher.combine(isBootloader) } } -extension PreActivityMetadata: Codable {} +extension TrezorDeviceInfo: 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 FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorDeviceInfo { return - try PreActivityMetadata( - 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 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: PreActivityMetadata, into buf: inout [UInt8]) { - 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: 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) } } @@ -7700,128 +7975,212 @@ 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 FfiConverterTypeTrezorDeviceInfo_lift(_ buf: RustBuffer) throws -> TrezorDeviceInfo { + return try FfiConverterTypeTrezorDeviceInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePreActivityMetadata_lower(_ value: PreActivityMetadata) -> RustBuffer { - return FfiConverterTypePreActivityMetadata.lower(value) +public func FfiConverterTypeTrezorDeviceInfo_lower(_ value: TrezorDeviceInfo) -> RustBuffer { + return FfiConverterTypeTrezorDeviceInfo.lower(value) } /** - * Precomposed transaction input + * Device features after initialization. */ -public struct PrecomposedInput { +public struct TrezorFeatures { /** - * BIP32 derivation path + * Vendor string */ - public var addressN: [UInt32] + public var vendor: String? /** - * Amount in satoshis + * Device model */ - public var amount: String + public var model: String? /** - * Previous transaction hash + * Device label (set by user during device setup) */ - public var prevHash: String + public var label: String? /** - * Previous output index + * Device ID (unique per device) */ - public var prevIndex: UInt32 + public var deviceId: String? /** - * Script type + * Major firmware version + */ + 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 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 scriptType: ScriptType + public var needsBackup: Bool? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * BIP32 derivation path - */addressN: [UInt32], + * Vendor string + */vendor: String?, /** - * Amount in satoshis - */amount: String, + * Device model + */model: String?, /** - * Previous transaction hash - */prevHash: String, + * Device label (set by user during device setup) + */label: String?, /** - * Previous output index - */prevIndex: UInt32, + * Device ID (unique per device) + */deviceId: String?, /** - * Script type - */scriptType: ScriptType) { - self.addressN = addressN - self.amount = amount - self.prevHash = prevHash - self.prevIndex = prevIndex - self.scriptType = scriptType + * Major firmware version + */majorVersion: UInt32?, + /** + * Minor firmware version + */minorVersion: UInt32?, + /** + * Patch firmware version + */patchVersion: UInt32?, + /** + * Whether PIN protection is enabled + */pinProtection: 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?) { + 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.passphraseProtection = passphraseProtection + self.initialized = initialized + self.needsBackup = needsBackup } } #if compiler(>=6) -extension PrecomposedInput: Sendable {} +extension TrezorFeatures: Sendable {} #endif -extension PrecomposedInput: Equatable, Hashable { - public static func ==(lhs: PrecomposedInput, rhs: PrecomposedInput) -> Bool { - if lhs.addressN != rhs.addressN { +extension TrezorFeatures: Equatable, Hashable { + public static func ==(lhs: TrezorFeatures, rhs: TrezorFeatures) -> Bool { + if lhs.vendor != rhs.vendor { return false } - if lhs.amount != rhs.amount { + if lhs.model != rhs.model { return false } - if lhs.prevHash != rhs.prevHash { + if lhs.label != rhs.label { return false } - if lhs.prevIndex != rhs.prevIndex { + if lhs.deviceId != rhs.deviceId { return false } - if lhs.scriptType != rhs.scriptType { + 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.passphraseProtection != rhs.passphraseProtection { + return false + } + if lhs.initialized != rhs.initialized { + return false + } + if lhs.needsBackup != rhs.needsBackup { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(addressN) - hasher.combine(amount) - hasher.combine(prevHash) - hasher.combine(prevIndex) - hasher.combine(scriptType) + 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(passphraseProtection) + hasher.combine(initialized) + hasher.combine(needsBackup) } } -extension PrecomposedInput: Codable {} +extension TrezorFeatures: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePrecomposedInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrecomposedInput { +public struct FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorFeatures { return - try PrecomposedInput( - addressN: FfiConverterSequenceUInt32.read(from: &buf), - amount: FfiConverterString.read(from: &buf), - prevHash: FfiConverterString.read(from: &buf), - prevIndex: FfiConverterUInt32.read(from: &buf), - scriptType: FfiConverterTypeScriptType.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), + passphraseProtection: FfiConverterOptionBool.read(from: &buf), + initialized: FfiConverterOptionBool.read(from: &buf), + needsBackup: FfiConverterOptionBool.read(from: &buf) ) } - public static func write(_ value: PrecomposedInput, into buf: inout [UInt8]) { - FfiConverterSequenceUInt32.write(value.addressN, into: &buf) - FfiConverterString.write(value.amount, into: &buf) - FfiConverterString.write(value.prevHash, into: &buf) - FfiConverterUInt32.write(value.prevIndex, into: &buf) - FfiConverterTypeScriptType.write(value.scriptType, 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.passphraseProtection, into: &buf) + FfiConverterOptionBool.write(value.initialized, into: &buf) + FfiConverterOptionBool.write(value.needsBackup, into: &buf) } } @@ -7829,75 +8188,75 @@ public struct FfiConverterTypePrecomposedInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePrecomposedInput_lift(_ buf: RustBuffer) throws -> PrecomposedInput { - return try FfiConverterTypePrecomposedInput.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 FfiConverterTypePrecomposedInput_lower(_ value: PrecomposedInput) -> RustBuffer { - return FfiConverterTypePrecomposedInput.lower(value) +public func FfiConverterTypeTrezorFeatures_lower(_ value: TrezorFeatures) -> RustBuffer { + return FfiConverterTypeTrezorFeatures.lower(value) } /** - * Precomposed transaction output + * Parameters for getting an address from the device. */ -public struct PrecomposedOutput { +public struct TrezorGetAddressParams { /** - * BIP32 derivation path (for change outputs) + * BIP32 path (e.g., "m/84'/0'/0'/0/0") */ - public var addressN: [UInt32]? + public var path: String /** - * Amount in satoshis + * Coin network (default: Bitcoin) */ - public var amount: String + public var coin: TrezorCoinType? /** - * Address (for regular outputs) + * Whether to display the address on the device for confirmation */ - public var address: String? + public var showOnTrezor: Bool /** - * Script type + * Script type (auto-detected from path if not specified) */ - public var scriptType: ScriptType + public var scriptType: TrezorScriptType? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * BIP32 derivation path (for change outputs) - */addressN: [UInt32]?, + * BIP32 path (e.g., "m/84'/0'/0'/0/0") + */path: String, /** - * Amount in satoshis - */amount: String, + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?, /** - * Address (for regular outputs) - */address: String?, + * Whether to display the address on the device for confirmation + */showOnTrezor: Bool, /** - * Script type - */scriptType: ScriptType) { - self.addressN = addressN - self.amount = amount - self.address = address + * 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 PrecomposedOutput: Sendable {} +extension TrezorGetAddressParams: Sendable {} #endif -extension PrecomposedOutput: Equatable, Hashable { - public static func ==(lhs: PrecomposedOutput, rhs: PrecomposedOutput) -> Bool { - if lhs.addressN != rhs.addressN { +extension TrezorGetAddressParams: Equatable, Hashable { + public static func ==(lhs: TrezorGetAddressParams, rhs: TrezorGetAddressParams) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.amount != rhs.amount { + if lhs.coin != rhs.coin { return false } - if lhs.address != rhs.address { + if lhs.showOnTrezor != rhs.showOnTrezor { return false } if lhs.scriptType != rhs.scriptType { @@ -7907,36 +8266,36 @@ extension PrecomposedOutput: Equatable, Hashable { } public func hash(into hasher: inout Hasher) { - hasher.combine(addressN) - hasher.combine(amount) - hasher.combine(address) + hasher.combine(path) + hasher.combine(coin) + hasher.combine(showOnTrezor) hasher.combine(scriptType) } } -extension PrecomposedOutput: Codable {} +extension TrezorGetAddressParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePrecomposedOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrecomposedOutput { +public struct FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetAddressParams { return - try PrecomposedOutput( - addressN: FfiConverterOptionSequenceUInt32.read(from: &buf), - amount: FfiConverterString.read(from: &buf), - address: FfiConverterOptionString.read(from: &buf), - scriptType: FfiConverterTypeScriptType.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: PrecomposedOutput, into buf: inout [UInt8]) { - FfiConverterOptionSequenceUInt32.write(value.addressN, into: &buf) - FfiConverterString.write(value.amount, into: &buf) - FfiConverterOptionString.write(value.address, into: &buf) - FfiConverterTypeScriptType.write(value.scriptType, 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) } } @@ -7944,113 +8303,184 @@ public struct FfiConverterTypePrecomposedOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePrecomposedOutput_lift(_ buf: RustBuffer) throws -> PrecomposedOutput { - return try FfiConverterTypePrecomposedOutput.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 FfiConverterTypePrecomposedOutput_lower(_ value: PrecomposedOutput) -> RustBuffer { - return FfiConverterTypePrecomposedOutput.lower(value) +public func FfiConverterTypeTrezorGetAddressParams_lower(_ value: TrezorGetAddressParams) -> RustBuffer { + return FfiConverterTypeTrezorGetAddressParams.lower(value) } /** - * Precomposed transaction + * Parameters for getting a public key from the device. */ -public struct PrecomposedTransaction { +public struct TrezorGetPublicKeyParams { + /** + * BIP32 path (e.g., "m/84'/0'/0'") + */ + public var path: String /** - * Transaction type (usually "final" or "error") + * Coin network (default: Bitcoin) */ - public var txType: String + public var coin: TrezorCoinType? /** - * Total amount spent (including fee) + * Whether to display on device for confirmation */ - public var totalSpent: String? + 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 { /** - * Transaction fee + * Transaction hash (hex encoded) */ - public var fee: String? + public var hash: String /** - * Fee per byte + * Transaction version */ - public var feePerByte: String? + public var version: UInt32 /** - * Transaction size in bytes + * Lock time */ - public var bytes: UInt32? + public var lockTime: UInt32 /** * Transaction inputs */ - public var inputs: [PrecomposedInput]? + public var inputs: [TrezorPrevTxInput] /** * Transaction outputs */ - public var outputs: [PrecomposedOutput]? - /** - * Output permutation indices - */ - public var outputsPermutation: [UInt32]? + public var outputs: [TrezorPrevTxOutput] // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Transaction type (usually "final" or "error") - */txType: String, - /** - * Total amount spent (including fee) - */totalSpent: String?, - /** - * Transaction fee - */fee: String?, + * Transaction hash (hex encoded) + */hash: String, /** - * Fee per byte - */feePerByte: String?, + * Transaction version + */version: UInt32, /** - * Transaction size in bytes - */bytes: UInt32?, + * Lock time + */lockTime: UInt32, /** * Transaction inputs - */inputs: [PrecomposedInput]?, + */inputs: [TrezorPrevTxInput], /** * Transaction outputs - */outputs: [PrecomposedOutput]?, - /** - * Output permutation indices - */outputsPermutation: [UInt32]?) { - self.txType = txType - self.totalSpent = totalSpent - self.fee = fee - self.feePerByte = feePerByte - self.bytes = bytes + */outputs: [TrezorPrevTxOutput]) { + self.hash = hash + self.version = version + self.lockTime = lockTime self.inputs = inputs self.outputs = outputs - self.outputsPermutation = outputsPermutation } } #if compiler(>=6) -extension PrecomposedTransaction: Sendable {} +extension TrezorPrevTx: Sendable {} #endif -extension PrecomposedTransaction: Equatable, Hashable { - public static func ==(lhs: PrecomposedTransaction, rhs: PrecomposedTransaction) -> Bool { - if lhs.txType != rhs.txType { - return false - } - if lhs.totalSpent != rhs.totalSpent { - return false - } - if lhs.fee != rhs.fee { +extension TrezorPrevTx: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTx, rhs: TrezorPrevTx) -> Bool { + if lhs.hash != rhs.hash { return false } - if lhs.feePerByte != rhs.feePerByte { + if lhs.version != rhs.version { return false } - if lhs.bytes != rhs.bytes { + if lhs.lockTime != rhs.lockTime { return false } if lhs.inputs != rhs.inputs { @@ -8059,55 +8489,43 @@ extension PrecomposedTransaction: Equatable, Hashable { if lhs.outputs != rhs.outputs { return false } - if lhs.outputsPermutation != rhs.outputsPermutation { - return false - } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txType) - hasher.combine(totalSpent) - hasher.combine(fee) - hasher.combine(feePerByte) - hasher.combine(bytes) + hasher.combine(hash) + hasher.combine(version) + hasher.combine(lockTime) hasher.combine(inputs) hasher.combine(outputs) - hasher.combine(outputsPermutation) } } -extension PrecomposedTransaction: Codable {} +extension TrezorPrevTx: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePrecomposedTransaction: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrecomposedTransaction { +public struct FfiConverterTypeTrezorPrevTx: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTx { return - try PrecomposedTransaction( - txType: FfiConverterString.read(from: &buf), - totalSpent: FfiConverterOptionString.read(from: &buf), - fee: FfiConverterOptionString.read(from: &buf), - feePerByte: FfiConverterOptionString.read(from: &buf), - bytes: FfiConverterOptionUInt32.read(from: &buf), - inputs: FfiConverterOptionSequenceTypePrecomposedInput.read(from: &buf), - outputs: FfiConverterOptionSequenceTypePrecomposedOutput.read(from: &buf), - outputsPermutation: FfiConverterOptionSequenceUInt32.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: PrecomposedTransaction, into buf: inout [UInt8]) { - FfiConverterString.write(value.txType, into: &buf) - FfiConverterOptionString.write(value.totalSpent, into: &buf) - FfiConverterOptionString.write(value.fee, into: &buf) - FfiConverterOptionString.write(value.feePerByte, into: &buf) - FfiConverterOptionUInt32.write(value.bytes, into: &buf) - FfiConverterOptionSequenceTypePrecomposedInput.write(value.inputs, into: &buf) - FfiConverterOptionSequenceTypePrecomposedOutput.write(value.outputs, into: &buf) - FfiConverterOptionSequenceUInt32.write(value.outputsPermutation, 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) } } @@ -8115,63 +8533,114 @@ public struct FfiConverterTypePrecomposedTransaction: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePrecomposedTransaction_lift(_ buf: RustBuffer) throws -> PrecomposedTransaction { - return try FfiConverterTypePrecomposedTransaction.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 FfiConverterTypePrecomposedTransaction_lower(_ value: PrecomposedTransaction) -> RustBuffer { - return FfiConverterTypePrecomposedTransaction.lower(value) +public func FfiConverterTypeTrezorPrevTx_lower(_ value: TrezorPrevTx) -> RustBuffer { + return FfiConverterTypeTrezorPrevTx.lower(value) } -public struct PubkyAuth { - public var data: String +/** + * Input of a previous transaction. + */ +public struct TrezorPrevTxInput { + /** + * Previous transaction hash (hex encoded) + */ + public var prevHash: String + /** + * Previous output index + */ + public var prevIndex: UInt32 + /** + * Script signature (hex encoded) + */ + public var scriptSig: String + /** + * Sequence number + */ + public var sequence: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(data: String) { - self.data = data + public init( + /** + * Previous transaction hash (hex encoded) + */prevHash: String, + /** + * Previous output index + */prevIndex: UInt32, + /** + * Script signature (hex encoded) + */scriptSig: String, + /** + * Sequence number + */sequence: UInt32) { + self.prevHash = prevHash + self.prevIndex = prevIndex + self.scriptSig = scriptSig + self.sequence = sequence } } #if compiler(>=6) -extension PubkyAuth: Sendable {} +extension TrezorPrevTxInput: Sendable {} #endif -extension PubkyAuth: Equatable, Hashable { - public static func ==(lhs: PubkyAuth, rhs: PubkyAuth) -> Bool { - if lhs.data != rhs.data { +extension TrezorPrevTxInput: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTxInput, rhs: TrezorPrevTxInput) -> Bool { + if lhs.prevHash != rhs.prevHash { + return false + } + if lhs.prevIndex != rhs.prevIndex { + return false + } + if lhs.scriptSig != rhs.scriptSig { + return false + } + if lhs.sequence != rhs.sequence { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(data) + hasher.combine(prevHash) + hasher.combine(prevIndex) + hasher.combine(scriptSig) + hasher.combine(sequence) } } -extension PubkyAuth: Codable {} +extension TrezorPrevTxInput: 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 FfiConverterTypeTrezorPrevTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxInput { return - try PubkyAuth( - data: FfiConverterString.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: PubkyAuth, into buf: inout [UInt8]) { - FfiConverterString.write(value.data, 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) } } @@ -8179,138 +8648,86 @@ 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 FfiConverterTypeTrezorPrevTxInput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxInput { + return try FfiConverterTypeTrezorPrevTxInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyAuth_lower(_ value: PubkyAuth) -> RustBuffer { - return FfiConverterTypePubkyAuth.lower(value) +public func FfiConverterTypeTrezorPrevTxInput_lower(_ value: TrezorPrevTxInput) -> RustBuffer { + return FfiConverterTypeTrezorPrevTxInput.lower(value) } /** - * Public key response containing the derived public key information + * Output of a previous transaction. */ -public struct PublicKeyResponse { - public var path: [UInt32] - public var serializedPath: String - public var xpub: String - public var xpubSegwit: String? - public var chainCode: String - public var childNum: UInt32 - public var publicKey: String - public var fingerprint: UInt32 - public var depth: UInt32 - public var descriptor: String? +public struct TrezorPrevTxOutput { + /** + * Amount in satoshis + */ + public var amount: UInt64 + /** + * Script pubkey (hex encoded) + */ + public var scriptPubkey: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(path: [UInt32], serializedPath: String, xpub: String, xpubSegwit: String?, chainCode: String, childNum: UInt32, publicKey: String, fingerprint: UInt32, depth: UInt32, descriptor: String?) { - self.path = path - self.serializedPath = serializedPath - self.xpub = xpub - self.xpubSegwit = xpubSegwit - self.chainCode = chainCode - self.childNum = childNum - self.publicKey = publicKey - self.fingerprint = fingerprint - self.depth = depth - self.descriptor = descriptor + public init( + /** + * Amount in satoshis + */amount: UInt64, + /** + * Script pubkey (hex encoded) + */scriptPubkey: String) { + self.amount = amount + self.scriptPubkey = scriptPubkey } } #if compiler(>=6) -extension PublicKeyResponse: Sendable {} +extension TrezorPrevTxOutput: Sendable {} #endif -extension PublicKeyResponse: Equatable, Hashable { - public static func ==(lhs: PublicKeyResponse, rhs: PublicKeyResponse) -> Bool { - if lhs.path != rhs.path { - return false - } - if lhs.serializedPath != rhs.serializedPath { - return false - } - if lhs.xpub != rhs.xpub { - return false - } - if lhs.xpubSegwit != rhs.xpubSegwit { - return false - } - if lhs.chainCode != rhs.chainCode { - return false - } - if lhs.childNum != rhs.childNum { - return false - } - if lhs.publicKey != rhs.publicKey { - return false - } - if lhs.fingerprint != rhs.fingerprint { - return false - } - if lhs.depth != rhs.depth { +extension TrezorPrevTxOutput: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTxOutput, rhs: TrezorPrevTxOutput) -> Bool { + if lhs.amount != rhs.amount { return false } - if lhs.descriptor != rhs.descriptor { + if lhs.scriptPubkey != rhs.scriptPubkey { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(serializedPath) - hasher.combine(xpub) - hasher.combine(xpubSegwit) - hasher.combine(chainCode) - hasher.combine(childNum) - hasher.combine(publicKey) - hasher.combine(fingerprint) - hasher.combine(depth) - hasher.combine(descriptor) + hasher.combine(amount) + hasher.combine(scriptPubkey) } } -extension PublicKeyResponse: Codable {} +extension TrezorPrevTxOutput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePublicKeyResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PublicKeyResponse { +public struct FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxOutput { return - try PublicKeyResponse( - path: FfiConverterSequenceUInt32.read(from: &buf), - serializedPath: FfiConverterString.read(from: &buf), - xpub: FfiConverterString.read(from: &buf), - xpubSegwit: FfiConverterOptionString.read(from: &buf), - chainCode: FfiConverterString.read(from: &buf), - childNum: FfiConverterUInt32.read(from: &buf), - publicKey: FfiConverterString.read(from: &buf), - fingerprint: FfiConverterUInt32.read(from: &buf), - depth: FfiConverterUInt32.read(from: &buf), - descriptor: FfiConverterOptionString.read(from: &buf) + try TrezorPrevTxOutput( + amount: FfiConverterUInt64.read(from: &buf), + scriptPubkey: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: PublicKeyResponse, into buf: inout [UInt8]) { - FfiConverterSequenceUInt32.write(value.path, into: &buf) - FfiConverterString.write(value.serializedPath, into: &buf) - FfiConverterString.write(value.xpub, into: &buf) - FfiConverterOptionString.write(value.xpubSegwit, into: &buf) - FfiConverterString.write(value.chainCode, into: &buf) - FfiConverterUInt32.write(value.childNum, into: &buf) - FfiConverterString.write(value.publicKey, into: &buf) - FfiConverterUInt32.write(value.fingerprint, into: &buf) - FfiConverterUInt32.write(value.depth, into: &buf) - FfiConverterOptionString.write(value.descriptor, into: &buf) + public static func write(_ value: TrezorPrevTxOutput, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterString.write(value.scriptPubkey, into: &buf) } } @@ -8318,212 +8735,156 @@ public struct FfiConverterTypePublicKeyResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePublicKeyResponse_lift(_ buf: RustBuffer) throws -> PublicKeyResponse { - return try FfiConverterTypePublicKeyResponse.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 FfiConverterTypePublicKeyResponse_lower(_ value: PublicKeyResponse) -> RustBuffer { - return FfiConverterTypePublicKeyResponse.lower(value) +public func FfiConverterTypeTrezorPrevTxOutput_lower(_ value: TrezorPrevTxOutput) -> RustBuffer { + return FfiConverterTypeTrezorPrevTxOutput.lower(value) } /** - * Reference transaction for transaction signing + * Public key response from device. */ -public struct RefTransaction { +public struct TrezorPublicKeyResponse { /** - * Transaction hash + * Extended public key (xpub) */ - public var hash: String + public var xpub: String /** - * Transaction version + * The serialized path (e.g., "m/84'/0'/0'") */ - public var version: UInt32? + public var path: String /** - * Transaction inputs + * Compressed public key (hex encoded) */ - public var inputs: [RefTxInput] - /** - * Transaction outputs (binary format) - */ - public var binOutputs: [RefTxOutput] - /** - * Lock time - */ - public var lockTime: UInt32? - /** - * Expiry (for Zcash/Decred) - */ - public var expiry: UInt32? - /** - * Version group ID (for Zcash) - */ - public var versionGroupId: UInt32? + public var publicKey: String /** - * Overwintered flag (for Zcash) + * Chain code (hex encoded) */ - public var overwintered: Bool? + public var chainCode: String /** - * Timestamp (for Capricoin) + * Parent key fingerprint */ - public var timestamp: UInt32? + public var fingerprint: UInt32 /** - * Branch ID (for Zcash) + * Derivation depth */ - public var branchId: UInt32? + public var depth: UInt32 /** - * Extra data + * Master root fingerprint (from the device's master seed) */ - public var extraData: String? + public var rootFingerprint: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Transaction hash - */hash: String, - /** - * Transaction version - */version: UInt32?, - /** - * Transaction inputs - */inputs: [RefTxInput], - /** - * Transaction outputs (binary format) - */binOutputs: [RefTxOutput], - /** - * Lock time - */lockTime: UInt32?, + * Extended public key (xpub) + */xpub: String, /** - * Expiry (for Zcash/Decred) - */expiry: UInt32?, + * The serialized path (e.g., "m/84'/0'/0'") + */path: String, /** - * Version group ID (for Zcash) - */versionGroupId: UInt32?, + * Compressed public key (hex encoded) + */publicKey: String, /** - * Overwintered flag (for Zcash) - */overwintered: Bool?, + * Chain code (hex encoded) + */chainCode: String, /** - * Timestamp (for Capricoin) - */timestamp: UInt32?, + * Parent key fingerprint + */fingerprint: UInt32, /** - * Branch ID (for Zcash) - */branchId: UInt32?, + * Derivation depth + */depth: UInt32, /** - * Extra data - */extraData: String?) { - self.hash = hash - self.version = version - self.inputs = inputs - self.binOutputs = binOutputs - self.lockTime = lockTime - self.expiry = expiry - self.versionGroupId = versionGroupId - self.overwintered = overwintered - self.timestamp = timestamp - self.branchId = branchId - self.extraData = extraData + * 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 RefTransaction: Sendable {} +extension TrezorPublicKeyResponse: Sendable {} #endif -extension RefTransaction: Equatable, Hashable { - public static func ==(lhs: RefTransaction, rhs: RefTransaction) -> Bool { - if lhs.hash != rhs.hash { - return false - } - if lhs.version != rhs.version { - return false - } - if lhs.inputs != rhs.inputs { - return false - } - if lhs.binOutputs != rhs.binOutputs { - return false - } - if lhs.lockTime != rhs.lockTime { +extension TrezorPublicKeyResponse: Equatable, Hashable { + public static func ==(lhs: TrezorPublicKeyResponse, rhs: TrezorPublicKeyResponse) -> Bool { + if lhs.xpub != rhs.xpub { return false } - if lhs.expiry != rhs.expiry { + if lhs.path != rhs.path { return false } - if lhs.versionGroupId != rhs.versionGroupId { + if lhs.publicKey != rhs.publicKey { return false } - if lhs.overwintered != rhs.overwintered { + if lhs.chainCode != rhs.chainCode { return false } - if lhs.timestamp != rhs.timestamp { + if lhs.fingerprint != rhs.fingerprint { return false } - if lhs.branchId != rhs.branchId { + if lhs.depth != rhs.depth { return false } - if lhs.extraData != rhs.extraData { + if lhs.rootFingerprint != rhs.rootFingerprint { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(hash) - hasher.combine(version) - hasher.combine(inputs) - hasher.combine(binOutputs) - hasher.combine(lockTime) - hasher.combine(expiry) - hasher.combine(versionGroupId) - hasher.combine(overwintered) - hasher.combine(timestamp) - hasher.combine(branchId) - hasher.combine(extraData) + hasher.combine(xpub) + hasher.combine(path) + hasher.combine(publicKey) + hasher.combine(chainCode) + hasher.combine(fingerprint) + hasher.combine(depth) + hasher.combine(rootFingerprint) } } -extension RefTransaction: Codable {} +extension TrezorPublicKeyResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeRefTransaction: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RefTransaction { +public struct FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPublicKeyResponse { return - try RefTransaction( - hash: FfiConverterString.read(from: &buf), - version: FfiConverterOptionUInt32.read(from: &buf), - inputs: FfiConverterSequenceTypeRefTxInput.read(from: &buf), - binOutputs: FfiConverterSequenceTypeRefTxOutput.read(from: &buf), - lockTime: FfiConverterOptionUInt32.read(from: &buf), - expiry: FfiConverterOptionUInt32.read(from: &buf), - versionGroupId: FfiConverterOptionUInt32.read(from: &buf), - overwintered: FfiConverterOptionBool.read(from: &buf), - timestamp: FfiConverterOptionUInt32.read(from: &buf), - branchId: FfiConverterOptionUInt32.read(from: &buf), - extraData: FfiConverterOptionString.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: RefTransaction, into buf: inout [UInt8]) { - FfiConverterString.write(value.hash, into: &buf) - FfiConverterOptionUInt32.write(value.version, into: &buf) - FfiConverterSequenceTypeRefTxInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeRefTxOutput.write(value.binOutputs, into: &buf) - FfiConverterOptionUInt32.write(value.lockTime, into: &buf) - FfiConverterOptionUInt32.write(value.expiry, into: &buf) - FfiConverterOptionUInt32.write(value.versionGroupId, into: &buf) - FfiConverterOptionBool.write(value.overwintered, into: &buf) - FfiConverterOptionUInt32.write(value.timestamp, into: &buf) - FfiConverterOptionUInt32.write(value.branchId, into: &buf) - FfiConverterOptionString.write(value.extraData, 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) } } @@ -8531,114 +8892,100 @@ public struct FfiConverterTypeRefTransaction: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeRefTransaction_lift(_ buf: RustBuffer) throws -> RefTransaction { - return try FfiConverterTypeRefTransaction.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 FfiConverterTypeRefTransaction_lower(_ value: RefTransaction) -> RustBuffer { - return FfiConverterTypeRefTransaction.lower(value) +public func FfiConverterTypeTrezorPublicKeyResponse_lower(_ value: TrezorPublicKeyResponse) -> RustBuffer { + return FfiConverterTypeTrezorPublicKeyResponse.lower(value) } /** - * Reference transaction input + * Parameters for signing a message. */ -public struct RefTxInput { +public struct TrezorSignMessageParams { /** - * Previous transaction hash + * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") */ - public var prevHash: String - /** - * Previous transaction output index - */ - public var prevIndex: UInt32 + public var path: String /** - * Script signature + * Message to sign */ - public var scriptSig: String + public var message: String /** - * Sequence number + * Coin network (default: Bitcoin) */ - public var sequence: UInt32 + public var coin: TrezorCoinType? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Previous transaction hash - */prevHash: String, - /** - * Previous transaction output index - */prevIndex: UInt32, + * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") + */path: String, /** - * Script signature - */scriptSig: String, + * Message to sign + */message: String, /** - * Sequence number - */sequence: UInt32) { - self.prevHash = prevHash - self.prevIndex = prevIndex - self.scriptSig = scriptSig - self.sequence = sequence + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?) { + self.path = path + self.message = message + self.coin = coin } } #if compiler(>=6) -extension RefTxInput: Sendable {} +extension TrezorSignMessageParams: Sendable {} #endif -extension RefTxInput: Equatable, Hashable { - public static func ==(lhs: RefTxInput, rhs: RefTxInput) -> Bool { - if lhs.prevHash != rhs.prevHash { - return false - } - if lhs.prevIndex != rhs.prevIndex { +extension TrezorSignMessageParams: Equatable, Hashable { + public static func ==(lhs: TrezorSignMessageParams, rhs: TrezorSignMessageParams) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.scriptSig != rhs.scriptSig { + if lhs.message != rhs.message { return false } - if lhs.sequence != rhs.sequence { + if lhs.coin != rhs.coin { 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(path) + hasher.combine(message) + hasher.combine(coin) } } -extension RefTxInput: Codable {} +extension TrezorSignMessageParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeRefTxInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RefTxInput { +public struct FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignMessageParams { return - try RefTxInput( - prevHash: FfiConverterString.read(from: &buf), - prevIndex: FfiConverterUInt32.read(from: &buf), - scriptSig: FfiConverterString.read(from: &buf), - sequence: FfiConverterUInt32.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: RefTxInput, 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: TrezorSignMessageParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, into: &buf) + FfiConverterString.write(value.message, into: &buf) + FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) } } @@ -8646,86 +8993,142 @@ public struct FfiConverterTypeRefTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeRefTxInput_lift(_ buf: RustBuffer) throws -> RefTxInput { - return try FfiConverterTypeRefTxInput.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 FfiConverterTypeRefTxInput_lower(_ value: RefTxInput) -> RustBuffer { - return FfiConverterTypeRefTxInput.lower(value) +public func FfiConverterTypeTrezorSignMessageParams_lower(_ value: TrezorSignMessageParams) -> RustBuffer { + return FfiConverterTypeTrezorSignMessageParams.lower(value) } /** - * Reference transaction output (binary format) + * Parameters for signing a transaction. */ -public struct RefTxOutput { +public struct TrezorSignTxParams { /** - * Amount in satoshis + * Transaction inputs */ - public var amount: UInt64 + public var inputs: [TrezorTxInput] + /** + * Transaction outputs + */ + public var outputs: [TrezorTxOutput] /** - * Script public key (binary hex) + * Coin network (default: Bitcoin) */ - public var scriptPubkey: String + public var coin: TrezorCoinType? + /** + * Lock time (default: 0) + */ + public var lockTime: UInt32? + /** + * Version (default: 2) + */ + 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( /** - * Amount in satoshis - */amount: UInt64, + * Transaction inputs + */inputs: [TrezorTxInput], /** - * Script public key (binary hex) - */scriptPubkey: String) { - self.amount = amount - self.scriptPubkey = scriptPubkey + * Transaction outputs + */outputs: [TrezorTxOutput], + /** + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?, + /** + * Lock time (default: 0) + */lockTime: UInt32?, + /** + * 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 RefTxOutput: Sendable {} +extension TrezorSignTxParams: Sendable {} #endif -extension RefTxOutput: Equatable, Hashable { - public static func ==(lhs: RefTxOutput, rhs: RefTxOutput) -> Bool { - if lhs.amount != rhs.amount { +extension TrezorSignTxParams: Equatable, Hashable { + public static func ==(lhs: TrezorSignTxParams, rhs: TrezorSignTxParams) -> Bool { + if lhs.inputs != rhs.inputs { return false } - if lhs.scriptPubkey != rhs.scriptPubkey { + if lhs.outputs != rhs.outputs { + return false + } + if lhs.coin != rhs.coin { + return false + } + if lhs.lockTime != rhs.lockTime { + return false + } + 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(amount) - hasher.combine(scriptPubkey) + hasher.combine(inputs) + hasher.combine(outputs) + hasher.combine(coin) + hasher.combine(lockTime) + hasher.combine(version) + hasher.combine(prevTxs) } } -extension RefTxOutput: Codable {} +extension TrezorSignTxParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeRefTxOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RefTxOutput { +public struct FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignTxParams { return - try RefTxOutput( - amount: FfiConverterUInt64.read(from: &buf), - scriptPubkey: FfiConverterString.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: RefTxOutput, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterString.write(value.scriptPubkey, 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) } } @@ -8733,56 +9136,56 @@ public struct FfiConverterTypeRefTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeRefTxOutput_lift(_ buf: RustBuffer) throws -> RefTxOutput { - return try FfiConverterTypeRefTxOutput.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 FfiConverterTypeRefTxOutput_lower(_ value: RefTxOutput) -> RustBuffer { - return FfiConverterTypeRefTxOutput.lower(value) +public func FfiConverterTypeTrezorSignTxParams_lower(_ value: TrezorSignTxParams) -> RustBuffer { + return FfiConverterTypeTrezorSignTxParams.lower(value) } /** - * Refund memo + * Response from signing a message. */ -public struct RefundMemo { +public struct TrezorSignedMessageResponse { /** - * Refund address + * Bitcoin address that signed the message */ public var address: String /** - * MAC + * Signature (base64 encoded) */ - public var mac: String + public var signature: String // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Refund address + * Bitcoin address that signed the message */address: String, /** - * MAC - */mac: String) { + * Signature (base64 encoded) + */signature: String) { self.address = address - self.mac = mac + self.signature = signature } } #if compiler(>=6) -extension RefundMemo: Sendable {} +extension TrezorSignedMessageResponse: Sendable {} #endif -extension RefundMemo: Equatable, Hashable { - public static func ==(lhs: RefundMemo, rhs: RefundMemo) -> Bool { +extension TrezorSignedMessageResponse: Equatable, Hashable { + public static func ==(lhs: TrezorSignedMessageResponse, rhs: TrezorSignedMessageResponse) -> Bool { if lhs.address != rhs.address { return false } - if lhs.mac != rhs.mac { + if lhs.signature != rhs.signature { return false } return true @@ -8790,29 +9193,29 @@ extension RefundMemo: Equatable, Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(address) - hasher.combine(mac) + hasher.combine(signature) } } -extension RefundMemo: Codable {} +extension TrezorSignedMessageResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeRefundMemo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RefundMemo { +public struct FfiConverterTypeTrezorSignedMessageResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedMessageResponse { return - try RefundMemo( + try TrezorSignedMessageResponse( address: FfiConverterString.read(from: &buf), - mac: FfiConverterString.read(from: &buf) + signature: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: RefundMemo, into buf: inout [UInt8]) { + public static func write(_ value: TrezorSignedMessageResponse, into buf: inout [UInt8]) { FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.mac, into: &buf) + FfiConverterString.write(value.signature, into: &buf) } } @@ -8820,100 +9223,86 @@ public struct FfiConverterTypeRefundMemo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeRefundMemo_lift(_ buf: RustBuffer) throws -> RefundMemo { - return try FfiConverterTypeRefundMemo.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 FfiConverterTypeRefundMemo_lower(_ value: RefundMemo) -> RustBuffer { - return FfiConverterTypeRefundMemo.lower(value) +public func FfiConverterTypeTrezorSignedMessageResponse_lower(_ value: TrezorSignedMessageResponse) -> RustBuffer { + return FfiConverterTypeTrezorSignedMessageResponse.lower(value) } /** - * Signed transaction response + * Signed transaction result. */ -public struct SignedTransactionResponse { +public struct TrezorSignedTx { /** - * Array of signer signatures + * Signatures for each input (hex encoded) */ public var signatures: [String] /** - * Serialized transaction + * Serialized transaction (hex) */ public var serializedTx: String - /** - * Broadcasted transaction ID (if push was true) - */ - public var txid: String? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Array of signer signatures + * Signatures for each input (hex encoded) */signatures: [String], /** - * Serialized transaction - */serializedTx: String, - /** - * Broadcasted transaction ID (if push was true) - */txid: String?) { + * Serialized transaction (hex) + */serializedTx: String) { self.signatures = signatures self.serializedTx = serializedTx - self.txid = txid } } #if compiler(>=6) -extension SignedTransactionResponse: Sendable {} +extension TrezorSignedTx: Sendable {} #endif -extension SignedTransactionResponse: Equatable, Hashable { - public static func ==(lhs: SignedTransactionResponse, rhs: SignedTransactionResponse) -> Bool { +extension TrezorSignedTx: Equatable, Hashable { + public static func ==(lhs: TrezorSignedTx, rhs: TrezorSignedTx) -> Bool { if lhs.signatures != rhs.signatures { return false } if lhs.serializedTx != rhs.serializedTx { return false } - if lhs.txid != rhs.txid { - return false - } return true } public func hash(into hasher: inout Hasher) { hasher.combine(signatures) hasher.combine(serializedTx) - hasher.combine(txid) } } -extension SignedTransactionResponse: Codable {} +extension TrezorSignedTx: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSignedTransactionResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SignedTransactionResponse { +public struct FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedTx { return - try SignedTransactionResponse( + try TrezorSignedTx( signatures: FfiConverterSequenceString.read(from: &buf), - serializedTx: FfiConverterString.read(from: &buf), - txid: FfiConverterOptionString.read(from: &buf) + serializedTx: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: SignedTransactionResponse, into buf: inout [UInt8]) { + 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) } } @@ -8921,111 +9310,100 @@ public struct FfiConverterTypeSignedTransactionResponse: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSignedTransactionResponse_lift(_ buf: RustBuffer) throws -> SignedTransactionResponse { - return try FfiConverterTypeSignedTransactionResponse.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 FfiConverterTypeSignedTransactionResponse_lower(_ value: SignedTransactionResponse) -> RustBuffer { - return FfiConverterTypeSignedTransactionResponse.lower(value) +public func FfiConverterTypeTrezorSignedTx_lower(_ value: TrezorSignedTx) -> RustBuffer { + return FfiConverterTypeTrezorSignedTx.lower(value) } -public struct SweepResult { - /** - * The transaction ID of the sweep transaction - */ - public var txid: String +/** + * Result from a transport read operation + */ +public struct TrezorTransportReadResult { /** - * The total amount swept (in satoshis) + * Whether the read succeeded */ - public var amountSwept: UInt64 + public var success: Bool /** - * The fee paid (in satoshis) + * Data read (empty on failure) */ - public var feePaid: UInt64 + public var data: Data /** - * The number of UTXOs swept + * Error message (empty on success) */ - public var utxosSwept: UInt32 + public var error: String // 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, + * Whether the read succeeded + */success: Bool, /** - * The fee paid (in satoshis) - */feePaid: UInt64, + * Data read (empty on failure) + */data: Data, /** - * The number of UTXOs swept - */utxosSwept: UInt32) { - self.txid = txid - self.amountSwept = amountSwept - self.feePaid = feePaid - self.utxosSwept = utxosSwept + * Error message (empty on success) + */error: String) { + self.success = success + self.data = data + self.error = error } } #if compiler(>=6) -extension SweepResult: Sendable {} +extension TrezorTransportReadResult: Sendable {} #endif -extension SweepResult: Equatable, Hashable { - public static func ==(lhs: SweepResult, rhs: SweepResult) -> Bool { - if lhs.txid != rhs.txid { - return false - } - if lhs.amountSwept != rhs.amountSwept { +extension TrezorTransportReadResult: Equatable, Hashable { + public static func ==(lhs: TrezorTransportReadResult, rhs: TrezorTransportReadResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.feePaid != rhs.feePaid { + if lhs.data != rhs.data { return false } - if lhs.utxosSwept != rhs.utxosSwept { + if lhs.error != rhs.error { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(amountSwept) - hasher.combine(feePaid) - hasher.combine(utxosSwept) + hasher.combine(success) + hasher.combine(data) + hasher.combine(error) } } -extension SweepResult: Codable {} +extension TrezorTransportReadResult: 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 FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportReadResult { return - try SweepResult( - txid: FfiConverterString.read(from: &buf), - amountSwept: FfiConverterUInt64.read(from: &buf), - feePaid: FfiConverterUInt64.read(from: &buf), - utxosSwept: FfiConverterUInt32.read(from: &buf) + try TrezorTransportReadResult( + success: FfiConverterBool.read(from: &buf), + data: FfiConverterData.read(from: &buf), + error: FfiConverterString.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: TrezorTransportReadResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterData.write(value.data, into: &buf) + FfiConverterString.write(value.error, into: &buf) } } @@ -9033,153 +9411,86 @@ 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 FfiConverterTypeTrezorTransportReadResult_lift(_ buf: RustBuffer) throws -> TrezorTransportReadResult { + return try FfiConverterTypeTrezorTransportReadResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepResult_lower(_ value: SweepResult) -> RustBuffer { - return FfiConverterTypeSweepResult.lower(value) +public func FfiConverterTypeTrezorTransportReadResult_lower(_ value: TrezorTransportReadResult) -> RustBuffer { + return FfiConverterTypeTrezorTransportReadResult.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 +/** + * Result from a transport write or open operation + */ +public struct TrezorTransportWriteResult { /** - * The destination address + * Whether the operation succeeded */ - public var destinationAddress: String + public var success: Bool /** - * The amount that will be sent to destination after fees (in satoshis) + * Error message (empty on success) */ - public var amountAfterFees: UInt64 + public var error: 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, + * Whether the operation succeeded + */success: Bool, /** - * 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 + * Error message (empty on success) + */error: String) { + self.success = success + self.error = error } } #if compiler(>=6) -extension SweepTransactionPreview: Sendable {} +extension TrezorTransportWriteResult: 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 { +extension TrezorTransportWriteResult: Equatable, Hashable { + public static func ==(lhs: TrezorTransportWriteResult, rhs: TrezorTransportWriteResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.utxosCount != rhs.utxosCount { - return false - } - if lhs.destinationAddress != rhs.destinationAddress { - return false - } - if lhs.amountAfterFees != rhs.amountAfterFees { + if lhs.error != rhs.error { 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(success) + hasher.combine(error) } } -extension SweepTransactionPreview: Codable {} +extension TrezorTransportWriteResult: 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 FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportWriteResult { 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 TrezorTransportWriteResult( + success: FfiConverterBool.read(from: &buf), + error: 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: TrezorTransportWriteResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterString.write(value.error, into: &buf) } } @@ -9187,167 +9498,170 @@ 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 FfiConverterTypeTrezorTransportWriteResult_lift(_ buf: RustBuffer) throws -> TrezorTransportWriteResult { + return try FfiConverterTypeTrezorTransportWriteResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepTransactionPreview_lower(_ value: SweepTransactionPreview) -> RustBuffer { - return FfiConverterTypeSweepTransactionPreview.lower(value) +public func FfiConverterTypeTrezorTransportWriteResult_lower(_ value: TrezorTransportWriteResult) -> RustBuffer { + return FfiConverterTypeTrezorTransportWriteResult.lower(value) } -public struct SweepableBalances { +/** + * Transaction input for signing. + */ +public struct TrezorTxInput { /** - * Balance in legacy (P2PKH) addresses (in satoshis) + * Previous transaction hash (hex, 32 bytes) */ - public var legacyBalance: UInt64 + public var prevHash: String /** - * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) + * Previous output index */ - public var p2shBalance: UInt64 + public var prevIndex: UInt32 /** - * Balance in Taproot (P2TR) addresses (in satoshis) + * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") */ - public var taprootBalance: UInt64 + public var path: String /** - * Total balance across all wallet types (in satoshis) + * Amount in satoshis */ - public var totalBalance: UInt64 + public var amount: UInt64 /** - * Number of UTXOs in legacy wallet + * Script type */ - public var legacyUtxosCount: UInt32 + public var scriptType: TrezorScriptType /** - * Number of UTXOs in P2SH-SegWit wallet + * Sequence number (default: 0xFFFFFFFD for RBF) */ - public var p2shUtxosCount: UInt32 + public var sequence: UInt32? /** - * Number of UTXOs in Taproot wallet + * Original transaction hash for RBF replacement (hex encoded) */ - public var taprootUtxosCount: UInt32 + public var origHash: String? /** - * Total number of UTXOs across all wallet types + * Original input index for RBF replacement */ - public var totalUtxosCount: UInt32 + public var origIndex: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Balance in legacy (P2PKH) addresses (in satoshis) - */legacyBalance: UInt64, + * Previous transaction hash (hex, 32 bytes) + */prevHash: String, /** - * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) - */p2shBalance: UInt64, + * Previous output index + */prevIndex: UInt32, /** - * Balance in Taproot (P2TR) addresses (in satoshis) - */taprootBalance: UInt64, + * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") + */path: String, /** - * Total balance across all wallet types (in satoshis) - */totalBalance: UInt64, + * Amount in satoshis + */amount: UInt64, /** - * Number of UTXOs in legacy wallet - */legacyUtxosCount: UInt32, + * Script type + */scriptType: TrezorScriptType, /** - * Number of UTXOs in P2SH-SegWit wallet - */p2shUtxosCount: UInt32, + * Sequence number (default: 0xFFFFFFFD for RBF) + */sequence: UInt32?, /** - * Number of UTXOs in Taproot wallet - */taprootUtxosCount: UInt32, + * Original transaction hash for RBF replacement (hex encoded) + */origHash: 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 + * 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 SweepableBalances: Sendable {} +extension TrezorTxInput: Sendable {} #endif -extension SweepableBalances: Equatable, Hashable { - public static func ==(lhs: SweepableBalances, rhs: SweepableBalances) -> Bool { - if lhs.legacyBalance != rhs.legacyBalance { +extension TrezorTxInput: Equatable, Hashable { + public static func ==(lhs: TrezorTxInput, rhs: TrezorTxInput) -> Bool { + if lhs.prevHash != rhs.prevHash { return false } - if lhs.p2shBalance != rhs.p2shBalance { + if lhs.prevIndex != rhs.prevIndex { return false } - if lhs.taprootBalance != rhs.taprootBalance { + if lhs.path != rhs.path { return false } - if lhs.totalBalance != rhs.totalBalance { + if lhs.amount != rhs.amount { return false } - if lhs.legacyUtxosCount != rhs.legacyUtxosCount { + if lhs.scriptType != rhs.scriptType { return false } - if lhs.p2shUtxosCount != rhs.p2shUtxosCount { + if lhs.sequence != rhs.sequence { return false } - if lhs.taprootUtxosCount != rhs.taprootUtxosCount { + if lhs.origHash != rhs.origHash { return false } - if lhs.totalUtxosCount != rhs.totalUtxosCount { + if lhs.origIndex != rhs.origIndex { 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(prevHash) + hasher.combine(prevIndex) + hasher.combine(path) + hasher.combine(amount) + hasher.combine(scriptType) + hasher.combine(sequence) + hasher.combine(origHash) + hasher.combine(origIndex) } } -extension SweepableBalances: Codable {} +extension TrezorTxInput: 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 FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxInput { 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 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: 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: 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) } } @@ -9355,197 +9669,156 @@ 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 FfiConverterTypeTrezorTxInput_lift(_ buf: RustBuffer) throws -> TrezorTxInput { + return try FfiConverterTypeTrezorTxInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepableBalances_lower(_ value: SweepableBalances) -> RustBuffer { - return FfiConverterTypeSweepableBalances.lower(value) +public func FfiConverterTypeTrezorTxInput_lower(_ value: TrezorTxInput) -> RustBuffer { + return FfiConverterTypeTrezorTxInput.lower(value) } /** - * Text memo + * Transaction output for signing. */ -public struct TextMemo { +public struct TrezorTxOutput { /** - * Text content + * Destination address (for external outputs) */ - public var text: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Text content - */text: String) { - self.text = text - } -} - -#if compiler(>=6) -extension TextMemo: Sendable {} -#endif - - -extension TextMemo: Equatable, Hashable { - public static func ==(lhs: TextMemo, rhs: TextMemo) -> Bool { - if lhs.text != rhs.text { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(text) - } -} - -extension TextMemo: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTextMemo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TextMemo { - return - try TextMemo( - text: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: TextMemo, into buf: inout [UInt8]) { - FfiConverterString.write(value.text, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTextMemo_lift(_ buf: RustBuffer) throws -> TextMemo { - return try FfiConverterTypeTextMemo.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTextMemo_lower(_ value: TextMemo) -> RustBuffer { - return FfiConverterTypeTextMemo.lower(value) -} - - -/** - * Details about an onchain transaction. - */ -public struct TransactionDetails { + public var address: String? /** - * The transaction ID. + * BIP32 path (for change outputs) */ - public var txId: String + public var path: 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. + * Amount in satoshis */ - public var amountSats: Int64 + public var amount: UInt64 /** - * The transaction inputs with full details. + * Script type (for change outputs) */ - public var inputs: [TxInput] + public var scriptType: TrezorScriptType? /** - * The transaction outputs with full details. + * OP_RETURN data (hex encoded, for data outputs) */ - public var outputs: [TxOutput] + public var opReturnData: String? + /** + * Original transaction hash for RBF replacement (hex encoded) + */ + public var origHash: String? + /** + * Original output index for RBF replacement + */ + public var origIndex: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * The transaction ID. - */txId: String, + * Destination address (for external outputs) + */address: 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, + * BIP32 path (for change outputs) + */path: String?, /** - * The transaction inputs with full details. - */inputs: [TxInput], + * Amount in satoshis + */amount: UInt64, /** - * The transaction outputs with full details. - */outputs: [TxOutput]) { - self.txId = txId - self.amountSats = amountSats - self.inputs = inputs - self.outputs = outputs + * Script type (for change outputs) + */scriptType: TrezorScriptType?, + /** + * OP_RETURN data (hex encoded, for data outputs) + */opReturnData: String?, + /** + * Original transaction hash for RBF replacement (hex encoded) + */origHash: 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 } } #if compiler(>=6) -extension TransactionDetails: Sendable {} +extension TrezorTxOutput: Sendable {} #endif -extension TransactionDetails: Equatable, Hashable { - public static func ==(lhs: TransactionDetails, rhs: TransactionDetails) -> Bool { - if lhs.txId != rhs.txId { +extension TrezorTxOutput: Equatable, Hashable { + public static func ==(lhs: TrezorTxOutput, rhs: TrezorTxOutput) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.amountSats != rhs.amountSats { + if lhs.path != rhs.path { return false } - if lhs.inputs != rhs.inputs { + if lhs.amount != rhs.amount { return false } - if lhs.outputs != rhs.outputs { + if lhs.scriptType != rhs.scriptType { + return false + } + if lhs.opReturnData != rhs.opReturnData { + 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(txId) - hasher.combine(amountSats) - hasher.combine(inputs) - hasher.combine(outputs) + hasher.combine(address) + hasher.combine(path) + hasher.combine(amount) + hasher.combine(scriptType) + hasher.combine(opReturnData) + hasher.combine(origHash) + hasher.combine(origIndex) } } -extension TransactionDetails: Codable {} +extension TrezorTxOutput: 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 FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxOutput { return - try TransactionDetails( - txId: FfiConverterString.read(from: &buf), - amountSats: FfiConverterInt64.read(from: &buf), - inputs: FfiConverterSequenceTypeTxInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTxOutput.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: TransactionDetails, into buf: inout [UInt8]) { - 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: 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) } } @@ -9553,128 +9826,114 @@ 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 FfiConverterTypeTrezorTxOutput_lift(_ buf: RustBuffer) throws -> TrezorTxOutput { + return try FfiConverterTypeTrezorTxOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetails_lower(_ value: TransactionDetails) -> RustBuffer { - return FfiConverterTypeTransactionDetails.lower(value) +public func FfiConverterTypeTrezorTxOutput_lower(_ value: TrezorTxOutput) -> RustBuffer { + return FfiConverterTypeTrezorTxOutput.lower(value) } /** - * Payment request + * Parameters for verifying a message signature. */ -public struct TxAckPaymentRequest { - /** - * Nonce - */ - public var nonce: String? +public struct TrezorVerifyMessageParams { /** - * Recipient name + * Bitcoin address that signed the message */ - public var recipientName: String + public var address: String /** - * Memos + * Signature (base64 encoded) */ - public var memos: [PaymentRequestMemo]? + public var signature: String /** - * Amount + * Original message */ - public var amount: UInt64? + public var message: String /** - * Signature + * Coin network (default: Bitcoin) */ - public var signature: String + public var coin: TrezorCoinType? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Nonce - */nonce: String?, - /** - * Recipient name - */recipientName: String, + * Bitcoin address that signed the message + */address: String, /** - * Memos - */memos: [PaymentRequestMemo]?, + * Signature (base64 encoded) + */signature: String, /** - * Amount - */amount: UInt64?, + * Original message + */message: String, /** - * Signature - */signature: String) { - self.nonce = nonce - self.recipientName = recipientName - self.memos = memos - self.amount = amount + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?) { + self.address = address self.signature = signature + self.message = message + self.coin = coin } } #if compiler(>=6) -extension TxAckPaymentRequest: Sendable {} +extension TrezorVerifyMessageParams: Sendable {} #endif -extension TxAckPaymentRequest: Equatable, Hashable { - public static func ==(lhs: TxAckPaymentRequest, rhs: TxAckPaymentRequest) -> Bool { - if lhs.nonce != rhs.nonce { - return false - } - if lhs.recipientName != rhs.recipientName { +extension TrezorVerifyMessageParams: Equatable, Hashable { + public static func ==(lhs: TrezorVerifyMessageParams, rhs: TrezorVerifyMessageParams) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.memos != rhs.memos { + if lhs.signature != rhs.signature { return false } - if lhs.amount != rhs.amount { + if lhs.message != rhs.message { return false } - if lhs.signature != rhs.signature { + if lhs.coin != rhs.coin { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(nonce) - hasher.combine(recipientName) - hasher.combine(memos) - hasher.combine(amount) + hasher.combine(address) hasher.combine(signature) + hasher.combine(message) + hasher.combine(coin) } } -extension TxAckPaymentRequest: Codable {} +extension TrezorVerifyMessageParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxAckPaymentRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxAckPaymentRequest { +public struct FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorVerifyMessageParams { return - try TxAckPaymentRequest( - nonce: FfiConverterOptionString.read(from: &buf), - recipientName: FfiConverterString.read(from: &buf), - memos: FfiConverterOptionSequenceTypePaymentRequestMemo.read(from: &buf), - amount: FfiConverterOptionUInt64.read(from: &buf), - signature: FfiConverterString.read(from: &buf) + 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: TxAckPaymentRequest, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.nonce, into: &buf) - FfiConverterString.write(value.recipientName, into: &buf) - FfiConverterOptionSequenceTypePaymentRequestMemo.write(value.memos, into: &buf) - FfiConverterOptionUInt64.write(value.amount, into: &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) } } @@ -9682,15 +9941,15 @@ public struct FfiConverterTypeTxAckPaymentRequest: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxAckPaymentRequest_lift(_ buf: RustBuffer) throws -> TxAckPaymentRequest { - return try FfiConverterTypeTxAckPaymentRequest.lift(buf) +public func FfiConverterTypeTrezorVerifyMessageParams_lift(_ buf: RustBuffer) throws -> TrezorVerifyMessageParams { + return try FfiConverterTypeTrezorVerifyMessageParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxAckPaymentRequest_lower(_ value: TxAckPaymentRequest) -> RustBuffer { - return FfiConverterTypeTxAckPaymentRequest.lower(value) +public func FfiConverterTypeTrezorVerifyMessageParams_lower(_ value: TrezorVerifyMessageParams) -> RustBuffer { + return FfiConverterTypeTrezorVerifyMessageParams.lower(value) } @@ -9824,314 +10083,45 @@ public func FfiConverterTypeTxInput_lower(_ value: TxInput) -> RustBuffer { /** - * Transaction input type + * Details about a transaction output. */ -public struct TxInputType { - /** - * Previous transaction hash - */ - public var prevHash: String - /** - * Previous transaction output index - */ - public var prevIndex: UInt32 - /** - * Amount in satoshis - */ - public var amount: UInt64 - /** - * Transaction sequence - */ - public var sequence: UInt32? - /** - * BIP32 derivation path - */ - public var addressN: [UInt32]? - /** - * Script type - */ - public var scriptType: ScriptType? - /** - * Multisig information - */ - public var multisig: MultisigRedeemScriptType? - /** - * Script public key (for external inputs) - */ - public var scriptPubkey: String? - /** - * Script signature - */ - public var scriptSig: String? - /** - * Witness data - */ - public var witness: String? +public struct TxOutput { /** - * Ownership proof + * The script public key (hex-encoded). */ - public var ownershipProof: String? + public var scriptpubkey: String /** - * Commitment data + * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). */ - public var commitmentData: String? + public var scriptpubkeyType: String? /** - * Original hash for RBF + * The address corresponding to this script (if decodable). */ - public var origHash: String? + public var scriptpubkeyAddress: String? /** - * Original index for RBF + * The value in satoshis. */ - public var origIndex: UInt32? + public var value: Int64 /** - * Coinjoin flags + * The output index in the transaction. */ - public var coinjoinFlags: UInt32? + public var n: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Previous transaction hash - */prevHash: String, - /** - * Previous transaction output index - */prevIndex: UInt32, - /** - * Amount in satoshis - */amount: UInt64, - /** - * Transaction sequence - */sequence: UInt32?, - /** - * BIP32 derivation path - */addressN: [UInt32]?, - /** - * Script type - */scriptType: ScriptType?, + * The script public key (hex-encoded). + */scriptpubkey: String, /** - * Multisig information - */multisig: MultisigRedeemScriptType?, + * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + */scriptpubkeyType: String?, /** - * Script public key (for external inputs) - */scriptPubkey: String?, + * The address corresponding to this script (if decodable). + */scriptpubkeyAddress: String?, /** - * Script signature - */scriptSig: String?, - /** - * Witness data - */witness: String?, - /** - * Ownership proof - */ownershipProof: String?, - /** - * Commitment data - */commitmentData: String?, - /** - * Original hash for RBF - */origHash: String?, - /** - * Original index for RBF - */origIndex: UInt32?, - /** - * Coinjoin flags - */coinjoinFlags: UInt32?) { - self.prevHash = prevHash - self.prevIndex = prevIndex - self.amount = amount - self.sequence = sequence - self.addressN = addressN - self.scriptType = scriptType - self.multisig = multisig - self.scriptPubkey = scriptPubkey - self.scriptSig = scriptSig - self.witness = witness - self.ownershipProof = ownershipProof - self.commitmentData = commitmentData - self.origHash = origHash - self.origIndex = origIndex - self.coinjoinFlags = coinjoinFlags - } -} - -#if compiler(>=6) -extension TxInputType: Sendable {} -#endif - - -extension TxInputType: Equatable, Hashable { - public static func ==(lhs: TxInputType, rhs: TxInputType) -> Bool { - if lhs.prevHash != rhs.prevHash { - return false - } - if lhs.prevIndex != rhs.prevIndex { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.sequence != rhs.sequence { - return false - } - if lhs.addressN != rhs.addressN { - return false - } - if lhs.scriptType != rhs.scriptType { - return false - } - if lhs.multisig != rhs.multisig { - return false - } - if lhs.scriptPubkey != rhs.scriptPubkey { - return false - } - if lhs.scriptSig != rhs.scriptSig { - return false - } - if lhs.witness != rhs.witness { - return false - } - if lhs.ownershipProof != rhs.ownershipProof { - return false - } - if lhs.commitmentData != rhs.commitmentData { - return false - } - if lhs.origHash != rhs.origHash { - return false - } - if lhs.origIndex != rhs.origIndex { - return false - } - if lhs.coinjoinFlags != rhs.coinjoinFlags { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(prevHash) - hasher.combine(prevIndex) - hasher.combine(amount) - hasher.combine(sequence) - hasher.combine(addressN) - hasher.combine(scriptType) - hasher.combine(multisig) - hasher.combine(scriptPubkey) - hasher.combine(scriptSig) - hasher.combine(witness) - hasher.combine(ownershipProof) - hasher.combine(commitmentData) - hasher.combine(origHash) - hasher.combine(origIndex) - hasher.combine(coinjoinFlags) - } -} - -extension TxInputType: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTxInputType: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxInputType { - return - try TxInputType( - prevHash: FfiConverterString.read(from: &buf), - prevIndex: FfiConverterUInt32.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - sequence: FfiConverterOptionUInt32.read(from: &buf), - addressN: FfiConverterOptionSequenceUInt32.read(from: &buf), - scriptType: FfiConverterOptionTypeScriptType.read(from: &buf), - multisig: FfiConverterOptionTypeMultisigRedeemScriptType.read(from: &buf), - scriptPubkey: FfiConverterOptionString.read(from: &buf), - scriptSig: FfiConverterOptionString.read(from: &buf), - witness: FfiConverterOptionString.read(from: &buf), - ownershipProof: FfiConverterOptionString.read(from: &buf), - commitmentData: FfiConverterOptionString.read(from: &buf), - origHash: FfiConverterOptionString.read(from: &buf), - origIndex: FfiConverterOptionUInt32.read(from: &buf), - coinjoinFlags: FfiConverterOptionUInt32.read(from: &buf) - ) - } - - public static func write(_ value: TxInputType, into buf: inout [UInt8]) { - FfiConverterString.write(value.prevHash, into: &buf) - FfiConverterUInt32.write(value.prevIndex, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterOptionUInt32.write(value.sequence, into: &buf) - FfiConverterOptionSequenceUInt32.write(value.addressN, into: &buf) - FfiConverterOptionTypeScriptType.write(value.scriptType, into: &buf) - FfiConverterOptionTypeMultisigRedeemScriptType.write(value.multisig, into: &buf) - FfiConverterOptionString.write(value.scriptPubkey, into: &buf) - FfiConverterOptionString.write(value.scriptSig, into: &buf) - FfiConverterOptionString.write(value.witness, into: &buf) - FfiConverterOptionString.write(value.ownershipProof, into: &buf) - FfiConverterOptionString.write(value.commitmentData, into: &buf) - FfiConverterOptionString.write(value.origHash, into: &buf) - FfiConverterOptionUInt32.write(value.origIndex, into: &buf) - FfiConverterOptionUInt32.write(value.coinjoinFlags, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTxInputType_lift(_ buf: RustBuffer) throws -> TxInputType { - return try FfiConverterTypeTxInputType.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTxInputType_lower(_ value: TxInputType) -> RustBuffer { - return FfiConverterTypeTxInputType.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 value in satoshis. + */value: Int64, /** * The output index in the transaction. */n: UInt32) { @@ -10221,121 +10211,34 @@ public func FfiConverterTypeTxOutput_lower(_ value: TxOutput) -> RustBuffer { } -/** - * Transaction output type - */ -public struct TxOutputType { - /** - * Output address (for address outputs) - */ - public var address: String? - /** - * BIP32 derivation path (for change outputs) - */ - public var addressN: [UInt32]? - /** - * Amount in satoshis - */ - public var amount: UInt64 - /** - * Script type - */ - public var scriptType: ScriptType - /** - * Multisig information - */ - public var multisig: MultisigRedeemScriptType? - /** - * OP_RETURN data - */ - public var opReturnData: String? - /** - * Original hash for RBF - */ - public var origHash: String? - /** - * Original index for RBF - */ - public var origIndex: UInt32? - /** - * Payment request index - */ - public var paymentReqIndex: UInt32? +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( - /** - * Output address (for address outputs) - */address: String?, - /** - * BIP32 derivation path (for change outputs) - */addressN: [UInt32]?, - /** - * Amount in satoshis - */amount: UInt64, - /** - * Script type - */scriptType: ScriptType, - /** - * Multisig information - */multisig: MultisigRedeemScriptType?, - /** - * OP_RETURN data - */opReturnData: String?, - /** - * Original hash for RBF - */origHash: String?, - /** - * Original index for RBF - */origIndex: UInt32?, - /** - * Payment request index - */paymentReqIndex: UInt32?) { + public init(address: String, network: NetworkType, addressType: AddressType) { self.address = address - self.addressN = addressN - self.amount = amount - self.scriptType = scriptType - self.multisig = multisig - self.opReturnData = opReturnData - self.origHash = origHash - self.origIndex = origIndex - self.paymentReqIndex = paymentReqIndex + self.network = network + self.addressType = addressType } } #if compiler(>=6) -extension TxOutputType: Sendable {} +extension ValidationResult: Sendable {} #endif -extension TxOutputType: Equatable, Hashable { - public static func ==(lhs: TxOutputType, rhs: TxOutputType) -> Bool { +extension ValidationResult: Equatable, Hashable { + public static func ==(lhs: ValidationResult, rhs: ValidationResult) -> Bool { if lhs.address != rhs.address { return false } - if lhs.addressN != rhs.addressN { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.scriptType != rhs.scriptType { - return false - } - if lhs.multisig != rhs.multisig { - return false - } - if lhs.opReturnData != rhs.opReturnData { - return false - } - if lhs.origHash != rhs.origHash { - return false - } - if lhs.origIndex != rhs.origIndex { + if lhs.network != rhs.network { return false } - if lhs.paymentReqIndex != rhs.paymentReqIndex { + if lhs.addressType != rhs.addressType { return false } return true @@ -10343,50 +10246,32 @@ extension TxOutputType: Equatable, Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(address) - hasher.combine(addressN) - hasher.combine(amount) - hasher.combine(scriptType) - hasher.combine(multisig) - hasher.combine(opReturnData) - hasher.combine(origHash) - hasher.combine(origIndex) - hasher.combine(paymentReqIndex) + hasher.combine(network) + hasher.combine(addressType) } } -extension TxOutputType: Codable {} +extension ValidationResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxOutputType: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxOutputType { +public struct FfiConverterTypeValidationResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ValidationResult { return - try TxOutputType( - address: FfiConverterOptionString.read(from: &buf), - addressN: FfiConverterOptionSequenceUInt32.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - scriptType: FfiConverterTypeScriptType.read(from: &buf), - multisig: FfiConverterOptionTypeMultisigRedeemScriptType.read(from: &buf), - opReturnData: FfiConverterOptionString.read(from: &buf), - origHash: FfiConverterOptionString.read(from: &buf), - origIndex: FfiConverterOptionUInt32.read(from: &buf), - paymentReqIndex: FfiConverterOptionUInt32.read(from: &buf) + try ValidationResult( + address: FfiConverterString.read(from: &buf), + network: FfiConverterTypeNetworkType.read(from: &buf), + addressType: FfiConverterTypeAddressType.read(from: &buf) ) } - public static func write(_ value: TxOutputType, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.address, into: &buf) - FfiConverterOptionSequenceUInt32.write(value.addressN, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterTypeScriptType.write(value.scriptType, into: &buf) - FfiConverterOptionTypeMultisigRedeemScriptType.write(value.multisig, into: &buf) - FfiConverterOptionString.write(value.opReturnData, into: &buf) - FfiConverterOptionString.write(value.origHash, into: &buf) - FfiConverterOptionUInt32.write(value.origIndex, into: &buf) - FfiConverterOptionUInt32.write(value.paymentReqIndex, into: &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) } } @@ -10394,86 +10279,67 @@ public struct FfiConverterTypeTxOutputType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxOutputType_lift(_ buf: RustBuffer) throws -> TxOutputType { - return try FfiConverterTypeTxOutputType.lift(buf) +public func FfiConverterTypeValidationResult_lift(_ buf: RustBuffer) throws -> ValidationResult { + return try FfiConverterTypeValidationResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxOutputType_lower(_ value: TxOutputType) -> RustBuffer { - return FfiConverterTypeTxOutputType.lower(value) +public func FfiConverterTypeValidationResult_lower(_ value: ValidationResult) -> RustBuffer { + return FfiConverterTypeValidationResult.lower(value) } +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Unlock Path parameters - */ -public struct UnlockPath { - /** - * BIP32 derivation path - */ - public var addressN: [UInt32] - /** - * MAC (optional) - */ - public var mac: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * BIP32 derivation path - */addressN: [UInt32], - /** - * MAC (optional) - */mac: String?) { - self.addressN = addressN - self.mac = mac - } +public enum Activity { + + case onchain(OnchainActivity + ) + case lightning(LightningActivity + ) } + #if compiler(>=6) -extension UnlockPath: Sendable {} +extension Activity: Sendable {} #endif - -extension UnlockPath: Equatable, Hashable { - public static func ==(lhs: UnlockPath, rhs: UnlockPath) -> Bool { - if lhs.addressN != rhs.addressN { - return false - } - if lhs.mac != rhs.mac { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(addressN) - hasher.combine(mac) - } -} - -extension UnlockPath: Codable {} - - - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUnlockPath: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UnlockPath { - return - try UnlockPath( - addressN: FfiConverterSequenceUInt32.read(from: &buf), - mac: FfiConverterOptionString.read(from: &buf) +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: UnlockPath, into buf: inout [UInt8]) { - FfiConverterSequenceUInt32.write(value.addressN, into: &buf) - FfiConverterOptionString.write(value.mac, into: &buf) + 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) + + } } } @@ -10481,79 +10347,130 @@ public struct FfiConverterTypeUnlockPath: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUnlockPath_lift(_ buf: RustBuffer) throws -> UnlockPath { - return try FfiConverterTypeUnlockPath.lift(buf) +public func FfiConverterTypeActivity_lift(_ buf: RustBuffer) throws -> Activity { + return try FfiConverterTypeActivity.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUnlockPath_lower(_ value: UnlockPath) -> RustBuffer { - return FfiConverterTypeUnlockPath.lower(value) +public func FfiConverterTypeActivity_lower(_ value: Activity) -> RustBuffer { + return FfiConverterTypeActivity.lower(value) } -public struct ValidationResult { - public var address: String - public var network: NetworkType - public var addressType: AddressType +extension Activity: Equatable, Hashable {} - // 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 - } -} +extension Activity: Codable {} -#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 {} +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 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 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: 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: 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) + + } } } @@ -10561,249 +10478,84 @@ 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 FfiConverterTypeActivityError_lift(_ buf: RustBuffer) throws -> ActivityError { + return try FfiConverterTypeActivityError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeValidationResult_lower(_ value: ValidationResult) -> RustBuffer { - return FfiConverterTypeValidationResult.lower(value) +public func FfiConverterTypeActivityError_lower(_ value: ActivityError) -> RustBuffer { + return FfiConverterTypeActivityError.lower(value) } -/** - * Verify message response - */ -public struct VerifyMessageResponse { - /** - * Verification result message - */ - public var message: String +extension ActivityError: Equatable, Hashable {} - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Verification result message - */message: String) { - self.message = message +extension ActivityError: Codable {} + + + + +extension ActivityError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) } } -#if compiler(>=6) -extension VerifyMessageResponse: Sendable {} -#endif -extension VerifyMessageResponse: Equatable, Hashable { - public static func ==(lhs: VerifyMessageResponse, rhs: VerifyMessageResponse) -> Bool { - if lhs.message != rhs.message { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(message) - } -} - -extension VerifyMessageResponse: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeVerifyMessageResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> VerifyMessageResponse { - return - try VerifyMessageResponse( - message: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: VerifyMessageResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.message, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeVerifyMessageResponse_lift(_ buf: RustBuffer) throws -> VerifyMessageResponse { - return try FfiConverterTypeVerifyMessageResponse.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeVerifyMessageResponse_lower(_ value: VerifyMessageResponse) -> RustBuffer { - return FfiConverterTypeVerifyMessageResponse.lower(value) -} - - -/** - * Marker object for XRP accounts - */ -public struct XrpMarker { - /** - * Ledger number - */ - public var ledger: UInt64 - /** - * Sequence number - */ - public var seq: UInt64 - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Ledger number - */ledger: UInt64, - /** - * Sequence number - */seq: UInt64) { - self.ledger = ledger - self.seq = seq - } -} - -#if compiler(>=6) -extension XrpMarker: Sendable {} -#endif - - -extension XrpMarker: Equatable, Hashable { - public static func ==(lhs: XrpMarker, rhs: XrpMarker) -> Bool { - if lhs.ledger != rhs.ledger { - return false - } - if lhs.seq != rhs.seq { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(ledger) - hasher.combine(seq) - } -} - -extension XrpMarker: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeXrpMarker: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> XrpMarker { - return - try XrpMarker( - ledger: FfiConverterUInt64.read(from: &buf), - seq: FfiConverterUInt64.read(from: &buf) - ) - } - - public static func write(_ value: XrpMarker, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.ledger, into: &buf) - FfiConverterUInt64.write(value.seq, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeXrpMarker_lift(_ buf: RustBuffer) throws -> XrpMarker { - return try FfiConverterTypeXrpMarker.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeXrpMarker_lower(_ value: XrpMarker) -> RustBuffer { - return FfiConverterTypeXrpMarker.lower(value) -} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Level of details to be returned by getAccountInfo - */ -public enum AccountInfoDetails { +public enum ActivityFilter { - /** - * Return only account balances (default) - */ - case basic - /** - * Return with derived addresses or ERC20 tokens - */ - case tokens - /** - * Same as tokens with balances - */ - case tokenBalances - /** - * TokenBalances + complete account transaction history - */ - case txs + case all + case lightning + case onchain } #if compiler(>=6) -extension AccountInfoDetails: Sendable {} +extension ActivityFilter: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAccountInfoDetails: FfiConverterRustBuffer { - typealias SwiftType = AccountInfoDetails +public struct FfiConverterTypeActivityFilter: FfiConverterRustBuffer { + typealias SwiftType = ActivityFilter - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountInfoDetails { + 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 .basic - - case 2: return .tokens + case 1: return .all - case 3: return .tokenBalances + case 2: return .lightning - case 4: return .txs + case 3: return .onchain default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AccountInfoDetails, into buf: inout [UInt8]) { + public static func write(_ value: ActivityFilter, into buf: inout [UInt8]) { switch value { - case .basic: + case .all: writeInt(&buf, Int32(1)) - case .tokens: + case .lightning: writeInt(&buf, Int32(2)) - case .tokenBalances: + case .onchain: writeInt(&buf, Int32(3)) - - case .txs: - writeInt(&buf, Int32(4)) - } } } @@ -10812,21 +10564,21 @@ public struct FfiConverterTypeAccountInfoDetails: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountInfoDetails_lift(_ buf: RustBuffer) throws -> AccountInfoDetails { - return try FfiConverterTypeAccountInfoDetails.lift(buf) +public func FfiConverterTypeActivityFilter_lift(_ buf: RustBuffer) throws -> ActivityFilter { + return try FfiConverterTypeActivityFilter.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountInfoDetails_lower(_ value: AccountInfoDetails) -> RustBuffer { - return FfiConverterTypeAccountInfoDetails.lower(value) +public func FfiConverterTypeActivityFilter_lower(_ value: ActivityFilter) -> RustBuffer { + return FfiConverterTypeActivityFilter.lower(value) } -extension AccountInfoDetails: Equatable, Hashable {} +extension ActivityFilter: Equatable, Hashable {} -extension AccountInfoDetails: Codable {} +extension ActivityFilter: Codable {} @@ -10836,52 +10588,46 @@ extension AccountInfoDetails: 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 ActivityType { - case onchain(OnchainActivity - ) - case lightning(LightningActivity - ) + case onchain + case lightning } #if compiler(>=6) -extension Activity: Sendable {} +extension ActivityType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivity: FfiConverterRustBuffer { - typealias SwiftType = Activity +public struct FfiConverterTypeActivityType: FfiConverterRustBuffer { + typealias SwiftType = ActivityType - 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 -> ActivityType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .onchain(try FfiConverterTypeOnchainActivity.read(from: &buf) - ) + case 1: return .onchain - case 2: return .lightning(try FfiConverterTypeLightningActivity.read(from: &buf) - ) + case 2: return .lightning default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: Activity, into buf: inout [UInt8]) { + public static func write(_ value: ActivityType, into buf: inout [UInt8]) { switch value { - case let .onchain(v1): + case .onchain: writeInt(&buf, Int32(1)) - FfiConverterTypeOnchainActivity.write(v1, into: &buf) - - case let .lightning(v1): + + case .lightning: writeInt(&buf, Int32(2)) - FfiConverterTypeLightningActivity.write(v1, into: &buf) - + } } } @@ -10890,21 +10636,21 @@ 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 FfiConverterTypeActivityType_lift(_ buf: RustBuffer) throws -> ActivityType { + return try FfiConverterTypeActivityType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivity_lower(_ value: Activity) -> RustBuffer { - return FfiConverterTypeActivity.lower(value) +public func FfiConverterTypeActivityType_lower(_ value: ActivityType) -> RustBuffer { + return FfiConverterTypeActivityType.lower(value) } -extension Activity: Equatable, Hashable {} +extension ActivityType: Equatable, Hashable {} -extension Activity: Codable {} +extension ActivityType: Codable {} @@ -10912,107 +10658,73 @@ extension Activity: Codable {} -public enum ActivityError: Swift.Error { +public enum AddressError: 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 - ) + case InvalidAddress + case InvalidNetwork + case MnemonicGenerationFailed + case InvalidMnemonic + case InvalidEntropy + case AddressDerivationFailed } #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { - typealias SwiftType = ActivityError +public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { + typealias SwiftType = AddressError - 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 -> AddressError { 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) - ) + 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: ActivityError, into buf: inout [UInt8]) { + public static func write(_ value: AddressError, into buf: inout [UInt8]) { switch value { - case let .InvalidActivity(errorDetails): + case .InvalidAddress: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InitializationError(errorDetails): + + case .InvalidNetwork: writeInt(&buf, Int32(2)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InsertError(errorDetails): + + case .MnemonicGenerationFailed: writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .RetrievalError(errorDetails): + + case .InvalidMnemonic: writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .DataError(errorDetails): + + case .InvalidEntropy: 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) - + case .AddressDerivationFailed: + writeInt(&buf, Int32(6)) + } } } @@ -11021,26 +10733,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 FfiConverterTypeAddressError_lift(_ buf: RustBuffer) throws -> AddressError { + return try FfiConverterTypeAddressError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityError_lower(_ value: ActivityError) -> RustBuffer { - return FfiConverterTypeActivityError.lower(value) +public func FfiConverterTypeAddressError_lower(_ value: AddressError) -> RustBuffer { + return FfiConverterTypeAddressError.lower(value) } -extension ActivityError: Equatable, Hashable {} +extension AddressError: Equatable, Hashable {} -extension ActivityError: Codable {} +extension AddressError: Codable {} -extension ActivityError: Foundation.LocalizedError { +extension AddressError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -11052,53 +10764,74 @@ 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. -public enum ActivityFilter { +public enum AddressType { - case all - case lightning - case onchain + case p2pkh + case p2sh + case p2wpkh + case p2wsh + case p2tr + case unknown } #if compiler(>=6) -extension ActivityFilter: Sendable {} +extension AddressType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivityFilter: FfiConverterRustBuffer { - typealias SwiftType = ActivityFilter +public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { + typealias SwiftType = AddressType - 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 -> AddressType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .all + case 1: return .p2pkh - case 2: return .lightning + case 2: return .p2sh - case 3: return .onchain + 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: ActivityFilter, into buf: inout [UInt8]) { + public static func write(_ value: AddressType, into buf: inout [UInt8]) { switch value { - case .all: + case .p2pkh: writeInt(&buf, Int32(1)) - case .lightning: + case .p2sh: writeInt(&buf, Int32(2)) - case .onchain: + case .p2wpkh: writeInt(&buf, Int32(3)) + + case .p2wsh: + writeInt(&buf, Int32(4)) + + + case .p2tr: + writeInt(&buf, Int32(5)) + + + case .unknown: + writeInt(&buf, Int32(6)) + } } } @@ -11107,21 +10840,21 @@ public struct FfiConverterTypeActivityFilter: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityFilter_lift(_ buf: RustBuffer) throws -> ActivityFilter { - return try FfiConverterTypeActivityFilter.lift(buf) +public func FfiConverterTypeAddressType_lift(_ buf: RustBuffer) throws -> AddressType { + return try FfiConverterTypeAddressType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityFilter_lower(_ value: ActivityFilter) -> RustBuffer { - return FfiConverterTypeActivityFilter.lower(value) +public func FfiConverterTypeAddressType_lower(_ value: AddressType) -> RustBuffer { + return FfiConverterTypeAddressType.lower(value) } -extension ActivityFilter: Equatable, Hashable {} +extension AddressType: Equatable, Hashable {} -extension ActivityFilter: Codable {} +extension AddressType: Codable {} @@ -11131,46 +10864,60 @@ 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 { +public enum BitcoinNetworkEnum { - case onchain - case lightning + case mainnet + case testnet + case signet + case regtest } #if compiler(>=6) -extension ActivityType: Sendable {} +extension BitcoinNetworkEnum: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivityType: FfiConverterRustBuffer { - typealias SwiftType = ActivityType +public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { + typealias SwiftType = BitcoinNetworkEnum - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityType { + 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 .onchain + case 1: return .mainnet - case 2: return .lightning + case 2: return .testnet + + case 3: return .signet + + case 4: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ActivityType, into buf: inout [UInt8]) { + public static func write(_ value: BitcoinNetworkEnum, into buf: inout [UInt8]) { switch value { - case .onchain: + case .mainnet: writeInt(&buf, Int32(1)) - case .lightning: + case .testnet: writeInt(&buf, Int32(2)) + + case .signet: + writeInt(&buf, Int32(3)) + + + case .regtest: + writeInt(&buf, Int32(4)) + } } } @@ -11179,21 +10926,21 @@ public struct FfiConverterTypeActivityType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityType_lift(_ buf: RustBuffer) throws -> ActivityType { - return try FfiConverterTypeActivityType.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 FfiConverterTypeActivityType_lower(_ value: ActivityType) -> RustBuffer { - return FfiConverterTypeActivityType.lower(value) +public func FfiConverterTypeBitcoinNetworkEnum_lower(_ value: BitcoinNetworkEnum) -> RustBuffer { + return FfiConverterTypeBitcoinNetworkEnum.lower(value) } -extension ActivityType: Equatable, Hashable {} +extension BitcoinNetworkEnum: Equatable, Hashable {} -extension ActivityType: Codable {} +extension BitcoinNetworkEnum: Codable {} @@ -11201,101 +10948,197 @@ extension ActivityType: Codable {} -public enum AddressError: Swift.Error { +public enum BlocktankError: Swift.Error { - case InvalidAddress - case InvalidNetwork - case MnemonicGenerationFailed - case InvalidMnemonic - case InvalidEntropy - case AddressDerivationFailed + 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 + ) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { - typealias SwiftType = AddressError +public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { + typealias SwiftType = BlocktankError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressError { + 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 .InvalidAddress - case 2: return .InvalidNetwork - case 3: return .MnemonicGenerationFailed - case 4: return .InvalidMnemonic - case 5: return .InvalidEntropy - case 6: return .AddressDerivationFailed + 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: AddressError, into buf: inout [UInt8]) { + public static func write(_ value: BlocktankError, into buf: inout [UInt8]) { switch value { - case .InvalidAddress: + case let .HttpClient(errorDetails): writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .InvalidNetwork: + case let .BlocktankClient(errorDetails): writeInt(&buf, Int32(2)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .MnemonicGenerationFailed: + case let .InvalidBlocktank(errorDetails): writeInt(&buf, Int32(3)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .InvalidMnemonic: + case let .InitializationError(errorDetails): writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .InvalidEntropy: + case let .InsertError(errorDetails): writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .AddressDerivationFailed: + 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) + + } + } +} + + #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressError_lift(_ buf: RustBuffer) throws -> AddressError { - return try FfiConverterTypeAddressError.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 FfiConverterTypeAddressError_lower(_ value: AddressError) -> RustBuffer { - return FfiConverterTypeAddressError.lower(value) +public func FfiConverterTypeBlocktankError_lower(_ value: BlocktankError) -> RustBuffer { + return FfiConverterTypeBlocktankError.lower(value) } -extension AddressError: Equatable, Hashable {} +extension BlocktankError: Equatable, Hashable {} -extension AddressError: Codable {} +extension BlocktankError: Codable {} -extension AddressError: Foundation.LocalizedError { +extension BlocktankError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -11307,74 +11150,60 @@ extension AddressError: 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 AddressType { +public enum BtBolt11InvoiceState { - case p2pkh - case p2sh - case p2wpkh - case p2wsh - case p2tr - case unknown + case pending + case holding + case paid + case canceled } #if compiler(>=6) -extension AddressType: Sendable {} +extension BtBolt11InvoiceState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { - typealias SwiftType = AddressType +public struct FfiConverterTypeBtBolt11InvoiceState: FfiConverterRustBuffer { + typealias SwiftType = BtBolt11InvoiceState - 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 -> BtBolt11InvoiceState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .p2pkh - - case 2: return .p2sh - - case 3: return .p2wpkh + case 1: return .pending - case 4: return .p2wsh + case 2: return .holding - case 5: return .p2tr + case 3: return .paid - case 6: return .unknown + case 4: return .canceled default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AddressType, into buf: inout [UInt8]) { + public static func write(_ value: BtBolt11InvoiceState, into buf: inout [UInt8]) { switch value { - case .p2pkh: + case .pending: writeInt(&buf, Int32(1)) - case .p2sh: + case .holding: writeInt(&buf, Int32(2)) - case .p2wpkh: + case .paid: writeInt(&buf, Int32(3)) - case .p2wsh: + case .canceled: writeInt(&buf, Int32(4)) - - case .p2tr: - writeInt(&buf, Int32(5)) - - - case .unknown: - writeInt(&buf, Int32(6)) - } } } @@ -11383,21 +11212,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 FfiConverterTypeBtBolt11InvoiceState_lift(_ buf: RustBuffer) throws -> BtBolt11InvoiceState { + return try FfiConverterTypeBtBolt11InvoiceState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressType_lower(_ value: AddressType) -> RustBuffer { - return FfiConverterTypeAddressType.lower(value) +public func FfiConverterTypeBtBolt11InvoiceState_lower(_ value: BtBolt11InvoiceState) -> RustBuffer { + return FfiConverterTypeBtBolt11InvoiceState.lower(value) } -extension AddressType: Equatable, Hashable {} +extension BtBolt11InvoiceState: Equatable, Hashable {} -extension AddressType: Codable {} +extension BtBolt11InvoiceState: Codable {} @@ -11406,64 +11235,68 @@ 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. -/** - * Amount unit for display - */ -public enum AmountUnit { +public enum BtChannelOrderErrorType { - case bitcoin - case milliBitcoin - case microBitcoin - case satoshi + case wrongOrderState + case peerNotReachable + case channelRejectedByDestination + case channelRejectedByLsp + case blocktankNotReady } #if compiler(>=6) -extension AmountUnit: Sendable {} +extension BtChannelOrderErrorType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAmountUnit: FfiConverterRustBuffer { - typealias SwiftType = AmountUnit +public struct FfiConverterTypeBtChannelOrderErrorType: FfiConverterRustBuffer { + typealias SwiftType = BtChannelOrderErrorType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AmountUnit { + 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 .bitcoin + case 1: return .wrongOrderState + + case 2: return .peerNotReachable - case 2: return .milliBitcoin + case 3: return .channelRejectedByDestination - case 3: return .microBitcoin + case 4: return .channelRejectedByLsp - case 4: return .satoshi + case 5: return .blocktankNotReady default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AmountUnit, into buf: inout [UInt8]) { + public static func write(_ value: BtChannelOrderErrorType, into buf: inout [UInt8]) { switch value { - case .bitcoin: + case .wrongOrderState: writeInt(&buf, Int32(1)) - case .milliBitcoin: + case .peerNotReachable: writeInt(&buf, Int32(2)) - case .microBitcoin: + case .channelRejectedByDestination: writeInt(&buf, Int32(3)) - case .satoshi: + case .channelRejectedByLsp: writeInt(&buf, Int32(4)) + + case .blocktankNotReady: + writeInt(&buf, Int32(5)) + } } } @@ -11472,21 +11305,21 @@ public struct FfiConverterTypeAmountUnit: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAmountUnit_lift(_ buf: RustBuffer) throws -> AmountUnit { - return try FfiConverterTypeAmountUnit.lift(buf) +public func FfiConverterTypeBtChannelOrderErrorType_lift(_ buf: RustBuffer) throws -> BtChannelOrderErrorType { + return try FfiConverterTypeBtChannelOrderErrorType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAmountUnit_lower(_ value: AmountUnit) -> RustBuffer { - return FfiConverterTypeAmountUnit.lower(value) +public func FfiConverterTypeBtChannelOrderErrorType_lower(_ value: BtChannelOrderErrorType) -> RustBuffer { + return FfiConverterTypeBtChannelOrderErrorType.lower(value) } -extension AmountUnit: Equatable, Hashable {} +extension BtChannelOrderErrorType: Equatable, Hashable {} -extension AmountUnit: Codable {} +extension BtChannelOrderErrorType: Codable {} @@ -11496,60 +11329,53 @@ extension AmountUnit: 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 { +public enum BtOpenChannelState { - case mainnet - case testnet - case signet - case regtest + case opening + case `open` + case closed } #if compiler(>=6) -extension BitcoinNetworkEnum: Sendable {} +extension BtOpenChannelState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { - typealias SwiftType = BitcoinNetworkEnum +public struct FfiConverterTypeBtOpenChannelState: FfiConverterRustBuffer { + typealias SwiftType = BtOpenChannelState - 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 -> BtOpenChannelState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .mainnet - - case 2: return .testnet + case 1: return .opening - case 3: return .signet + case 2: return .`open` - case 4: return .regtest + case 3: return .closed default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BitcoinNetworkEnum, into buf: inout [UInt8]) { + public static func write(_ value: BtOpenChannelState, into buf: inout [UInt8]) { switch value { - case .mainnet: + case .opening: writeInt(&buf, Int32(1)) - case .testnet: + case .`open`: writeInt(&buf, Int32(2)) - case .signet: + case .closed: writeInt(&buf, Int32(3)) - - case .regtest: - writeInt(&buf, Int32(4)) - } } } @@ -11558,191 +11384,84 @@ 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 FfiConverterTypeBtOpenChannelState_lift(_ buf: RustBuffer) throws -> BtOpenChannelState { + return try FfiConverterTypeBtOpenChannelState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBitcoinNetworkEnum_lower(_ value: BitcoinNetworkEnum) -> RustBuffer { - return FfiConverterTypeBitcoinNetworkEnum.lower(value) +public func FfiConverterTypeBtOpenChannelState_lower(_ value: BtOpenChannelState) -> RustBuffer { + return FfiConverterTypeBtOpenChannelState.lower(value) } -extension BitcoinNetworkEnum: Equatable, Hashable {} - -extension BitcoinNetworkEnum: Codable {} +extension BtOpenChannelState: Equatable, Hashable {} +extension BtOpenChannelState: 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. +public enum BtOrderState { - - 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 created + case expired + case `open` + case closed } +#if compiler(>=6) +extension BtOrderState: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { - typealias SwiftType = BlocktankError +public struct FfiConverterTypeBtOrderState: FfiConverterRustBuffer { + typealias SwiftType = BtOrderState - 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 -> BtOrderState { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .created - 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 .expired + + case 3: return .`open` + + case 4: return .closed + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BlocktankError, into buf: inout [UInt8]) { + public static func write(_ value: BtOrderState, into buf: inout [UInt8]) { switch value { - - - - case let .HttpClient(errorDetails): + case .created: 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 .expired: + writeInt(&buf, Int32(2)) - 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 .`open`: + writeInt(&buf, Int32(3)) - 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 .closed: + writeInt(&buf, Int32(4)) - case let .DatabaseError(errorDetails): - writeInt(&buf, Int32(13)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -11751,30 +11470,23 @@ 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 FfiConverterTypeBtOrderState_lift(_ buf: RustBuffer) throws -> BtOrderState { + return try FfiConverterTypeBtOrderState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBlocktankError_lower(_ value: BlocktankError) -> RustBuffer { - return FfiConverterTypeBlocktankError.lower(value) +public func FfiConverterTypeBtOrderState_lower(_ value: BtOrderState) -> RustBuffer { + return FfiConverterTypeBtOrderState.lower(value) } -extension BlocktankError: Equatable, Hashable {} - -extension BlocktankError: Codable {} - +extension BtOrderState: Equatable, Hashable {} +extension BtOrderState: Codable {} -extension BlocktankError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} @@ -11782,58 +11494,58 @@ extension BlocktankError: 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 BtOrderState2 { - case pending - case holding + case created + case expired + case executed case paid - case canceled } #if compiler(>=6) -extension BtBolt11InvoiceState: Sendable {} +extension BtOrderState2: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtBolt11InvoiceState: FfiConverterRustBuffer { - typealias SwiftType = BtBolt11InvoiceState +public struct FfiConverterTypeBtOrderState2: FfiConverterRustBuffer { + typealias SwiftType = BtOrderState2 - 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 -> BtOrderState2 { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .pending + case 1: return .created - case 2: return .holding + case 2: return .expired - case 3: return .paid + case 3: return .executed - case 4: return .canceled + case 4: return .paid default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtBolt11InvoiceState, into buf: inout [UInt8]) { + public static func write(_ value: BtOrderState2, into buf: inout [UInt8]) { switch value { - case .pending: + case .created: writeInt(&buf, Int32(1)) - case .holding: + case .expired: writeInt(&buf, Int32(2)) - case .paid: + case .executed: writeInt(&buf, Int32(3)) - case .canceled: + case .paid: writeInt(&buf, Int32(4)) } @@ -11844,21 +11556,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 FfiConverterTypeBtOrderState2_lift(_ buf: RustBuffer) throws -> BtOrderState2 { + return try FfiConverterTypeBtOrderState2.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtBolt11InvoiceState_lower(_ value: BtBolt11InvoiceState) -> RustBuffer { - return FfiConverterTypeBtBolt11InvoiceState.lower(value) +public func FfiConverterTypeBtOrderState2_lower(_ value: BtOrderState2) -> RustBuffer { + return FfiConverterTypeBtOrderState2.lower(value) } -extension BtBolt11InvoiceState: Equatable, Hashable {} +extension BtOrderState2: Equatable, Hashable {} -extension BtBolt11InvoiceState: Codable {} +extension BtOrderState2: Codable {} @@ -11868,65 +11580,65 @@ 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. -public enum BtChannelOrderErrorType { +public enum BtPaymentState { - case wrongOrderState - case peerNotReachable - case channelRejectedByDestination - case channelRejectedByLsp - case blocktankNotReady + case created + case partiallyPaid + case paid + case refunded + case refundAvailable } #if compiler(>=6) -extension BtChannelOrderErrorType: Sendable {} +extension BtPaymentState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtChannelOrderErrorType: FfiConverterRustBuffer { - typealias SwiftType = BtChannelOrderErrorType +public struct FfiConverterTypeBtPaymentState: FfiConverterRustBuffer { + typealias SwiftType = BtPaymentState - 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 -> BtPaymentState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .wrongOrderState + case 1: return .created - case 2: return .peerNotReachable + case 2: return .partiallyPaid - case 3: return .channelRejectedByDestination + case 3: return .paid - case 4: return .channelRejectedByLsp + case 4: return .refunded - case 5: return .blocktankNotReady + case 5: return .refundAvailable default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtChannelOrderErrorType, into buf: inout [UInt8]) { + public static func write(_ value: BtPaymentState, into buf: inout [UInt8]) { switch value { - case .wrongOrderState: + case .created: writeInt(&buf, Int32(1)) - case .peerNotReachable: + case .partiallyPaid: writeInt(&buf, Int32(2)) - case .channelRejectedByDestination: + case .paid: writeInt(&buf, Int32(3)) - case .channelRejectedByLsp: + case .refunded: writeInt(&buf, Int32(4)) - case .blocktankNotReady: + case .refundAvailable: writeInt(&buf, Int32(5)) } @@ -11937,21 +11649,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 FfiConverterTypeBtPaymentState_lift(_ buf: RustBuffer) throws -> BtPaymentState { + return try FfiConverterTypeBtPaymentState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtChannelOrderErrorType_lower(_ value: BtChannelOrderErrorType) -> RustBuffer { - return FfiConverterTypeBtChannelOrderErrorType.lower(value) +public func FfiConverterTypeBtPaymentState_lower(_ value: BtPaymentState) -> RustBuffer { + return FfiConverterTypeBtPaymentState.lower(value) } -extension BtChannelOrderErrorType: Equatable, Hashable {} +extension BtPaymentState: Equatable, Hashable {} -extension BtChannelOrderErrorType: Codable {} +extension BtPaymentState: Codable {} @@ -11961,53 +11673,67 @@ 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 { +public enum BtPaymentState2 { - case opening - case `open` - case closed + case created + case paid + case refunded + case refundAvailable + case canceled } #if compiler(>=6) -extension BtOpenChannelState: Sendable {} +extension BtPaymentState2: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtOpenChannelState: FfiConverterRustBuffer { - typealias SwiftType = BtOpenChannelState +public struct FfiConverterTypeBtPaymentState2: FfiConverterRustBuffer { + typealias SwiftType = BtPaymentState2 - 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 -> BtPaymentState2 { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .opening + case 1: return .created - case 2: return .`open` + case 2: return .paid - case 3: return .closed + case 3: return .refunded - default: throw UniffiInternalError.unexpectedEnumCase + case 4: return .refundAvailable + + case 5: return .canceled + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtOpenChannelState, into buf: inout [UInt8]) { + public static func write(_ value: BtPaymentState2, into buf: inout [UInt8]) { switch value { - case .opening: + case .created: writeInt(&buf, Int32(1)) - case .`open`: + case .paid: writeInt(&buf, Int32(2)) - case .closed: + case .refunded: writeInt(&buf, Int32(3)) + + case .refundAvailable: + writeInt(&buf, Int32(4)) + + + case .canceled: + writeInt(&buf, Int32(5)) + } } } @@ -12016,21 +11742,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 FfiConverterTypeBtPaymentState2_lift(_ buf: RustBuffer) throws -> BtPaymentState2 { + return try FfiConverterTypeBtPaymentState2.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOpenChannelState_lower(_ value: BtOpenChannelState) -> RustBuffer { - return FfiConverterTypeBtOpenChannelState.lower(value) +public func FfiConverterTypeBtPaymentState2_lower(_ value: BtPaymentState2) -> RustBuffer { + return FfiConverterTypeBtPaymentState2.lower(value) } -extension BtOpenChannelState: Equatable, Hashable {} +extension BtPaymentState2: Equatable, Hashable {} -extension BtOpenChannelState: Codable {} +extension BtPaymentState2: Codable {} @@ -12040,42 +11766,42 @@ 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. -public enum BtOrderState { +public enum CJitStateEnum { case created + case completed case expired - case `open` - case closed + case failed } #if compiler(>=6) -extension BtOrderState: Sendable {} +extension CJitStateEnum: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtOrderState: FfiConverterRustBuffer { - typealias SwiftType = BtOrderState +public struct FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { + typealias SwiftType = CJitStateEnum - 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 -> CJitStateEnum { let variant: Int32 = try readInt(&buf) switch variant { case 1: return .created - case 2: return .expired + case 2: return .completed - case 3: return .`open` + case 3: return .expired - case 4: return .closed + case 4: return .failed default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtOrderState, into buf: inout [UInt8]) { + public static func write(_ value: CJitStateEnum, into buf: inout [UInt8]) { switch value { @@ -12083,15 +11809,15 @@ public struct FfiConverterTypeBtOrderState: FfiConverterRustBuffer { writeInt(&buf, Int32(1)) - case .expired: + case .completed: writeInt(&buf, Int32(2)) - case .`open`: + case .expired: writeInt(&buf, Int32(3)) - case .closed: + case .failed: writeInt(&buf, Int32(4)) } @@ -12102,84 +11828,89 @@ 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 FfiConverterTypeCJitStateEnum_lift(_ buf: RustBuffer) throws -> CJitStateEnum { + return try FfiConverterTypeCJitStateEnum.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOrderState_lower(_ value: BtOrderState) -> RustBuffer { - return FfiConverterTypeBtOrderState.lower(value) +public func FfiConverterTypeCJitStateEnum_lower(_ value: CJitStateEnum) -> RustBuffer { + return FfiConverterTypeCJitStateEnum.lower(value) } -extension BtOrderState: Equatable, Hashable {} +extension CJitStateEnum: Equatable, Hashable {} -extension BtOrderState: Codable {} +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. -public enum BtOrderState2 { +public enum DbError: Swift.Error { + - case created - case expired - case executed - case paid + + case DbActivityError(errorDetails: ActivityError + ) + case DbBlocktankError(errorDetails: BlocktankError + ) + 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 .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: + 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 .InitializationError(errorDetails): writeInt(&buf, Int32(3)) - - - case .paid: - writeInt(&buf, Int32(4)) - + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -12188,183 +11919,271 @@ 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 DecodingError: Swift.Error { -public enum BtPaymentState { - 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)) - } - } -} - - -#if swift(>=5.8) + + 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) + + } + } +} + + +#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. -public enum BtPaymentState2 { + +public enum LnurlError: Swift.Error { + - case created - case paid - case refunded - case refundAvailable - case canceled + + case InvalidAddress + case ClientCreationFailed + case RequestFailed + case InvalidResponse + case InvalidAmount(amountSatoshis: UInt64, min: UInt64, max: UInt64 + ) + case InvoiceCreationFailed(errorDetails: String + ) + case AuthenticationFailed } -#if compiler(>=6) -extension BtPaymentState2: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtPaymentState2: FfiConverterRustBuffer { - typealias SwiftType = BtPaymentState2 +public struct FfiConverterTypeLnurlError: FfiConverterRustBuffer { + typealias SwiftType = LnurlError - 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 -> LnurlError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .created - - case 2: return .paid - - case 3: return .refunded - - case 4: return .refundAvailable - - case 5: return .canceled + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .InvalidAddress + case 2: return .ClientCreationFailed + case 3: return .RequestFailed + case 4: return .InvalidResponse + case 5: return .InvalidAmount( + amountSatoshis: try FfiConverterUInt64.read(from: &buf), + min: try FfiConverterUInt64.read(from: &buf), + max: try FfiConverterUInt64.read(from: &buf) + ) + case 6: return .InvoiceCreationFailed( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 7: return .AuthenticationFailed + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtPaymentState2, into buf: inout [UInt8]) { + public static func write(_ value: LnurlError, into buf: inout [UInt8]) { switch value { + + - case .created: + + case .InvalidAddress: writeInt(&buf, Int32(1)) - case .paid: + case .ClientCreationFailed: writeInt(&buf, Int32(2)) - case .refunded: + case .RequestFailed: writeInt(&buf, Int32(3)) - case .refundAvailable: + case .InvalidResponse: writeInt(&buf, Int32(4)) - case .canceled: + case let .InvalidAmount(amountSatoshis,min,max): writeInt(&buf, Int32(5)) + FfiConverterUInt64.write(amountSatoshis, into: &buf) + FfiConverterUInt64.write(min, into: &buf) + FfiConverterUInt64.write(max, into: &buf) + + + case let .InvoiceCreationFailed(errorDetails): + writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + + case .AuthenticationFailed: + writeInt(&buf, Int32(7)) } } @@ -12374,23 +12193,30 @@ 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 FfiConverterTypeLnurlError_lift(_ buf: RustBuffer) throws -> LnurlError { + return try FfiConverterTypeLnurlError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState2_lower(_ value: BtPaymentState2) -> RustBuffer { - return FfiConverterTypeBtPaymentState2.lower(value) +public func FfiConverterTypeLnurlError_lower(_ value: LnurlError) -> RustBuffer { + return FfiConverterTypeLnurlError.lower(value) } -extension BtPaymentState2: Equatable, Hashable {} +extension LnurlError: Equatable, Hashable {} + +extension LnurlError: Codable {} + -extension BtPaymentState2: Codable {} +extension LnurlError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} @@ -12398,42 +12224,42 @@ 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. -public enum CJitStateEnum { +public enum ManualRefundStateEnum { case created - case completed - case expired - case failed + case approved + case rejected + case sent } #if compiler(>=6) -extension CJitStateEnum: Sendable {} +extension ManualRefundStateEnum: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { - typealias SwiftType = CJitStateEnum +public struct FfiConverterTypeManualRefundStateEnum: FfiConverterRustBuffer { + typealias SwiftType = ManualRefundStateEnum - 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 -> ManualRefundStateEnum { let variant: Int32 = try readInt(&buf) switch variant { case 1: return .created - case 2: return .completed + case 2: return .approved - case 3: return .expired + case 3: return .rejected - case 4: return .failed + case 4: return .sent default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: CJitStateEnum, into buf: inout [UInt8]) { + public static func write(_ value: ManualRefundStateEnum, into buf: inout [UInt8]) { switch value { @@ -12441,15 +12267,15 @@ public struct FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { writeInt(&buf, Int32(1)) - case .completed: + case .approved: writeInt(&buf, Int32(2)) - case .expired: + case .rejected: writeInt(&buf, Int32(3)) - case .failed: + case .sent: writeInt(&buf, Int32(4)) } @@ -12460,21 +12286,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 FfiConverterTypeManualRefundStateEnum_lift(_ buf: RustBuffer) throws -> ManualRefundStateEnum { + return try FfiConverterTypeManualRefundStateEnum.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCJitStateEnum_lower(_ value: CJitStateEnum) -> RustBuffer { - return FfiConverterTypeCJitStateEnum.lower(value) +public func FfiConverterTypeManualRefundStateEnum_lower(_ value: ManualRefundStateEnum) -> RustBuffer { + return FfiConverterTypeManualRefundStateEnum.lower(value) } -extension CJitStateEnum: Equatable, Hashable {} +extension ManualRefundStateEnum: Equatable, Hashable {} -extension CJitStateEnum: Codable {} +extension ManualRefundStateEnum: Codable {} @@ -12483,112 +12309,81 @@ 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. -/** - * Output type for compose transaction - */ -public enum ComposeOutput { +public enum Network { /** - * Regular output with amount and address + * Mainnet Bitcoin. */ - case regular( - /** - * Amount in satoshis - */amount: String, - /** - * Recipient address - */address: String - ) + case bitcoin /** - * Send max output + * Bitcoin's testnet network. */ - case sendMax( - /** - * Recipient address - */address: String - ) + case testnet /** - * OP_RETURN output + * Bitcoin's testnet4 network. */ - case opReturn( - /** - * Hexadecimal string with arbitrary data - */dataHex: String - ) + case testnet4 /** - * Payment without address (precompose only) + * Bitcoin's signet network. */ - case paymentNoAddress( - /** - * Amount in satoshis - */amount: String - ) + case signet /** - * Send max without address (precompose only) + * Bitcoin's regtest network. */ - case sendMaxNoAddress + case regtest } #if compiler(>=6) -extension ComposeOutput: Sendable {} +extension Network: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeComposeOutput: FfiConverterRustBuffer { - typealias SwiftType = ComposeOutput +public struct FfiConverterTypeNetwork: FfiConverterRustBuffer { + typealias SwiftType = Network - 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 -> Network { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .regular(amount: try FfiConverterString.read(from: &buf), address: try FfiConverterString.read(from: &buf) - ) + case 1: return .bitcoin - case 2: return .sendMax(address: try FfiConverterString.read(from: &buf) - ) + case 2: return .testnet - case 3: return .opReturn(dataHex: try FfiConverterString.read(from: &buf) - ) + case 3: return .testnet4 - case 4: return .paymentNoAddress(amount: try FfiConverterString.read(from: &buf) - ) + case 4: return .signet - case 5: return .sendMaxNoAddress + case 5: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ComposeOutput, into buf: inout [UInt8]) { + public static func write(_ value: Network, into buf: inout [UInt8]) { switch value { - case let .regular(amount,address): + case .bitcoin: writeInt(&buf, Int32(1)) - FfiConverterString.write(amount, into: &buf) - FfiConverterString.write(address, into: &buf) - - case let .sendMax(address): + + case .testnet: writeInt(&buf, Int32(2)) - FfiConverterString.write(address, into: &buf) - - case let .opReturn(dataHex): + + case .testnet4: writeInt(&buf, Int32(3)) - FfiConverterString.write(dataHex, into: &buf) - - case let .paymentNoAddress(amount): + + case .signet: writeInt(&buf, Int32(4)) - FfiConverterString.write(amount, into: &buf) - - case .sendMaxNoAddress: + + case .regtest: writeInt(&buf, Int32(5)) } @@ -12599,21 +12394,21 @@ 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 FfiConverterTypeNetwork_lift(_ buf: RustBuffer) throws -> Network { + return try FfiConverterTypeNetwork.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeOutput_lower(_ value: ComposeOutput) -> RustBuffer { - return FfiConverterTypeComposeOutput.lower(value) +public func FfiConverterTypeNetwork_lower(_ value: Network) -> RustBuffer { + return FfiConverterTypeNetwork.lower(value) } -extension ComposeOutput: Equatable, Hashable {} +extension Network: Equatable, Hashable {} -extension ComposeOutput: Codable {} +extension Network: Codable {} @@ -12622,62 +12417,61 @@ extension ComposeOutput: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Compose transaction response - */ -public enum ComposeTransactionResponse { +public enum NetworkType { - /** - * Signed transaction (payment mode) - */ - case signedTransaction(SignedTransactionResponse - ) - /** - * Precomposed transactions (precompose mode) - */ - case precomposedTransactions([PrecomposedTransaction] - ) + case bitcoin + case testnet + case regtest + case signet } #if compiler(>=6) -extension ComposeTransactionResponse: Sendable {} +extension NetworkType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeComposeTransactionResponse: FfiConverterRustBuffer { - typealias SwiftType = ComposeTransactionResponse +public struct FfiConverterTypeNetworkType: FfiConverterRustBuffer { + typealias SwiftType = NetworkType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposeTransactionResponse { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NetworkType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .signedTransaction(try FfiConverterTypeSignedTransactionResponse.read(from: &buf) - ) + case 1: return .bitcoin - case 2: return .precomposedTransactions(try FfiConverterSequenceTypePrecomposedTransaction.read(from: &buf) - ) + case 2: return .testnet + + case 3: return .regtest + + case 4: return .signet default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ComposeTransactionResponse, into buf: inout [UInt8]) { + public static func write(_ value: NetworkType, into buf: inout [UInt8]) { switch value { - case let .signedTransaction(v1): + case .bitcoin: writeInt(&buf, Int32(1)) - FfiConverterTypeSignedTransactionResponse.write(v1, into: &buf) - - case let .precomposedTransactions(v1): + + case .testnet: writeInt(&buf, Int32(2)) - FfiConverterSequenceTypePrecomposedTransaction.write(v1, into: &buf) - + + + case .regtest: + writeInt(&buf, Int32(3)) + + + case .signet: + writeInt(&buf, Int32(4)) + } } } @@ -12686,89 +12480,77 @@ public struct FfiConverterTypeComposeTransactionResponse: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeTransactionResponse_lift(_ buf: RustBuffer) throws -> ComposeTransactionResponse { - return try FfiConverterTypeComposeTransactionResponse.lift(buf) +public func FfiConverterTypeNetworkType_lift(_ buf: RustBuffer) throws -> NetworkType { + return try FfiConverterTypeNetworkType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeTransactionResponse_lower(_ value: ComposeTransactionResponse) -> RustBuffer { - return FfiConverterTypeComposeTransactionResponse.lower(value) +public func FfiConverterTypeNetworkType_lower(_ value: NetworkType) -> RustBuffer { + return FfiConverterTypeNetworkType.lower(value) } -extension ComposeTransactionResponse: Equatable, Hashable {} - -extension ComposeTransactionResponse: Codable {} +extension NetworkType: Equatable, Hashable {} +extension NetworkType: 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 PaymentState { - - case DbActivityError(errorDetails: ActivityError - ) - case DbBlocktankError(errorDetails: BlocktankError - ) - case InitializationError(errorDetails: String - ) + case pending + case succeeded + case failed } +#if compiler(>=6) +extension PaymentState: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDbError: FfiConverterRustBuffer { - typealias SwiftType = DbError +public struct FfiConverterTypePaymentState: FfiConverterRustBuffer { + typealias SwiftType = PaymentState - 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 -> PaymentState { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .pending - case 1: return .DbActivityError( - errorDetails: try FfiConverterTypeActivityError.read(from: &buf) - ) - case 2: return .DbBlocktankError( - errorDetails: try FfiConverterTypeBlocktankError.read(from: &buf) - ) - case 3: return .InitializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .succeeded + + case 3: return .failed + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: DbError, into buf: inout [UInt8]) { + public static func write(_ value: PaymentState, into buf: inout [UInt8]) { switch value { - - - - case let .DbActivityError(errorDetails): + case .pending: writeInt(&buf, Int32(1)) - FfiConverterTypeActivityError.write(errorDetails, into: &buf) - - case let .DbBlocktankError(errorDetails): + + case .succeeded: writeInt(&buf, Int32(2)) - FfiConverterTypeBlocktankError.write(errorDetails, into: &buf) - - case let .InitializationError(errorDetails): + + case .failed: writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - + } } } @@ -12777,150 +12559,70 @@ 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 FfiConverterTypePaymentState_lift(_ buf: RustBuffer) throws -> PaymentState { + return try FfiConverterTypePaymentState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDbError_lower(_ value: DbError) -> RustBuffer { - return FfiConverterTypeDbError.lower(value) +public func FfiConverterTypePaymentState_lower(_ value: PaymentState) -> RustBuffer { + return FfiConverterTypePaymentState.lower(value) } -extension DbError: Equatable, Hashable {} - -extension DbError: Codable {} - - +extension PaymentState: Equatable, Hashable {} +extension PaymentState: 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 PaymentType { - - 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 sent + case received } +#if compiler(>=6) +extension PaymentType: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDecodingError: FfiConverterRustBuffer { - typealias SwiftType = DecodingError +public struct FfiConverterTypePaymentType: FfiConverterRustBuffer { + typealias SwiftType = PaymentType - 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 -> PaymentType { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .sent - 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 2: return .received + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: DecodingError, into buf: inout [UInt8]) { + public static func write(_ value: PaymentType, into buf: inout [UInt8]) { switch value { - - - - case .InvalidFormat: + case .sent: writeInt(&buf, Int32(1)) - case .InvalidNetwork: + case .received: writeInt(&buf, Int32(2)) - - case .InvalidAmount: - writeInt(&buf, Int32(3)) - - - 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 .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) - } } } @@ -12929,96 +12631,158 @@ 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 FfiConverterTypePaymentType_lift(_ buf: RustBuffer) throws -> PaymentType { + return try FfiConverterTypePaymentType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDecodingError_lower(_ value: DecodingError) -> RustBuffer { - return FfiConverterTypeDecodingError.lower(value) +public func FfiConverterTypePaymentType_lower(_ value: PaymentType) -> RustBuffer { + return FfiConverterTypePaymentType.lower(value) } -extension DecodingError: Equatable, Hashable {} +extension PaymentType: Equatable, Hashable {} -extension DecodingError: Codable {} +extension PaymentType: 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. -/** - * Bitcoin account types for default display - */ -public enum DefaultAccountType { +public enum Scanner { - /** - * Normal account - */ - case normal - /** - * SegWit account - */ - case segwit - /** - * Legacy account - */ - case legacy + case onChain(invoice: OnChainInvoice + ) + case lightning(invoice: LightningInvoice + ) + case pubkyAuth(data: String + ) + case lnurlChannel(data: LnurlChannelData + ) + case lnurlAuth(data: LnurlAuthData + ) + case lnurlWithdraw(data: LnurlWithdrawData + ) + case lnurlAddress(data: LnurlAddressData + ) + case lnurlPay(data: LnurlPayData + ) + case nodeId(url: String, network: NetworkType + ) + case gift(code: String, amount: UInt64 + ) } #if compiler(>=6) -extension DefaultAccountType: Sendable {} +extension Scanner: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDefaultAccountType: FfiConverterRustBuffer { - typealias SwiftType = DefaultAccountType +public struct FfiConverterTypeScanner: FfiConverterRustBuffer { + typealias SwiftType = Scanner - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DefaultAccountType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Scanner { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .normal + case 1: return .onChain(invoice: try FfiConverterTypeOnChainInvoice.read(from: &buf) + ) + + case 2: return .lightning(invoice: try FfiConverterTypeLightningInvoice.read(from: &buf) + ) + + case 3: return .pubkyAuth(data: try FfiConverterString.read(from: &buf) + ) + + case 4: return .lnurlChannel(data: try FfiConverterTypeLnurlChannelData.read(from: &buf) + ) + + case 5: return .lnurlAuth(data: try FfiConverterTypeLnurlAuthData.read(from: &buf) + ) + + case 6: return .lnurlWithdraw(data: try FfiConverterTypeLnurlWithdrawData.read(from: &buf) + ) + + case 7: return .lnurlAddress(data: try FfiConverterTypeLnurlAddressData.read(from: &buf) + ) - case 2: return .segwit + case 8: return .lnurlPay(data: try FfiConverterTypeLnurlPayData.read(from: &buf) + ) + + case 9: return .nodeId(url: try FfiConverterString.read(from: &buf), network: try FfiConverterTypeNetworkType.read(from: &buf) + ) - case 3: return .legacy + case 10: return .gift(code: try FfiConverterString.read(from: &buf), amount: try FfiConverterUInt64.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: DefaultAccountType, into buf: inout [UInt8]) { + public static func write(_ value: Scanner, into buf: inout [UInt8]) { switch value { - case .normal: + case let .onChain(invoice): writeInt(&buf, Int32(1)) + FfiConverterTypeOnChainInvoice.write(invoice, into: &buf) + - - case .segwit: + case let .lightning(invoice): writeInt(&buf, Int32(2)) + FfiConverterTypeLightningInvoice.write(invoice, into: &buf) + - - case .legacy: + case let .pubkyAuth(data): writeInt(&buf, Int32(3)) + FfiConverterString.write(data, into: &buf) + + + case let .lnurlChannel(data): + writeInt(&buf, Int32(4)) + FfiConverterTypeLnurlChannelData.write(data, into: &buf) + + + case let .lnurlAuth(data): + writeInt(&buf, Int32(5)) + FfiConverterTypeLnurlAuthData.write(data, into: &buf) + + + case let .lnurlWithdraw(data): + writeInt(&buf, Int32(6)) + FfiConverterTypeLnurlWithdrawData.write(data, into: &buf) + + + case let .lnurlAddress(data): + writeInt(&buf, Int32(7)) + FfiConverterTypeLnurlAddressData.write(data, into: &buf) + + + case let .lnurlPay(data): + writeInt(&buf, Int32(8)) + FfiConverterTypeLnurlPayData.write(data, into: &buf) + + + case let .nodeId(url,network): + writeInt(&buf, Int32(9)) + FfiConverterString.write(url, into: &buf) + FfiConverterTypeNetworkType.write(network, into: &buf) + + case let .gift(code,amount): + writeInt(&buf, Int32(10)) + FfiConverterString.write(code, into: &buf) + FfiConverterUInt64.write(amount, into: &buf) + } } } @@ -13027,21 +12791,21 @@ public struct FfiConverterTypeDefaultAccountType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDefaultAccountType_lift(_ buf: RustBuffer) throws -> DefaultAccountType { - return try FfiConverterTypeDefaultAccountType.lift(buf) +public func FfiConverterTypeScanner_lift(_ buf: RustBuffer) throws -> Scanner { + return try FfiConverterTypeScanner.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDefaultAccountType_lower(_ value: DefaultAccountType) -> RustBuffer { - return FfiConverterTypeDefaultAccountType.lower(value) +public func FfiConverterTypeScanner_lower(_ value: Scanner) -> RustBuffer { + return FfiConverterTypeScanner.lower(value) } -extension DefaultAccountType: Equatable, Hashable {} +extension Scanner: Equatable, Hashable {} -extension DefaultAccountType: Codable {} +extension Scanner: Codable {} @@ -13050,62 +12814,47 @@ extension DefaultAccountType: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Union type for HD Node (either a String or HDNodeType) - */ -public enum HdNodeTypeOrString { +public enum SortDirection { - /** - * HD Node as a string - */ - case string(String - ) - /** - * HD Node as an object - */ - case node(HdNodeType - ) + case asc + case desc } #if compiler(>=6) -extension HdNodeTypeOrString: Sendable {} +extension SortDirection: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeHDNodeTypeOrString: FfiConverterRustBuffer { - typealias SwiftType = HdNodeTypeOrString +public struct FfiConverterTypeSortDirection: FfiConverterRustBuffer { + typealias SwiftType = SortDirection - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HdNodeTypeOrString { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SortDirection { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .string(try FfiConverterString.read(from: &buf) - ) + case 1: return .asc - case 2: return .node(try FfiConverterTypeHDNodeType.read(from: &buf) - ) + case 2: return .desc default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: HdNodeTypeOrString, into buf: inout [UInt8]) { + public static func write(_ value: SortDirection, into buf: inout [UInt8]) { switch value { - case let .string(v1): + case .asc: writeInt(&buf, Int32(1)) - FfiConverterString.write(v1, into: &buf) - - case let .node(v1): + + case .desc: writeInt(&buf, Int32(2)) - FfiConverterTypeHDNodeType.write(v1, into: &buf) - + } } } @@ -13114,21 +12863,21 @@ public struct FfiConverterTypeHDNodeTypeOrString: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHDNodeTypeOrString_lift(_ buf: RustBuffer) throws -> HdNodeTypeOrString { - return try FfiConverterTypeHDNodeTypeOrString.lift(buf) +public func FfiConverterTypeSortDirection_lift(_ buf: RustBuffer) throws -> SortDirection { + return try FfiConverterTypeSortDirection.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHDNodeTypeOrString_lower(_ value: HdNodeTypeOrString) -> RustBuffer { - return FfiConverterTypeHDNodeTypeOrString.lower(value) +public func FfiConverterTypeSortDirection_lower(_ value: SortDirection) -> RustBuffer { + return FfiConverterTypeSortDirection.lower(value) } -extension HdNodeTypeOrString: Equatable, Hashable {} +extension SortDirection: Equatable, Hashable {} -extension HdNodeTypeOrString: Codable {} +extension SortDirection: Codable {} @@ -13136,91 +12885,59 @@ extension HdNodeTypeOrString: Codable {} -public enum LnurlError: Swift.Error { +public enum SweepError: Swift.Error { - case InvalidAddress - case ClientCreationFailed - case RequestFailed - case InvalidResponse - case InvalidAmount(amountSatoshis: UInt64, min: UInt64, max: UInt64 - ) - case InvoiceCreationFailed(errorDetails: String + case SweepFailed(String ) - case AuthenticationFailed + case NoUtxosFound + case InvalidMnemonic } #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLnurlError: FfiConverterRustBuffer { - typealias SwiftType = LnurlError +public struct FfiConverterTypeSweepError: FfiConverterRustBuffer { + typealias SwiftType = SweepError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InvalidAddress - case 2: return .ClientCreationFailed - case 3: return .RequestFailed - case 4: return .InvalidResponse - case 5: return .InvalidAmount( - amountSatoshis: try FfiConverterUInt64.read(from: &buf), - min: try FfiConverterUInt64.read(from: &buf), - max: try FfiConverterUInt64.read(from: &buf) - ) - case 6: return .InvoiceCreationFailed( - errorDetails: try FfiConverterString.read(from: &buf) + case 1: return .SweepFailed( + try FfiConverterString.read(from: &buf) ) - case 7: return .AuthenticationFailed + case 2: return .NoUtxosFound + case 3: return .InvalidMnemonic default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: LnurlError, into buf: inout [UInt8]) { + public static func write(_ value: SweepError, into buf: inout [UInt8]) { switch value { - case .InvalidAddress: + case let .SweepFailed(v1): writeInt(&buf, Int32(1)) + FfiConverterString.write(v1, into: &buf) + - - case .ClientCreationFailed: + case .NoUtxosFound: writeInt(&buf, Int32(2)) - case .RequestFailed: + case .InvalidMnemonic: writeInt(&buf, Int32(3)) - - case .InvalidResponse: - writeInt(&buf, Int32(4)) - - - case let .InvalidAmount(amountSatoshis,min,max): - writeInt(&buf, Int32(5)) - FfiConverterUInt64.write(amountSatoshis, into: &buf) - FfiConverterUInt64.write(min, into: &buf) - FfiConverterUInt64.write(max, into: &buf) - - - case let .InvoiceCreationFailed(errorDetails): - writeInt(&buf, Int32(6)) - FfiConverterString.write(errorDetails, into: &buf) - - - case .AuthenticationFailed: - writeInt(&buf, Int32(7)) - } } } @@ -13229,26 +12946,26 @@ public struct FfiConverterTypeLnurlError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlError_lift(_ buf: RustBuffer) throws -> LnurlError { - return try FfiConverterTypeLnurlError.lift(buf) +public func FfiConverterTypeSweepError_lift(_ buf: RustBuffer) throws -> SweepError { + return try FfiConverterTypeSweepError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlError_lower(_ value: LnurlError) -> RustBuffer { - return FfiConverterTypeLnurlError.lower(value) +public func FfiConverterTypeSweepError_lower(_ value: SweepError) -> RustBuffer { + return FfiConverterTypeSweepError.lower(value) } -extension LnurlError: Equatable, Hashable {} +extension SweepError: Equatable, Hashable {} -extension LnurlError: Codable {} +extension SweepError: Codable {} -extension LnurlError: Foundation.LocalizedError { +extension SweepError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -13259,59 +12976,74 @@ extension LnurlError: 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 / coin type for Trezor operations. + */ -public enum ManualRefundStateEnum { +public enum TrezorCoinType { - case created - case approved - case rejected - case sent + /** + * Bitcoin mainnet + */ + case bitcoin + /** + * Bitcoin testnet + */ + case testnet + /** + * Bitcoin signet (treated as testnet by the device) + */ + case signet + /** + * Bitcoin regtest + */ + case regtest } #if compiler(>=6) -extension ManualRefundStateEnum: Sendable {} +extension TrezorCoinType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeManualRefundStateEnum: FfiConverterRustBuffer { - typealias SwiftType = ManualRefundStateEnum +public struct FfiConverterTypeTrezorCoinType: FfiConverterRustBuffer { + typealias SwiftType = TrezorCoinType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ManualRefundStateEnum { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorCoinType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .created + case 1: return .bitcoin - case 2: return .approved + case 2: return .testnet - case 3: return .rejected + case 3: return .signet - case 4: return .sent + case 4: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ManualRefundStateEnum, into buf: inout [UInt8]) { + public static func write(_ value: TrezorCoinType, into buf: inout [UInt8]) { switch value { - case .created: + case .bitcoin: writeInt(&buf, Int32(1)) - case .approved: + case .testnet: writeInt(&buf, Int32(2)) - case .rejected: + case .signet: writeInt(&buf, Int32(3)) - case .sent: + case .regtest: writeInt(&buf, Int32(4)) } @@ -13322,106 +13054,265 @@ public struct FfiConverterTypeManualRefundStateEnum: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeManualRefundStateEnum_lift(_ buf: RustBuffer) throws -> ManualRefundStateEnum { - return try FfiConverterTypeManualRefundStateEnum.lift(buf) +public func FfiConverterTypeTrezorCoinType_lift(_ buf: RustBuffer) throws -> TrezorCoinType { + return try FfiConverterTypeTrezorCoinType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeManualRefundStateEnum_lower(_ value: ManualRefundStateEnum) -> RustBuffer { - return FfiConverterTypeManualRefundStateEnum.lower(value) +public func FfiConverterTypeTrezorCoinType_lower(_ value: TrezorCoinType) -> RustBuffer { + return FfiConverterTypeTrezorCoinType.lower(value) } -extension ManualRefundStateEnum: Equatable, Hashable {} +extension TrezorCoinType: Equatable, Hashable {} -extension ManualRefundStateEnum: Codable {} +extension TrezorCoinType: 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 Network { +/** + * Trezor-related errors exposed via FFI. + */ +public enum TrezorError: Swift.Error { + + /** - * Mainnet Bitcoin. + * Transport layer error (USB/Bluetooth communication) */ - case bitcoin + case TransportError(errorDetails: String + ) /** - * Bitcoin's testnet network. + * No Trezor device found */ - case testnet + case DeviceNotFound /** - * Bitcoin's testnet4 network. + * Device disconnected during operation */ - case testnet4 + case DeviceDisconnected /** - * Bitcoin's signet network. + * Connection error */ - case signet + case ConnectionError(errorDetails: String + ) /** - * Bitcoin's regtest network. + * Protocol error (encoding/decoding) */ - case regtest + case ProtocolError(errorDetails: String + ) + /** + * Pairing required for Bluetooth connection + */ + case PairingRequired + /** + * Pairing failed + */ + case PairingFailed(errorDetails: String + ) + /** + * PIN is required + */ + case PinRequired + /** + * PIN entry cancelled + */ + case PinCancelled + /** + * Invalid PIN entered + */ + case InvalidPin + /** + * Passphrase is required + */ + case PassphraseRequired + /** + * Action cancelled by user on device + */ + case UserCancelled + /** + * Operation timed out + */ + case Timeout + /** + * Invalid derivation path + */ + case InvalidPath(errorDetails: String + ) + /** + * Device returned an error + */ + case DeviceError(errorDetails: String + ) + /** + * Trezor manager not initialized + */ + case NotInitialized + /** + * No device connected + */ + case NotConnected + /** + * Session error + */ + case SessionError(errorDetails: String + ) + /** + * IO error + */ + case IoError(errorDetails: String + ) } -#if compiler(>=6) -extension Network: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeNetwork: FfiConverterRustBuffer { - typealias SwiftType = Network +public struct FfiConverterTypeTrezorError: FfiConverterRustBuffer { + typealias SwiftType = TrezorError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Network { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .bitcoin - - case 2: return .testnet - - case 3: return .testnet4 - - case 4: return .signet - - case 5: return .regtest + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .TransportError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .DeviceNotFound + case 3: return .DeviceDisconnected + case 4: return .ConnectionError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 5: return .ProtocolError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 6: return .PairingRequired + case 7: return .PairingFailed( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 8: return .PinRequired + case 9: return .PinCancelled + case 10: return .InvalidPin + case 11: return .PassphraseRequired + case 12: return .UserCancelled + case 13: return .Timeout + case 14: return .InvalidPath( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 15: return .DeviceError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 16: return .NotInitialized + case 17: return .NotConnected + case 18: return .SessionError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 19: return .IoError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: Network, into buf: inout [UInt8]) { + public static func write(_ value: TrezorError, into buf: inout [UInt8]) { switch value { + + - case .bitcoin: - writeInt(&buf, Int32(1)) + case let .TransportError(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + - case .testnet: + case .DeviceNotFound: writeInt(&buf, Int32(2)) - case .testnet4: + case .DeviceDisconnected: writeInt(&buf, Int32(3)) - case .signet: + case let .ConnectionError(errorDetails): writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .regtest: + case let .ProtocolError(errorDetails): writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + + + case .PairingRequired: + writeInt(&buf, Int32(6)) + + + case let .PairingFailed(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + + + case .PinRequired: + writeInt(&buf, Int32(8)) + + + case .PinCancelled: + writeInt(&buf, Int32(9)) + + + case .InvalidPin: + writeInt(&buf, Int32(10)) + + + case .PassphraseRequired: + writeInt(&buf, Int32(11)) + + + case .UserCancelled: + writeInt(&buf, Int32(12)) + + + case .Timeout: + writeInt(&buf, Int32(13)) + + + case let .InvalidPath(errorDetails): + writeInt(&buf, Int32(14)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .DeviceError(errorDetails): + writeInt(&buf, Int32(15)) + FfiConverterString.write(errorDetails, into: &buf) + + case .NotInitialized: + writeInt(&buf, Int32(16)) + + + case .NotConnected: + writeInt(&buf, Int32(17)) + + + case let .SessionError(errorDetails): + writeInt(&buf, Int32(18)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .IoError(errorDetails): + writeInt(&buf, Int32(19)) + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -13430,84 +13321,126 @@ public struct FfiConverterTypeNetwork: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNetwork_lift(_ buf: RustBuffer) throws -> Network { - return try FfiConverterTypeNetwork.lift(buf) +public func FfiConverterTypeTrezorError_lift(_ buf: RustBuffer) throws -> TrezorError { + return try FfiConverterTypeTrezorError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNetwork_lower(_ value: Network) -> RustBuffer { - return FfiConverterTypeNetwork.lower(value) +public func FfiConverterTypeTrezorError_lower(_ value: TrezorError) -> RustBuffer { + return FfiConverterTypeTrezorError.lower(value) } -extension Network: Equatable, Hashable {} +extension TrezorError: Equatable, Hashable {} + +extension TrezorError: Codable {} -extension Network: Codable {} +extension TrezorError: 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. +/** + * Script types for address derivation. + */ -public enum NetworkType { +public enum TrezorScriptType { - case bitcoin - case testnet - case regtest - case signet + /** + * P2PKH (legacy) + */ + case spendAddress + /** + * P2SH-P2WPKH (nested SegWit) + */ + case spendP2shWitness + /** + * P2WPKH (native SegWit) + */ + case spendWitness + /** + * P2TR (Taproot) + */ + case spendTaproot + /** + * P2SH multisig + */ + case spendMultisig + /** + * External/watch-only input (not signed by device) + */ + case external } #if compiler(>=6) -extension NetworkType: Sendable {} +extension TrezorScriptType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeNetworkType: FfiConverterRustBuffer { - typealias SwiftType = NetworkType +public struct FfiConverterTypeTrezorScriptType: FfiConverterRustBuffer { + typealias SwiftType = TrezorScriptType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NetworkType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorScriptType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .bitcoin + case 1: return .spendAddress - case 2: return .testnet + case 2: return .spendP2shWitness - case 3: return .regtest + case 3: return .spendWitness - case 4: return .signet + case 4: return .spendTaproot + + case 5: return .spendMultisig + + case 6: return .external default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: NetworkType, into buf: inout [UInt8]) { + public static func write(_ value: TrezorScriptType, into buf: inout [UInt8]) { switch value { - case .bitcoin: + case .spendAddress: writeInt(&buf, Int32(1)) - case .testnet: + case .spendP2shWitness: writeInt(&buf, Int32(2)) - case .regtest: + case .spendWitness: writeInt(&buf, Int32(3)) - case .signet: + case .spendTaproot: writeInt(&buf, Int32(4)) + + case .spendMultisig: + writeInt(&buf, Int32(5)) + + + case .external: + writeInt(&buf, Int32(6)) + } } } @@ -13516,21 +13449,21 @@ public struct FfiConverterTypeNetworkType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNetworkType_lift(_ buf: RustBuffer) throws -> NetworkType { - return try FfiConverterTypeNetworkType.lift(buf) +public func FfiConverterTypeTrezorScriptType_lift(_ buf: RustBuffer) throws -> TrezorScriptType { + return try FfiConverterTypeTrezorScriptType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNetworkType_lower(_ value: NetworkType) -> RustBuffer { - return FfiConverterTypeNetworkType.lower(value) +public func FfiConverterTypeTrezorScriptType_lower(_ value: TrezorScriptType) -> RustBuffer { + return FfiConverterTypeTrezorScriptType.lower(value) } -extension NetworkType: Equatable, Hashable {} +extension TrezorScriptType: Equatable, Hashable {} -extension NetworkType: Codable {} +extension TrezorScriptType: Codable {} @@ -13539,124 +13472,54 @@ extension NetworkType: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Transport type for Trezor devices. + */ -public enum PaymentState { +public enum TrezorTransportType { - case pending - case succeeded - case failed + /** + * USB connection + */ + case usb + /** + * Bluetooth connection + */ + case bluetooth } #if compiler(>=6) -extension PaymentState: Sendable {} +extension TrezorTransportType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePaymentState: FfiConverterRustBuffer { - typealias SwiftType = PaymentState +public struct FfiConverterTypeTrezorTransportType: FfiConverterRustBuffer { + typealias SwiftType = TrezorTransportType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PaymentState { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .pending - - case 2: return .succeeded - - case 3: return .failed - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: PaymentState, into buf: inout [UInt8]) { - switch value { - - - case .pending: - writeInt(&buf, Int32(1)) - - - case .succeeded: - writeInt(&buf, Int32(2)) - - - case .failed: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePaymentState_lift(_ buf: RustBuffer) throws -> PaymentState { - return try FfiConverterTypePaymentState.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePaymentState_lower(_ value: PaymentState) -> RustBuffer { - return FfiConverterTypePaymentState.lower(value) -} - - -extension PaymentState: Equatable, Hashable {} - -extension PaymentState: 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 PaymentType { - - case sent - case received -} - - -#if compiler(>=6) -extension PaymentType: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypePaymentType: FfiConverterRustBuffer { - typealias SwiftType = PaymentType - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PaymentType { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .sent + case 1: return .usb - case 2: return .received + case 2: return .bluetooth default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: PaymentType, into buf: inout [UInt8]) { + public static func write(_ value: TrezorTransportType, into buf: inout [UInt8]) { switch value { - case .sent: + case .usb: writeInt(&buf, Int32(1)) - case .received: + case .bluetooth: writeInt(&buf, Int32(2)) } @@ -13667,21 +13530,21 @@ public struct FfiConverterTypePaymentType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePaymentType_lift(_ buf: RustBuffer) throws -> PaymentType { - return try FfiConverterTypePaymentType.lift(buf) +public func FfiConverterTypeTrezorTransportType_lift(_ buf: RustBuffer) throws -> TrezorTransportType { + return try FfiConverterTypeTrezorTransportType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePaymentType_lower(_ value: PaymentType) -> RustBuffer { - return FfiConverterTypePaymentType.lower(value) +public func FfiConverterTypeTrezorTransportType_lower(_ value: TrezorTransportType) -> RustBuffer { + return FfiConverterTypeTrezorTransportType.lower(value) } -extension PaymentType: Equatable, Hashable {} +extension TrezorTransportType: Equatable, Hashable {} -extension PaymentType: Codable {} +extension TrezorTransportType: Codable {} @@ -13691,1502 +13554,116 @@ extension PaymentType: 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 Scanner { +public enum WordCount { - case onChain(invoice: OnChainInvoice - ) - case lightning(invoice: LightningInvoice - ) - case pubkyAuth(data: String - ) - case lnurlChannel(data: LnurlChannelData - ) - case lnurlAuth(data: LnurlAuthData - ) - case lnurlWithdraw(data: LnurlWithdrawData - ) - case lnurlAddress(data: LnurlAddressData - ) - case lnurlPay(data: LnurlPayData - ) - case nodeId(url: String, network: NetworkType - ) - case gift(code: String, amount: UInt64 - ) + /** + * 12-word mnemonic (128 bits of entropy) + */ + case words12 + /** + * 15-word mnemonic (160 bits of entropy) + */ + case words15 + /** + * 18-word mnemonic (192 bits of entropy) + */ + case words18 + /** + * 21-word mnemonic (224 bits of entropy) + */ + case words21 + /** + * 24-word mnemonic (256 bits of entropy) + */ + case words24 } #if compiler(>=6) -extension Scanner: Sendable {} +extension WordCount: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeScanner: FfiConverterRustBuffer { - typealias SwiftType = Scanner +public struct FfiConverterTypeWordCount: FfiConverterRustBuffer { + typealias SwiftType = WordCount - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Scanner { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WordCount { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .onChain(invoice: try FfiConverterTypeOnChainInvoice.read(from: &buf) - ) - - case 2: return .lightning(invoice: try FfiConverterTypeLightningInvoice.read(from: &buf) - ) - - case 3: return .pubkyAuth(data: try FfiConverterString.read(from: &buf) - ) - - case 4: return .lnurlChannel(data: try FfiConverterTypeLnurlChannelData.read(from: &buf) - ) - - case 5: return .lnurlAuth(data: try FfiConverterTypeLnurlAuthData.read(from: &buf) - ) - - case 6: return .lnurlWithdraw(data: try FfiConverterTypeLnurlWithdrawData.read(from: &buf) - ) + case 1: return .words12 - case 7: return .lnurlAddress(data: try FfiConverterTypeLnurlAddressData.read(from: &buf) - ) + case 2: return .words15 - case 8: return .lnurlPay(data: try FfiConverterTypeLnurlPayData.read(from: &buf) - ) + case 3: return .words18 - case 9: return .nodeId(url: try FfiConverterString.read(from: &buf), network: try FfiConverterTypeNetworkType.read(from: &buf) - ) + case 4: return .words21 - case 10: return .gift(code: try FfiConverterString.read(from: &buf), amount: try FfiConverterUInt64.read(from: &buf) - ) + case 5: return .words24 default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: Scanner, into buf: inout [UInt8]) { + public static func write(_ value: WordCount, into buf: inout [UInt8]) { switch value { - case let .onChain(invoice): + case .words12: writeInt(&buf, Int32(1)) - FfiConverterTypeOnChainInvoice.write(invoice, into: &buf) - - - case let .lightning(invoice): - writeInt(&buf, Int32(2)) - FfiConverterTypeLightningInvoice.write(invoice, into: &buf) - - - case let .pubkyAuth(data): - writeInt(&buf, Int32(3)) - FfiConverterString.write(data, into: &buf) - - - case let .lnurlChannel(data): - writeInt(&buf, Int32(4)) - FfiConverterTypeLnurlChannelData.write(data, into: &buf) - - - case let .lnurlAuth(data): - writeInt(&buf, Int32(5)) - FfiConverterTypeLnurlAuthData.write(data, into: &buf) - - case let .lnurlWithdraw(data): - writeInt(&buf, Int32(6)) - FfiConverterTypeLnurlWithdrawData.write(data, into: &buf) - - case let .lnurlAddress(data): - writeInt(&buf, Int32(7)) - FfiConverterTypeLnurlAddressData.write(data, into: &buf) - + case .words15: + writeInt(&buf, Int32(2)) - case let .lnurlPay(data): - writeInt(&buf, Int32(8)) - FfiConverterTypeLnurlPayData.write(data, into: &buf) - - case let .nodeId(url,network): - writeInt(&buf, Int32(9)) - FfiConverterString.write(url, into: &buf) - FfiConverterTypeNetworkType.write(network, into: &buf) - + case .words18: + writeInt(&buf, Int32(3)) + + + case .words21: + writeInt(&buf, Int32(4)) + + + case .words24: + writeInt(&buf, Int32(5)) - case let .gift(code,amount): - writeInt(&buf, Int32(10)) - FfiConverterString.write(code, into: &buf) - FfiConverterUInt64.write(amount, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeScanner_lift(_ buf: RustBuffer) throws -> Scanner { - return try FfiConverterTypeScanner.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeScanner_lower(_ value: Scanner) -> RustBuffer { - return FfiConverterTypeScanner.lower(value) -} - - -extension Scanner: Equatable, Hashable {} - -extension Scanner: Codable {} - - - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Script type for inputs and outputs - */ - -public enum ScriptType { - - case spendAddress - case spendMultisig - case spendWitness - case spendP2shWitness - case spendTaproot - case external - case payToAddress - case payToScriptHash - case payToMultisig - case payToWitness - case payToP2shWitness - case payToTaproot - case payToOpReturn -} - - -#if compiler(>=6) -extension ScriptType: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeScriptType: FfiConverterRustBuffer { - typealias SwiftType = ScriptType - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ScriptType { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .spendAddress - - case 2: return .spendMultisig - - case 3: return .spendWitness - - case 4: return .spendP2shWitness - - case 5: return .spendTaproot - - case 6: return .external - - case 7: return .payToAddress - - case 8: return .payToScriptHash - - case 9: return .payToMultisig - - case 10: return .payToWitness - - case 11: return .payToP2shWitness - - case 12: return .payToTaproot - - case 13: return .payToOpReturn - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ScriptType, into buf: inout [UInt8]) { - switch value { - - - case .spendAddress: - writeInt(&buf, Int32(1)) - - - case .spendMultisig: - writeInt(&buf, Int32(2)) - - - case .spendWitness: - writeInt(&buf, Int32(3)) - - - case .spendP2shWitness: - writeInt(&buf, Int32(4)) - - - case .spendTaproot: - writeInt(&buf, Int32(5)) - - - case .external: - writeInt(&buf, Int32(6)) - - - case .payToAddress: - writeInt(&buf, Int32(7)) - - - case .payToScriptHash: - writeInt(&buf, Int32(8)) - - - case .payToMultisig: - writeInt(&buf, Int32(9)) - - - case .payToWitness: - writeInt(&buf, Int32(10)) - - - case .payToP2shWitness: - writeInt(&buf, Int32(11)) - - - case .payToTaproot: - writeInt(&buf, Int32(12)) - - - case .payToOpReturn: - writeInt(&buf, Int32(13)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeScriptType_lift(_ buf: RustBuffer) throws -> ScriptType { - return try FfiConverterTypeScriptType.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeScriptType_lower(_ value: ScriptType) -> RustBuffer { - return FfiConverterTypeScriptType.lower(value) -} - - -extension ScriptType: Equatable, Hashable {} - -extension ScriptType: 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 SortDirection { - - case asc - case desc -} - - -#if compiler(>=6) -extension SortDirection: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSortDirection: FfiConverterRustBuffer { - typealias SwiftType = SortDirection - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SortDirection { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .asc - - case 2: return .desc - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: SortDirection, into buf: inout [UInt8]) { - switch value { - - - case .asc: - writeInt(&buf, Int32(1)) - - - case .desc: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSortDirection_lift(_ buf: RustBuffer) throws -> SortDirection { - return try FfiConverterTypeSortDirection.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSortDirection_lower(_ value: SortDirection) -> RustBuffer { - return FfiConverterTypeSortDirection.lower(value) -} - - -extension SortDirection: Equatable, Hashable {} - -extension SortDirection: Codable {} - - - - - - - -public enum SweepError: Swift.Error { - - - - case SweepFailed(String - ) - case NoUtxosFound - case InvalidMnemonic -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeSweepError: FfiConverterRustBuffer { - typealias SwiftType = SweepError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .SweepFailed( - try FfiConverterString.read(from: &buf) - ) - case 2: return .NoUtxosFound - case 3: return .InvalidMnemonic - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: SweepError, into buf: inout [UInt8]) { - switch value { - - - - - - case let .SweepFailed(v1): - writeInt(&buf, Int32(1)) - FfiConverterString.write(v1, into: &buf) - - - case .NoUtxosFound: - writeInt(&buf, Int32(2)) - - - case .InvalidMnemonic: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSweepError_lift(_ buf: RustBuffer) throws -> SweepError { - return try FfiConverterTypeSweepError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeSweepError_lower(_ value: SweepError) -> RustBuffer { - return FfiConverterTypeSweepError.lower(value) -} - - -extension SweepError: Equatable, Hashable {} - -extension SweepError: Codable {} - - - - -extension SweepError: 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. -/** - * Token filter options for getAccountInfo - */ - -public enum TokenFilter { - - /** - * Return only addresses with nonzero balance (default) - */ - case nonzero - /** - * Return addresses with at least one transaction - */ - case used - /** - * Return all derived addresses - */ - case derived -} - - -#if compiler(>=6) -extension TokenFilter: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTokenFilter: FfiConverterRustBuffer { - typealias SwiftType = TokenFilter - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenFilter { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .nonzero - - case 2: return .used - - case 3: return .derived - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: TokenFilter, into buf: inout [UInt8]) { - switch value { - - - case .nonzero: - writeInt(&buf, Int32(1)) - - - case .used: - writeInt(&buf, Int32(2)) - - - case .derived: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTokenFilter_lift(_ buf: RustBuffer) throws -> TokenFilter { - return try FfiConverterTypeTokenFilter.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTokenFilter_lower(_ value: TokenFilter) -> RustBuffer { - return FfiConverterTypeTokenFilter.lower(value) -} - - -extension TokenFilter: Equatable, Hashable {} - -extension TokenFilter: Codable {} - - - - - - - -/** - * Error types for Trezor Connect operations - */ -public enum TrezorConnectError: Swift.Error { - - - - /** - * Error during serialization/deserialization - */ - case SerdeError(errorDetails: String - ) - /** - * Error with URL parsing or formatting - */ - case UrlError(errorDetails: String - ) - /** - * Environment-related errors - */ - case EnvironmentError(errorDetails: String - ) - /** - * General errors - */ - case Other(errorDetails: String - ) - case ClientError(errorDetails: String - ) -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTrezorConnectError: FfiConverterRustBuffer { - typealias SwiftType = TrezorConnectError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorConnectError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .SerdeError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .UrlError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .EnvironmentError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .Other( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 5: return .ClientError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: TrezorConnectError, into buf: inout [UInt8]) { - switch value { - - - - - - case let .SerdeError(errorDetails): - writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .UrlError(errorDetails): - writeInt(&buf, Int32(2)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .EnvironmentError(errorDetails): - writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .Other(errorDetails): - writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .ClientError(errorDetails): - writeInt(&buf, Int32(5)) - FfiConverterString.write(errorDetails, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorConnectError_lift(_ buf: RustBuffer) throws -> TrezorConnectError { - return try FfiConverterTypeTrezorConnectError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorConnectError_lower(_ value: TrezorConnectError) -> RustBuffer { - return FfiConverterTypeTrezorConnectError.lower(value) -} - - -extension TrezorConnectError: Equatable, Hashable {} - -extension TrezorConnectError: Codable {} - - - - -extension TrezorConnectError: 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. -/** - * Environment options for Trezor deep linking - */ - -public enum TrezorEnvironment { - - /** - * Production environment (currently unavailable according to docs) - */ - case production - /** - * Development environment - */ - case development - /** - * Local environment - */ - case local -} - - -#if compiler(>=6) -extension TrezorEnvironment: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTrezorEnvironment: FfiConverterRustBuffer { - typealias SwiftType = TrezorEnvironment - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorEnvironment { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .production - - case 2: return .development - - case 3: return .local - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: TrezorEnvironment, into buf: inout [UInt8]) { - switch value { - - - case .production: - writeInt(&buf, Int32(1)) - - - case .development: - writeInt(&buf, Int32(2)) - - - case .local: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorEnvironment_lift(_ buf: RustBuffer) throws -> TrezorEnvironment { - return try FfiConverterTypeTrezorEnvironment.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorEnvironment_lower(_ value: TrezorEnvironment) -> RustBuffer { - return FfiConverterTypeTrezorEnvironment.lower(value) -} - - -extension TrezorEnvironment: Equatable, Hashable {} - -extension TrezorEnvironment: Codable {} - - - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Enum representing the different types of Trezor responses - */ - -public enum TrezorResponsePayload { - - /** - * Response from getFeatures method - */ - case features(FeatureResponse - ) - /** - * Response from getAddress method - */ - case address(AddressResponse - ) - /** - * Response from getPublicKey method - */ - case publicKey(PublicKeyResponse - ) - /** - * Response from getAccountInfo method - */ - case accountInfo(AccountInfoResponse - ) - /** - * Response from composeTransaction method - */ - case composeTransaction(ComposeTransactionResponse - ) - /** - * Response from verifyMessage method - */ - case verifyMessage(VerifyMessageResponse - ) - /** - * Response from signMessage method - */ - case messageSignature(MessageSignatureResponse - ) - /** - * Response from signTransaction method - */ - case signedTransaction(SignedTransactionResponse - ) -} - - -#if compiler(>=6) -extension TrezorResponsePayload: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTrezorResponsePayload: FfiConverterRustBuffer { - typealias SwiftType = TrezorResponsePayload - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorResponsePayload { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .features(try FfiConverterTypeFeatureResponse.read(from: &buf) - ) - - case 2: return .address(try FfiConverterTypeAddressResponse.read(from: &buf) - ) - - case 3: return .publicKey(try FfiConverterTypePublicKeyResponse.read(from: &buf) - ) - - case 4: return .accountInfo(try FfiConverterTypeAccountInfoResponse.read(from: &buf) - ) - - case 5: return .composeTransaction(try FfiConverterTypeComposeTransactionResponse.read(from: &buf) - ) - - case 6: return .verifyMessage(try FfiConverterTypeVerifyMessageResponse.read(from: &buf) - ) - - case 7: return .messageSignature(try FfiConverterTypeMessageSignatureResponse.read(from: &buf) - ) - - case 8: return .signedTransaction(try FfiConverterTypeSignedTransactionResponse.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: TrezorResponsePayload, into buf: inout [UInt8]) { - switch value { - - - case let .features(v1): - writeInt(&buf, Int32(1)) - FfiConverterTypeFeatureResponse.write(v1, into: &buf) - - - case let .address(v1): - writeInt(&buf, Int32(2)) - FfiConverterTypeAddressResponse.write(v1, into: &buf) - - - case let .publicKey(v1): - writeInt(&buf, Int32(3)) - FfiConverterTypePublicKeyResponse.write(v1, into: &buf) - - - case let .accountInfo(v1): - writeInt(&buf, Int32(4)) - FfiConverterTypeAccountInfoResponse.write(v1, into: &buf) - - - case let .composeTransaction(v1): - writeInt(&buf, Int32(5)) - FfiConverterTypeComposeTransactionResponse.write(v1, into: &buf) - - - case let .verifyMessage(v1): - writeInt(&buf, Int32(6)) - FfiConverterTypeVerifyMessageResponse.write(v1, into: &buf) - - - case let .messageSignature(v1): - writeInt(&buf, Int32(7)) - FfiConverterTypeMessageSignatureResponse.write(v1, into: &buf) - - - case let .signedTransaction(v1): - writeInt(&buf, Int32(8)) - FfiConverterTypeSignedTransactionResponse.write(v1, into: &buf) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorResponsePayload_lift(_ buf: RustBuffer) throws -> TrezorResponsePayload { - return try FfiConverterTypeTrezorResponsePayload.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorResponsePayload_lower(_ value: TrezorResponsePayload) -> RustBuffer { - return FfiConverterTypeTrezorResponsePayload.lower(value) -} - - -extension TrezorResponsePayload: Equatable, Hashable {} - -extension TrezorResponsePayload: 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 WordCount { - - /** - * 12-word mnemonic (128 bits of entropy) - */ - case words12 - /** - * 15-word mnemonic (160 bits of entropy) - */ - case words15 - /** - * 18-word mnemonic (192 bits of entropy) - */ - case words18 - /** - * 21-word mnemonic (224 bits of entropy) - */ - case words21 - /** - * 24-word mnemonic (256 bits of entropy) - */ - case words24 -} - - -#if compiler(>=6) -extension WordCount: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeWordCount: FfiConverterRustBuffer { - typealias SwiftType = WordCount - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WordCount { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .words12 - - case 2: return .words15 - - case 3: return .words18 - - case 4: return .words21 - - case 5: return .words24 - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: WordCount, into buf: inout [UInt8]) { - switch value { - - - case .words12: - writeInt(&buf, Int32(1)) - - - case .words15: - writeInt(&buf, Int32(2)) - - - case .words18: - writeInt(&buf, Int32(3)) - - - case .words21: - writeInt(&buf, Int32(4)) - - - case .words24: - writeInt(&buf, Int32(5)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeWordCount_lift(_ buf: RustBuffer) throws -> WordCount { - return try FfiConverterTypeWordCount.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeWordCount_lower(_ value: WordCount) -> RustBuffer { - return FfiConverterTypeWordCount.lower(value) -} - - -extension WordCount: Equatable, Hashable {} - -extension WordCount: Codable {} - - - - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionUInt8: FfiConverterRustBuffer { - typealias SwiftType = UInt8? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt8.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 FfiConverterUInt8.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { - typealias SwiftType = UInt32? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt32.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 FfiConverterUInt32.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionUInt64: FfiConverterRustBuffer { - typealias SwiftType = UInt64? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt64.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 FfiConverterUInt64.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer { - typealias SwiftType = Bool? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterBool.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 FfiConverterBool.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { - typealias SwiftType = String? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterString.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 FfiConverterString.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer { - typealias SwiftType = Data? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterData.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 FfiConverterData.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeClosedChannelDetails: FfiConverterRustBuffer { - typealias SwiftType = ClosedChannelDetails? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeClosedChannelDetails.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 FfiConverterTypeClosedChannelDetails.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeCoinPurchaseMemo: FfiConverterRustBuffer { - typealias SwiftType = CoinPurchaseMemo? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeCoinPurchaseMemo.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 FfiConverterTypeCoinPurchaseMemo.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeCommonParams: FfiConverterRustBuffer { - typealias SwiftType = CommonParams? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeCommonParams.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 FfiConverterTypeCommonParams.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeComposeAccount: FfiConverterRustBuffer { - typealias SwiftType = ComposeAccount? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeComposeAccount.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 FfiConverterTypeComposeAccount.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeCreateCjitOptions: FfiConverterRustBuffer { - typealias SwiftType = CreateCjitOptions? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeCreateCjitOptions.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 FfiConverterTypeCreateCjitOptions.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeCreateOrderOptions: FfiConverterRustBuffer { - typealias SwiftType = CreateOrderOptions? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeCreateOrderOptions.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 FfiConverterTypeCreateOrderOptions.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeDeviceParams: FfiConverterRustBuffer { - typealias SwiftType = DeviceParams? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeDeviceParams.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 FfiConverterTypeDeviceParams.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeIBtBolt11Invoice: FfiConverterRustBuffer { - typealias SwiftType = IBtBolt11Invoice? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeIBtBolt11Invoice.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 FfiConverterTypeIBtBolt11Invoice.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeIBtChannel: FfiConverterRustBuffer { - typealias SwiftType = IBtChannel? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeIBtChannel.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 FfiConverterTypeIBtChannel.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag } } } + #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIBtChannelClose: FfiConverterRustBuffer { - typealias SwiftType = IBtChannelClose? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeIBtChannelClose.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 FfiConverterTypeIBtChannelClose.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } +public func FfiConverterTypeWordCount_lift(_ buf: RustBuffer) throws -> WordCount { + return try FfiConverterTypeWordCount.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIBtInfo: FfiConverterRustBuffer { - typealias SwiftType = IBtInfo? +public func FfiConverterTypeWordCount_lower(_ value: WordCount) -> RustBuffer { + return FfiConverterTypeWordCount.lower(value) +} + + +extension WordCount: Equatable, Hashable {} + +extension WordCount: Codable {} - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeIBtInfo.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 FfiConverterTypeIBtInfo.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionTypeIBtOnchainTransactions: FfiConverterRustBuffer { - typealias SwiftType = IBtOnchainTransactions? - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeIBtOnchainTransactions.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 FfiConverterTypeIBtOnchainTransactions.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIBtPayment: FfiConverterRustBuffer { - typealias SwiftType = IBtPayment? +fileprivate struct FfiConverterOptionUInt16: FfiConverterRustBuffer { + typealias SwiftType = UInt16? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15194,13 +13671,13 @@ fileprivate struct FfiConverterOptionTypeIBtPayment: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeIBtPayment.write(value, into: &buf) + FfiConverterUInt16.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 FfiConverterTypeIBtPayment.read(from: &buf) + case 1: return try FfiConverterUInt16.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15209,8 +13686,8 @@ fileprivate struct FfiConverterOptionTypeIBtPayment: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIDiscount: FfiConverterRustBuffer { - typealias SwiftType = IDiscount? +fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { + typealias SwiftType = UInt32? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15218,13 +13695,13 @@ fileprivate struct FfiConverterOptionTypeIDiscount: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeIDiscount.write(value, into: &buf) + FfiConverterUInt32.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 FfiConverterTypeIDiscount.read(from: &buf) + case 1: return try FfiConverterUInt32.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15233,8 +13710,8 @@ fileprivate struct FfiConverterOptionTypeIDiscount: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIGiftBolt11Invoice: FfiConverterRustBuffer { - typealias SwiftType = IGiftBolt11Invoice? +fileprivate struct FfiConverterOptionUInt64: FfiConverterRustBuffer { + typealias SwiftType = UInt64? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15242,13 +13719,13 @@ fileprivate struct FfiConverterOptionTypeIGiftBolt11Invoice: FfiConverterRustBuf return } writeInt(&buf, Int8(1)) - FfiConverterTypeIGiftBolt11Invoice.write(value, into: &buf) + FfiConverterUInt64.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 FfiConverterTypeIGiftBolt11Invoice.read(from: &buf) + case 1: return try FfiConverterUInt64.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15257,8 +13734,8 @@ fileprivate struct FfiConverterOptionTypeIGiftBolt11Invoice: FfiConverterRustBuf #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIGiftBtcAddress: FfiConverterRustBuffer { - typealias SwiftType = IGiftBtcAddress? +fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer { + typealias SwiftType = Bool? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15266,13 +13743,13 @@ fileprivate struct FfiConverterOptionTypeIGiftBtcAddress: FfiConverterRustBuffer return } writeInt(&buf, Int8(1)) - FfiConverterTypeIGiftBtcAddress.write(value, into: &buf) + FfiConverterBool.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 FfiConverterTypeIGiftBtcAddress.read(from: &buf) + case 1: return try FfiConverterBool.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15281,8 +13758,8 @@ fileprivate struct FfiConverterOptionTypeIGiftBtcAddress: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIGiftCode: FfiConverterRustBuffer { - typealias SwiftType = IGiftCode? +fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { + typealias SwiftType = String? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15290,13 +13767,13 @@ fileprivate struct FfiConverterOptionTypeIGiftCode: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeIGiftCode.write(value, into: &buf) + FfiConverterString.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 FfiConverterTypeIGiftCode.read(from: &buf) + case 1: return try FfiConverterString.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15305,8 +13782,8 @@ fileprivate struct FfiConverterOptionTypeIGiftCode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIGiftLspNode: FfiConverterRustBuffer { - typealias SwiftType = IGiftLspNode? +fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer { + typealias SwiftType = Data? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15314,13 +13791,13 @@ fileprivate struct FfiConverterOptionTypeIGiftLspNode: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeIGiftLspNode.write(value, into: &buf) + FfiConverterData.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 FfiConverterTypeIGiftLspNode.read(from: &buf) + case 1: return try FfiConverterData.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15329,8 +13806,8 @@ fileprivate struct FfiConverterOptionTypeIGiftLspNode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIGiftOrder: FfiConverterRustBuffer { - typealias SwiftType = IGiftOrder? +fileprivate struct FfiConverterOptionTypeClosedChannelDetails: FfiConverterRustBuffer { + typealias SwiftType = ClosedChannelDetails? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15338,13 +13815,13 @@ fileprivate struct FfiConverterOptionTypeIGiftOrder: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeIGiftOrder.write(value, into: &buf) + FfiConverterTypeClosedChannelDetails.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 FfiConverterTypeIGiftOrder.read(from: &buf) + case 1: return try FfiConverterTypeClosedChannelDetails.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15353,8 +13830,8 @@ fileprivate struct FfiConverterOptionTypeIGiftOrder: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeIGiftPayment: FfiConverterRustBuffer { - typealias SwiftType = IGiftPayment? +fileprivate struct FfiConverterOptionTypeCreateCjitOptions: FfiConverterRustBuffer { + typealias SwiftType = CreateCjitOptions? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15362,13 +13839,13 @@ fileprivate struct FfiConverterOptionTypeIGiftPayment: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeIGiftPayment.write(value, into: &buf) + FfiConverterTypeCreateCjitOptions.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 FfiConverterTypeIGiftPayment.read(from: &buf) + case 1: return try FfiConverterTypeCreateCjitOptions.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15377,8 +13854,8 @@ fileprivate struct FfiConverterOptionTypeIGiftPayment: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeILspNode: FfiConverterRustBuffer { - typealias SwiftType = ILspNode? +fileprivate struct FfiConverterOptionTypeCreateOrderOptions: FfiConverterRustBuffer { + typealias SwiftType = CreateOrderOptions? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15386,13 +13863,13 @@ fileprivate struct FfiConverterOptionTypeILspNode: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeILspNode.write(value, into: &buf) + FfiConverterTypeCreateOrderOptions.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 FfiConverterTypeILspNode.read(from: &buf) + case 1: return try FfiConverterTypeCreateOrderOptions.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15401,8 +13878,8 @@ fileprivate struct FfiConverterOptionTypeILspNode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeMultisigRedeemScriptType: FfiConverterRustBuffer { - typealias SwiftType = MultisigRedeemScriptType? +fileprivate struct FfiConverterOptionTypeIBtBolt11Invoice: FfiConverterRustBuffer { + typealias SwiftType = IBtBolt11Invoice? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15410,13 +13887,13 @@ fileprivate struct FfiConverterOptionTypeMultisigRedeemScriptType: FfiConverterR return } writeInt(&buf, Int8(1)) - FfiConverterTypeMultisigRedeemScriptType.write(value, into: &buf) + FfiConverterTypeIBtBolt11Invoice.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 FfiConverterTypeMultisigRedeemScriptType.read(from: &buf) + case 1: return try FfiConverterTypeIBtBolt11Invoice.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15425,8 +13902,8 @@ fileprivate struct FfiConverterOptionTypeMultisigRedeemScriptType: FfiConverterR #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeOnchainActivity: FfiConverterRustBuffer { - typealias SwiftType = OnchainActivity? +fileprivate struct FfiConverterOptionTypeIBtChannel: FfiConverterRustBuffer { + typealias SwiftType = IBtChannel? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15434,13 +13911,13 @@ fileprivate struct FfiConverterOptionTypeOnchainActivity: FfiConverterRustBuffer return } writeInt(&buf, Int8(1)) - FfiConverterTypeOnchainActivity.write(value, into: &buf) + FfiConverterTypeIBtChannel.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 FfiConverterTypeOnchainActivity.read(from: &buf) + case 1: return try FfiConverterTypeIBtChannel.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15449,8 +13926,8 @@ fileprivate struct FfiConverterOptionTypeOnchainActivity: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypePreActivityMetadata: FfiConverterRustBuffer { - typealias SwiftType = PreActivityMetadata? +fileprivate struct FfiConverterOptionTypeIBtChannelClose: FfiConverterRustBuffer { + typealias SwiftType = IBtChannelClose? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15458,13 +13935,13 @@ fileprivate struct FfiConverterOptionTypePreActivityMetadata: FfiConverterRustBu return } writeInt(&buf, Int8(1)) - FfiConverterTypePreActivityMetadata.write(value, into: &buf) + FfiConverterTypeIBtChannelClose.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 FfiConverterTypePreActivityMetadata.read(from: &buf) + case 1: return try FfiConverterTypeIBtChannelClose.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15473,8 +13950,8 @@ fileprivate struct FfiConverterOptionTypePreActivityMetadata: FfiConverterRustBu #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeRefundMemo: FfiConverterRustBuffer { - typealias SwiftType = RefundMemo? +fileprivate struct FfiConverterOptionTypeIBtInfo: FfiConverterRustBuffer { + typealias SwiftType = IBtInfo? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15482,13 +13959,13 @@ fileprivate struct FfiConverterOptionTypeRefundMemo: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeRefundMemo.write(value, into: &buf) + FfiConverterTypeIBtInfo.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 FfiConverterTypeRefundMemo.read(from: &buf) + case 1: return try FfiConverterTypeIBtInfo.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15497,8 +13974,8 @@ fileprivate struct FfiConverterOptionTypeRefundMemo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeTextMemo: FfiConverterRustBuffer { - typealias SwiftType = TextMemo? +fileprivate struct FfiConverterOptionTypeIBtOnchainTransactions: FfiConverterRustBuffer { + typealias SwiftType = IBtOnchainTransactions? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15506,13 +13983,13 @@ fileprivate struct FfiConverterOptionTypeTextMemo: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeTextMemo.write(value, into: &buf) + FfiConverterTypeIBtOnchainTransactions.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 FfiConverterTypeTextMemo.read(from: &buf) + case 1: return try FfiConverterTypeIBtOnchainTransactions.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15521,8 +13998,8 @@ fileprivate struct FfiConverterOptionTypeTextMemo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeTransactionDetails: FfiConverterRustBuffer { - typealias SwiftType = TransactionDetails? +fileprivate struct FfiConverterOptionTypeIBtPayment: FfiConverterRustBuffer { + typealias SwiftType = IBtPayment? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15530,13 +14007,13 @@ fileprivate struct FfiConverterOptionTypeTransactionDetails: FfiConverterRustBuf return } writeInt(&buf, Int8(1)) - FfiConverterTypeTransactionDetails.write(value, into: &buf) + FfiConverterTypeIBtPayment.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 FfiConverterTypeTransactionDetails.read(from: &buf) + case 1: return try FfiConverterTypeIBtPayment.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15545,8 +14022,8 @@ fileprivate struct FfiConverterOptionTypeTransactionDetails: FfiConverterRustBuf #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeUnlockPath: FfiConverterRustBuffer { - typealias SwiftType = UnlockPath? +fileprivate struct FfiConverterOptionTypeIDiscount: FfiConverterRustBuffer { + typealias SwiftType = IDiscount? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15554,13 +14031,13 @@ fileprivate struct FfiConverterOptionTypeUnlockPath: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeUnlockPath.write(value, into: &buf) + FfiConverterTypeIDiscount.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 FfiConverterTypeUnlockPath.read(from: &buf) + case 1: return try FfiConverterTypeIDiscount.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15569,8 +14046,8 @@ fileprivate struct FfiConverterOptionTypeUnlockPath: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeXrpMarker: FfiConverterRustBuffer { - typealias SwiftType = XrpMarker? +fileprivate struct FfiConverterOptionTypeIGiftBolt11Invoice: FfiConverterRustBuffer { + typealias SwiftType = IGiftBolt11Invoice? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15578,13 +14055,13 @@ fileprivate struct FfiConverterOptionTypeXrpMarker: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeXrpMarker.write(value, into: &buf) + FfiConverterTypeIGiftBolt11Invoice.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 FfiConverterTypeXrpMarker.read(from: &buf) + case 1: return try FfiConverterTypeIGiftBolt11Invoice.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15593,8 +14070,8 @@ fileprivate struct FfiConverterOptionTypeXrpMarker: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeAccountInfoDetails: FfiConverterRustBuffer { - typealias SwiftType = AccountInfoDetails? +fileprivate struct FfiConverterOptionTypeIGiftBtcAddress: FfiConverterRustBuffer { + typealias SwiftType = IGiftBtcAddress? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15602,13 +14079,13 @@ fileprivate struct FfiConverterOptionTypeAccountInfoDetails: FfiConverterRustBuf return } writeInt(&buf, Int8(1)) - FfiConverterTypeAccountInfoDetails.write(value, into: &buf) + FfiConverterTypeIGiftBtcAddress.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 FfiConverterTypeAccountInfoDetails.read(from: &buf) + case 1: return try FfiConverterTypeIGiftBtcAddress.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15617,8 +14094,8 @@ fileprivate struct FfiConverterOptionTypeAccountInfoDetails: FfiConverterRustBuf #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeActivity: FfiConverterRustBuffer { - typealias SwiftType = Activity? +fileprivate struct FfiConverterOptionTypeIGiftCode: FfiConverterRustBuffer { + typealias SwiftType = IGiftCode? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15626,13 +14103,13 @@ fileprivate struct FfiConverterOptionTypeActivity: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeActivity.write(value, into: &buf) + FfiConverterTypeIGiftCode.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 FfiConverterTypeActivity.read(from: &buf) + case 1: return try FfiConverterTypeIGiftCode.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15641,8 +14118,8 @@ fileprivate struct FfiConverterOptionTypeActivity: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeActivityFilter: FfiConverterRustBuffer { - typealias SwiftType = ActivityFilter? +fileprivate struct FfiConverterOptionTypeIGiftLspNode: FfiConverterRustBuffer { + typealias SwiftType = IGiftLspNode? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15650,13 +14127,13 @@ fileprivate struct FfiConverterOptionTypeActivityFilter: FfiConverterRustBuffer return } writeInt(&buf, Int8(1)) - FfiConverterTypeActivityFilter.write(value, into: &buf) + FfiConverterTypeIGiftLspNode.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 FfiConverterTypeActivityFilter.read(from: &buf) + case 1: return try FfiConverterTypeIGiftLspNode.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15665,8 +14142,8 @@ fileprivate struct FfiConverterOptionTypeActivityFilter: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeAmountUnit: FfiConverterRustBuffer { - typealias SwiftType = AmountUnit? +fileprivate struct FfiConverterOptionTypeIGiftOrder: FfiConverterRustBuffer { + typealias SwiftType = IGiftOrder? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15674,13 +14151,13 @@ fileprivate struct FfiConverterOptionTypeAmountUnit: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeAmountUnit.write(value, into: &buf) + FfiConverterTypeIGiftOrder.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 FfiConverterTypeAmountUnit.read(from: &buf) + case 1: return try FfiConverterTypeIGiftOrder.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15689,8 +14166,8 @@ fileprivate struct FfiConverterOptionTypeAmountUnit: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeBtOrderState2: FfiConverterRustBuffer { - typealias SwiftType = BtOrderState2? +fileprivate struct FfiConverterOptionTypeIGiftPayment: FfiConverterRustBuffer { + typealias SwiftType = IGiftPayment? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15698,13 +14175,13 @@ fileprivate struct FfiConverterOptionTypeBtOrderState2: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeBtOrderState2.write(value, into: &buf) + FfiConverterTypeIGiftPayment.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 FfiConverterTypeBtOrderState2.read(from: &buf) + case 1: return try FfiConverterTypeIGiftPayment.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15713,8 +14190,8 @@ fileprivate struct FfiConverterOptionTypeBtOrderState2: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeBtPaymentState2: FfiConverterRustBuffer { - typealias SwiftType = BtPaymentState2? +fileprivate struct FfiConverterOptionTypeILspNode: FfiConverterRustBuffer { + typealias SwiftType = ILspNode? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15722,13 +14199,13 @@ fileprivate struct FfiConverterOptionTypeBtPaymentState2: FfiConverterRustBuffer return } writeInt(&buf, Int8(1)) - FfiConverterTypeBtPaymentState2.write(value, into: &buf) + FfiConverterTypeILspNode.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 FfiConverterTypeBtPaymentState2.read(from: &buf) + case 1: return try FfiConverterTypeILspNode.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15737,8 +14214,8 @@ fileprivate struct FfiConverterOptionTypeBtPaymentState2: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeCJitStateEnum: FfiConverterRustBuffer { - typealias SwiftType = CJitStateEnum? +fileprivate struct FfiConverterOptionTypeOnchainActivity: FfiConverterRustBuffer { + typealias SwiftType = OnchainActivity? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15746,13 +14223,13 @@ fileprivate struct FfiConverterOptionTypeCJitStateEnum: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeCJitStateEnum.write(value, into: &buf) + FfiConverterTypeOnchainActivity.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 FfiConverterTypeCJitStateEnum.read(from: &buf) + case 1: return try FfiConverterTypeOnchainActivity.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15761,8 +14238,8 @@ fileprivate struct FfiConverterOptionTypeCJitStateEnum: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeDefaultAccountType: FfiConverterRustBuffer { - typealias SwiftType = DefaultAccountType? +fileprivate struct FfiConverterOptionTypePreActivityMetadata: FfiConverterRustBuffer { + typealias SwiftType = PreActivityMetadata? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15770,13 +14247,13 @@ fileprivate struct FfiConverterOptionTypeDefaultAccountType: FfiConverterRustBuf return } writeInt(&buf, Int8(1)) - FfiConverterTypeDefaultAccountType.write(value, into: &buf) + FfiConverterTypePreActivityMetadata.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 FfiConverterTypeDefaultAccountType.read(from: &buf) + case 1: return try FfiConverterTypePreActivityMetadata.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15785,8 +14262,8 @@ fileprivate struct FfiConverterOptionTypeDefaultAccountType: FfiConverterRustBuf #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeNetwork: FfiConverterRustBuffer { - typealias SwiftType = Network? +fileprivate struct FfiConverterOptionTypeTransactionDetails: FfiConverterRustBuffer { + typealias SwiftType = TransactionDetails? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15794,13 +14271,13 @@ fileprivate struct FfiConverterOptionTypeNetwork: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeNetwork.write(value, into: &buf) + FfiConverterTypeTransactionDetails.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 FfiConverterTypeNetwork.read(from: &buf) + case 1: return try FfiConverterTypeTransactionDetails.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15809,8 +14286,8 @@ fileprivate struct FfiConverterOptionTypeNetwork: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypePaymentType: FfiConverterRustBuffer { - typealias SwiftType = PaymentType? +fileprivate struct FfiConverterOptionTypeTrezorCallMessageResult: FfiConverterRustBuffer { + typealias SwiftType = TrezorCallMessageResult? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15818,13 +14295,13 @@ fileprivate struct FfiConverterOptionTypePaymentType: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypePaymentType.write(value, into: &buf) + FfiConverterTypeTrezorCallMessageResult.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 FfiConverterTypePaymentType.read(from: &buf) + case 1: return try FfiConverterTypeTrezorCallMessageResult.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15833,8 +14310,8 @@ fileprivate struct FfiConverterOptionTypePaymentType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeScriptType: FfiConverterRustBuffer { - typealias SwiftType = ScriptType? +fileprivate struct FfiConverterOptionTypeTrezorDeviceInfo: FfiConverterRustBuffer { + typealias SwiftType = TrezorDeviceInfo? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15842,13 +14319,13 @@ fileprivate struct FfiConverterOptionTypeScriptType: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeScriptType.write(value, into: &buf) + FfiConverterTypeTrezorDeviceInfo.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 FfiConverterTypeScriptType.read(from: &buf) + case 1: return try FfiConverterTypeTrezorDeviceInfo.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15857,8 +14334,8 @@ fileprivate struct FfiConverterOptionTypeScriptType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeSortDirection: FfiConverterRustBuffer { - typealias SwiftType = SortDirection? +fileprivate struct FfiConverterOptionTypeTrezorFeatures: FfiConverterRustBuffer { + typealias SwiftType = TrezorFeatures? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15866,13 +14343,13 @@ fileprivate struct FfiConverterOptionTypeSortDirection: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeSortDirection.write(value, into: &buf) + FfiConverterTypeTrezorFeatures.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 FfiConverterTypeSortDirection.read(from: &buf) + case 1: return try FfiConverterTypeTrezorFeatures.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15881,8 +14358,8 @@ fileprivate struct FfiConverterOptionTypeSortDirection: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeTokenFilter: FfiConverterRustBuffer { - typealias SwiftType = TokenFilter? +fileprivate struct FfiConverterOptionTypeActivity: FfiConverterRustBuffer { + typealias SwiftType = Activity? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15890,13 +14367,13 @@ fileprivate struct FfiConverterOptionTypeTokenFilter: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeTokenFilter.write(value, into: &buf) + FfiConverterTypeActivity.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 FfiConverterTypeTokenFilter.read(from: &buf) + case 1: return try FfiConverterTypeActivity.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15905,8 +14382,8 @@ fileprivate struct FfiConverterOptionTypeTokenFilter: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeTrezorEnvironment: FfiConverterRustBuffer { - typealias SwiftType = TrezorEnvironment? +fileprivate struct FfiConverterOptionTypeActivityFilter: FfiConverterRustBuffer { + typealias SwiftType = ActivityFilter? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15914,13 +14391,13 @@ fileprivate struct FfiConverterOptionTypeTrezorEnvironment: FfiConverterRustBuff return } writeInt(&buf, Int8(1)) - FfiConverterTypeTrezorEnvironment.write(value, into: &buf) + FfiConverterTypeActivityFilter.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 FfiConverterTypeTrezorEnvironment.read(from: &buf) + case 1: return try FfiConverterTypeActivityFilter.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15929,8 +14406,8 @@ fileprivate struct FfiConverterOptionTypeTrezorEnvironment: FfiConverterRustBuff #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeWordCount: FfiConverterRustBuffer { - typealias SwiftType = WordCount? +fileprivate struct FfiConverterOptionTypeBtOrderState2: FfiConverterRustBuffer { + typealias SwiftType = BtOrderState2? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15938,13 +14415,13 @@ fileprivate struct FfiConverterOptionTypeWordCount: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterTypeWordCount.write(value, into: &buf) + FfiConverterTypeBtOrderState2.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 FfiConverterTypeWordCount.read(from: &buf) + case 1: return try FfiConverterTypeBtOrderState2.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15953,8 +14430,8 @@ fileprivate struct FfiConverterOptionTypeWordCount: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceUInt32: FfiConverterRustBuffer { - typealias SwiftType = [UInt32]? +fileprivate struct FfiConverterOptionTypeBtPaymentState2: FfiConverterRustBuffer { + typealias SwiftType = BtPaymentState2? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15962,13 +14439,13 @@ fileprivate struct FfiConverterOptionSequenceUInt32: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterSequenceUInt32.write(value, into: &buf) + FfiConverterTypeBtPaymentState2.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 FfiConverterSequenceUInt32.read(from: &buf) + case 1: return try FfiConverterTypeBtPaymentState2.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -15977,8 +14454,8 @@ fileprivate struct FfiConverterOptionSequenceUInt32: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceString: FfiConverterRustBuffer { - typealias SwiftType = [String]? +fileprivate struct FfiConverterOptionTypeCJitStateEnum: FfiConverterRustBuffer { + typealias SwiftType = CJitStateEnum? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -15986,13 +14463,13 @@ fileprivate struct FfiConverterOptionSequenceString: FfiConverterRustBuffer { return } writeInt(&buf, Int8(1)) - FfiConverterSequenceString.write(value, into: &buf) + FfiConverterTypeCJitStateEnum.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 FfiConverterSequenceString.read(from: &buf) + case 1: return try FfiConverterTypeCJitStateEnum.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16001,8 +14478,8 @@ fileprivate struct FfiConverterOptionSequenceString: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypeFeeLevel: FfiConverterRustBuffer { - typealias SwiftType = [FeeLevel]? +fileprivate struct FfiConverterOptionTypeNetwork: FfiConverterRustBuffer { + typealias SwiftType = Network? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16010,13 +14487,13 @@ fileprivate struct FfiConverterOptionSequenceTypeFeeLevel: FfiConverterRustBuffe return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypeFeeLevel.write(value, into: &buf) + FfiConverterTypeNetwork.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 FfiConverterSequenceTypeFeeLevel.read(from: &buf) + case 1: return try FfiConverterTypeNetwork.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16025,8 +14502,8 @@ fileprivate struct FfiConverterOptionSequenceTypeFeeLevel: FfiConverterRustBuffe #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypeHDNodeType: FfiConverterRustBuffer { - typealias SwiftType = [HdNodeType]? +fileprivate struct FfiConverterOptionTypePaymentType: FfiConverterRustBuffer { + typealias SwiftType = PaymentType? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16034,13 +14511,13 @@ fileprivate struct FfiConverterOptionSequenceTypeHDNodeType: FfiConverterRustBuf return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypeHDNodeType.write(value, into: &buf) + FfiConverterTypePaymentType.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 FfiConverterSequenceTypeHDNodeType.read(from: &buf) + case 1: return try FfiConverterTypePaymentType.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16049,8 +14526,8 @@ fileprivate struct FfiConverterOptionSequenceTypeHDNodeType: FfiConverterRustBuf #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypeIManualRefund: FfiConverterRustBuffer { - typealias SwiftType = [IManualRefund]? +fileprivate struct FfiConverterOptionTypeSortDirection: FfiConverterRustBuffer { + typealias SwiftType = SortDirection? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16058,13 +14535,13 @@ fileprivate struct FfiConverterOptionSequenceTypeIManualRefund: FfiConverterRust return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypeIManualRefund.write(value, into: &buf) + FfiConverterTypeSortDirection.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 FfiConverterSequenceTypeIManualRefund.read(from: &buf) + case 1: return try FfiConverterTypeSortDirection.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16073,8 +14550,8 @@ fileprivate struct FfiConverterOptionSequenceTypeIManualRefund: FfiConverterRust #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypePaymentRequestMemo: FfiConverterRustBuffer { - typealias SwiftType = [PaymentRequestMemo]? +fileprivate struct FfiConverterOptionTypeTrezorCoinType: FfiConverterRustBuffer { + typealias SwiftType = TrezorCoinType? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16082,13 +14559,13 @@ fileprivate struct FfiConverterOptionSequenceTypePaymentRequestMemo: FfiConverte return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypePaymentRequestMemo.write(value, into: &buf) + FfiConverterTypeTrezorCoinType.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 FfiConverterSequenceTypePaymentRequestMemo.read(from: &buf) + case 1: return try FfiConverterTypeTrezorCoinType.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16097,8 +14574,8 @@ fileprivate struct FfiConverterOptionSequenceTypePaymentRequestMemo: FfiConverte #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypePrecomposedInput: FfiConverterRustBuffer { - typealias SwiftType = [PrecomposedInput]? +fileprivate struct FfiConverterOptionTypeTrezorScriptType: FfiConverterRustBuffer { + typealias SwiftType = TrezorScriptType? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16106,13 +14583,13 @@ fileprivate struct FfiConverterOptionSequenceTypePrecomposedInput: FfiConverterR return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypePrecomposedInput.write(value, into: &buf) + FfiConverterTypeTrezorScriptType.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 FfiConverterSequenceTypePrecomposedInput.read(from: &buf) + case 1: return try FfiConverterTypeTrezorScriptType.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16121,8 +14598,8 @@ fileprivate struct FfiConverterOptionSequenceTypePrecomposedInput: FfiConverterR #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypePrecomposedOutput: FfiConverterRustBuffer { - typealias SwiftType = [PrecomposedOutput]? +fileprivate struct FfiConverterOptionTypeWordCount: FfiConverterRustBuffer { + typealias SwiftType = WordCount? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16130,13 +14607,13 @@ fileprivate struct FfiConverterOptionSequenceTypePrecomposedOutput: FfiConverter return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypePrecomposedOutput.write(value, into: &buf) + FfiConverterTypeWordCount.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 FfiConverterSequenceTypePrecomposedOutput.read(from: &buf) + case 1: return try FfiConverterTypeWordCount.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16145,8 +14622,8 @@ fileprivate struct FfiConverterOptionSequenceTypePrecomposedOutput: FfiConverter #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypeRefTransaction: FfiConverterRustBuffer { - typealias SwiftType = [RefTransaction]? +fileprivate struct FfiConverterOptionSequenceString: FfiConverterRustBuffer { + typealias SwiftType = [String]? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16154,13 +14631,13 @@ fileprivate struct FfiConverterOptionSequenceTypeRefTransaction: FfiConverterRus return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypeRefTransaction.write(value, into: &buf) + FfiConverterSequenceString.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 FfiConverterSequenceTypeRefTransaction.read(from: &buf) + case 1: return try FfiConverterSequenceString.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16169,8 +14646,8 @@ fileprivate struct FfiConverterOptionSequenceTypeRefTransaction: FfiConverterRus #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionSequenceTypeTxAckPaymentRequest: FfiConverterRustBuffer { - typealias SwiftType = [TxAckPaymentRequest]? +fileprivate struct FfiConverterOptionSequenceTypeIManualRefund: FfiConverterRustBuffer { + typealias SwiftType = [IManualRefund]? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -16178,13 +14655,13 @@ fileprivate struct FfiConverterOptionSequenceTypeTxAckPaymentRequest: FfiConvert return } writeInt(&buf, Int8(1)) - FfiConverterSequenceTypeTxAckPaymentRequest.write(value, into: &buf) + FfiConverterSequenceTypeIManualRefund.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 FfiConverterSequenceTypeTxAckPaymentRequest.read(from: &buf) + case 1: return try FfiConverterSequenceTypeIManualRefund.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -16214,31 +14691,6 @@ fileprivate struct FfiConverterOptionDictionaryStringString: FfiConverterRustBuf } } -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceUInt32: FfiConverterRustBuffer { - typealias SwiftType = [UInt32] - - public static func write(_ value: [UInt32], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterUInt32.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [UInt32] { - let len: Int32 = try readInt(&buf) - var seq = [UInt32]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterUInt32.read(from: &buf)) - } - return seq - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -16264,31 +14716,6 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer { } } -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeAccountUtxo: FfiConverterRustBuffer { - typealias SwiftType = [AccountUtxo] - - public static func write(_ value: [AccountUtxo], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeAccountUtxo.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AccountUtxo] { - let len: Int32 = try readInt(&buf) - var seq = [AccountUtxo]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeAccountUtxo.read(from: &buf)) - } - return seq - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -16314,31 +14741,6 @@ fileprivate struct FfiConverterSequenceTypeActivityTags: FfiConverterRustBuffer } } -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeAddressInfo: FfiConverterRustBuffer { - typealias SwiftType = [AddressInfo] - - public static func write(_ value: [AddressInfo], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeAddressInfo.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AddressInfo] { - let len: Int32 = try readInt(&buf) - var seq = [AddressInfo]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeAddressInfo.read(from: &buf)) - } - return seq - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -16364,31 +14766,6 @@ fileprivate struct FfiConverterSequenceTypeClosedChannelDetails: FfiConverterRus } } -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeFeeLevel: FfiConverterRustBuffer { - typealias SwiftType = [FeeLevel] - - public static func write(_ value: [FeeLevel], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeFeeLevel.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FeeLevel] { - let len: Int32 = try readInt(&buf) - var seq = [FeeLevel]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeFeeLevel.read(from: &buf)) - } - return seq - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -16414,56 +14791,6 @@ fileprivate struct FfiConverterSequenceTypeGetAddressResponse: FfiConverterRustB } } -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeHDNodePathType: FfiConverterRustBuffer { - typealias SwiftType = [HdNodePathType] - - public static func write(_ value: [HdNodePathType], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeHDNodePathType.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [HdNodePathType] { - let len: Int32 = try readInt(&buf) - var seq = [HdNodePathType]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeHDNodePathType.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeHDNodeType: FfiConverterRustBuffer { - typealias SwiftType = [HdNodeType] - - public static func write(_ value: [HdNodeType], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeHDNodeType.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [HdNodeType] { - let len: Int32 = try readInt(&buf) - var seq = [HdNodeType]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeHDNodeType.read(from: &buf)) - } - return seq - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -16595,120 +14922,20 @@ fileprivate struct FfiConverterSequenceTypeIManualRefund: FfiConverterRustBuffer fileprivate struct FfiConverterSequenceTypeLightningActivity: FfiConverterRustBuffer { typealias SwiftType = [LightningActivity] - public static func write(_ value: [LightningActivity], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeLightningActivity.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LightningActivity] { - let len: Int32 = try readInt(&buf) - var seq = [LightningActivity]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeLightningActivity.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypeOnchainActivity: FfiConverterRustBuffer { - typealias SwiftType = [OnchainActivity] - - public static func write(_ value: [OnchainActivity], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypeOnchainActivity.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [OnchainActivity] { - let len: Int32 = try readInt(&buf) - var seq = [OnchainActivity]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypeOnchainActivity.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypePaymentRequestMemo: FfiConverterRustBuffer { - typealias SwiftType = [PaymentRequestMemo] - - public static func write(_ value: [PaymentRequestMemo], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypePaymentRequestMemo.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PaymentRequestMemo] { - let len: Int32 = try readInt(&buf) - var seq = [PaymentRequestMemo]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypePaymentRequestMemo.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypePreActivityMetadata: FfiConverterRustBuffer { - typealias SwiftType = [PreActivityMetadata] - - public static func write(_ value: [PreActivityMetadata], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypePreActivityMetadata.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PreActivityMetadata] { - let len: Int32 = try readInt(&buf) - var seq = [PreActivityMetadata]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypePreActivityMetadata.read(from: &buf)) - } - return seq - } -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypePrecomposedInput: FfiConverterRustBuffer { - typealias SwiftType = [PrecomposedInput] - - public static func write(_ value: [PrecomposedInput], into buf: inout [UInt8]) { + public static func write(_ value: [LightningActivity], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypePrecomposedInput.write(item, into: &buf) + FfiConverterTypeLightningActivity.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PrecomposedInput] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LightningActivity] { let len: Int32 = try readInt(&buf) - var seq = [PrecomposedInput]() + var seq = [LightningActivity]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypePrecomposedInput.read(from: &buf)) + seq.append(try FfiConverterTypeLightningActivity.read(from: &buf)) } return seq } @@ -16717,23 +14944,23 @@ fileprivate struct FfiConverterSequenceTypePrecomposedInput: FfiConverterRustBuf #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypePrecomposedOutput: FfiConverterRustBuffer { - typealias SwiftType = [PrecomposedOutput] +fileprivate struct FfiConverterSequenceTypeNativeDeviceInfo: FfiConverterRustBuffer { + typealias SwiftType = [NativeDeviceInfo] - public static func write(_ value: [PrecomposedOutput], into buf: inout [UInt8]) { + public static func write(_ value: [NativeDeviceInfo], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypePrecomposedOutput.write(item, into: &buf) + FfiConverterTypeNativeDeviceInfo.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PrecomposedOutput] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [NativeDeviceInfo] { let len: Int32 = try readInt(&buf) - var seq = [PrecomposedOutput]() + var seq = [NativeDeviceInfo]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypePrecomposedOutput.read(from: &buf)) + seq.append(try FfiConverterTypeNativeDeviceInfo.read(from: &buf)) } return seq } @@ -16742,23 +14969,23 @@ fileprivate struct FfiConverterSequenceTypePrecomposedOutput: FfiConverterRustBu #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypePrecomposedTransaction: FfiConverterRustBuffer { - typealias SwiftType = [PrecomposedTransaction] +fileprivate struct FfiConverterSequenceTypeOnchainActivity: FfiConverterRustBuffer { + typealias SwiftType = [OnchainActivity] - public static func write(_ value: [PrecomposedTransaction], into buf: inout [UInt8]) { + public static func write(_ value: [OnchainActivity], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypePrecomposedTransaction.write(item, into: &buf) + FfiConverterTypeOnchainActivity.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PrecomposedTransaction] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [OnchainActivity] { let len: Int32 = try readInt(&buf) - var seq = [PrecomposedTransaction]() + var seq = [OnchainActivity]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypePrecomposedTransaction.read(from: &buf)) + seq.append(try FfiConverterTypeOnchainActivity.read(from: &buf)) } return seq } @@ -16767,23 +14994,23 @@ fileprivate struct FfiConverterSequenceTypePrecomposedTransaction: FfiConverterR #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeRefTransaction: FfiConverterRustBuffer { - typealias SwiftType = [RefTransaction] +fileprivate struct FfiConverterSequenceTypePreActivityMetadata: FfiConverterRustBuffer { + typealias SwiftType = [PreActivityMetadata] - public static func write(_ value: [RefTransaction], into buf: inout [UInt8]) { + public static func write(_ value: [PreActivityMetadata], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeRefTransaction.write(item, into: &buf) + FfiConverterTypePreActivityMetadata.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RefTransaction] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PreActivityMetadata] { let len: Int32 = try readInt(&buf) - var seq = [RefTransaction]() + var seq = [PreActivityMetadata]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeRefTransaction.read(from: &buf)) + seq.append(try FfiConverterTypePreActivityMetadata.read(from: &buf)) } return seq } @@ -16792,23 +15019,23 @@ fileprivate struct FfiConverterSequenceTypeRefTransaction: FfiConverterRustBuffe #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeRefTxInput: FfiConverterRustBuffer { - typealias SwiftType = [RefTxInput] +fileprivate struct FfiConverterSequenceTypeTransactionDetails: FfiConverterRustBuffer { + typealias SwiftType = [TransactionDetails] - public static func write(_ value: [RefTxInput], into buf: inout [UInt8]) { + public static func write(_ value: [TransactionDetails], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeRefTxInput.write(item, into: &buf) + FfiConverterTypeTransactionDetails.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RefTxInput] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TransactionDetails] { let len: Int32 = try readInt(&buf) - var seq = [RefTxInput]() + var seq = [TransactionDetails]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeRefTxInput.read(from: &buf)) + seq.append(try FfiConverterTypeTransactionDetails.read(from: &buf)) } return seq } @@ -16817,23 +15044,23 @@ fileprivate struct FfiConverterSequenceTypeRefTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeRefTxOutput: FfiConverterRustBuffer { - typealias SwiftType = [RefTxOutput] +fileprivate struct FfiConverterSequenceTypeTrezorDeviceInfo: FfiConverterRustBuffer { + typealias SwiftType = [TrezorDeviceInfo] - public static func write(_ value: [RefTxOutput], into buf: inout [UInt8]) { + public static func write(_ value: [TrezorDeviceInfo], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeRefTxOutput.write(item, into: &buf) + FfiConverterTypeTrezorDeviceInfo.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RefTxOutput] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TrezorDeviceInfo] { let len: Int32 = try readInt(&buf) - var seq = [RefTxOutput]() + var seq = [TrezorDeviceInfo]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeRefTxOutput.read(from: &buf)) + seq.append(try FfiConverterTypeTrezorDeviceInfo.read(from: &buf)) } return seq } @@ -16842,23 +15069,23 @@ fileprivate struct FfiConverterSequenceTypeRefTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeTransactionDetails: FfiConverterRustBuffer { - typealias SwiftType = [TransactionDetails] +fileprivate struct FfiConverterSequenceTypeTrezorPrevTx: FfiConverterRustBuffer { + typealias SwiftType = [TrezorPrevTx] - public static func write(_ value: [TransactionDetails], into buf: inout [UInt8]) { + public static func write(_ value: [TrezorPrevTx], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeTransactionDetails.write(item, into: &buf) + FfiConverterTypeTrezorPrevTx.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TransactionDetails] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TrezorPrevTx] { let len: Int32 = try readInt(&buf) - var seq = [TransactionDetails]() + var seq = [TrezorPrevTx]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeTransactionDetails.read(from: &buf)) + seq.append(try FfiConverterTypeTrezorPrevTx.read(from: &buf)) } return seq } @@ -16867,23 +15094,23 @@ fileprivate struct FfiConverterSequenceTypeTransactionDetails: FfiConverterRustB #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeTxAckPaymentRequest: FfiConverterRustBuffer { - typealias SwiftType = [TxAckPaymentRequest] +fileprivate struct FfiConverterSequenceTypeTrezorPrevTxInput: FfiConverterRustBuffer { + typealias SwiftType = [TrezorPrevTxInput] - public static func write(_ value: [TxAckPaymentRequest], into buf: inout [UInt8]) { + public static func write(_ value: [TrezorPrevTxInput], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeTxAckPaymentRequest.write(item, into: &buf) + FfiConverterTypeTrezorPrevTxInput.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TxAckPaymentRequest] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TrezorPrevTxInput] { let len: Int32 = try readInt(&buf) - var seq = [TxAckPaymentRequest]() + var seq = [TrezorPrevTxInput]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeTxAckPaymentRequest.read(from: &buf)) + seq.append(try FfiConverterTypeTrezorPrevTxInput.read(from: &buf)) } return seq } @@ -16892,23 +15119,23 @@ fileprivate struct FfiConverterSequenceTypeTxAckPaymentRequest: FfiConverterRust #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeTxInput: FfiConverterRustBuffer { - typealias SwiftType = [TxInput] +fileprivate struct FfiConverterSequenceTypeTrezorPrevTxOutput: FfiConverterRustBuffer { + typealias SwiftType = [TrezorPrevTxOutput] - public static func write(_ value: [TxInput], into buf: inout [UInt8]) { + public static func write(_ value: [TrezorPrevTxOutput], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeTxInput.write(item, into: &buf) + FfiConverterTypeTrezorPrevTxOutput.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TxInput] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TrezorPrevTxOutput] { let len: Int32 = try readInt(&buf) - var seq = [TxInput]() + var seq = [TrezorPrevTxOutput]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeTxInput.read(from: &buf)) + seq.append(try FfiConverterTypeTrezorPrevTxOutput.read(from: &buf)) } return seq } @@ -16917,23 +15144,23 @@ fileprivate struct FfiConverterSequenceTypeTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeTxInputType: FfiConverterRustBuffer { - typealias SwiftType = [TxInputType] +fileprivate struct FfiConverterSequenceTypeTrezorTxInput: FfiConverterRustBuffer { + typealias SwiftType = [TrezorTxInput] - public static func write(_ value: [TxInputType], into buf: inout [UInt8]) { + public static func write(_ value: [TrezorTxInput], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeTxInputType.write(item, into: &buf) + FfiConverterTypeTrezorTxInput.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TxInputType] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TrezorTxInput] { let len: Int32 = try readInt(&buf) - var seq = [TxInputType]() + var seq = [TrezorTxInput]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeTxInputType.read(from: &buf)) + seq.append(try FfiConverterTypeTrezorTxInput.read(from: &buf)) } return seq } @@ -16942,23 +15169,23 @@ fileprivate struct FfiConverterSequenceTypeTxInputType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeTxOutput: FfiConverterRustBuffer { - typealias SwiftType = [TxOutput] +fileprivate struct FfiConverterSequenceTypeTrezorTxOutput: FfiConverterRustBuffer { + typealias SwiftType = [TrezorTxOutput] - public static func write(_ value: [TxOutput], into buf: inout [UInt8]) { + public static func write(_ value: [TrezorTxOutput], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeTxOutput.write(item, into: &buf) + FfiConverterTypeTrezorTxOutput.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TxOutput] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TrezorTxOutput] { let len: Int32 = try readInt(&buf) - var seq = [TxOutput]() + var seq = [TrezorTxOutput]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeTxOutput.read(from: &buf)) + seq.append(try FfiConverterTypeTrezorTxOutput.read(from: &buf)) } return seq } @@ -16967,23 +15194,23 @@ fileprivate struct FfiConverterSequenceTypeTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeTxOutputType: FfiConverterRustBuffer { - typealias SwiftType = [TxOutputType] +fileprivate struct FfiConverterSequenceTypeTxInput: FfiConverterRustBuffer { + typealias SwiftType = [TxInput] - public static func write(_ value: [TxOutputType], into buf: inout [UInt8]) { + public static func write(_ value: [TxInput], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeTxOutputType.write(item, into: &buf) + FfiConverterTypeTxInput.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TxOutputType] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [TxInput] { let len: Int32 = try readInt(&buf) - var seq = [TxOutputType]() + var seq = [TxInput]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeTxOutputType.read(from: &buf)) + seq.append(try FfiConverterTypeTxInput.read(from: &buf)) } return seq } @@ -16992,23 +15219,23 @@ fileprivate struct FfiConverterSequenceTypeTxOutputType: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeActivity: FfiConverterRustBuffer { - typealias SwiftType = [Activity] +fileprivate struct FfiConverterSequenceTypeTxOutput: FfiConverterRustBuffer { + typealias SwiftType = [TxOutput] - public static func write(_ value: [Activity], into buf: inout [UInt8]) { + public static func write(_ value: [TxOutput], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeActivity.write(item, into: &buf) + FfiConverterTypeTxOutput.write(item, into: &buf) } } - 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 -> [TxOutput] { let len: Int32 = try readInt(&buf) - var seq = [Activity]() + var seq = [TxOutput]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeActivity.read(from: &buf)) + seq.append(try FfiConverterTypeTxOutput.read(from: &buf)) } return seq } @@ -17017,23 +15244,23 @@ fileprivate struct FfiConverterSequenceTypeActivity: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeComposeOutput: FfiConverterRustBuffer { - typealias SwiftType = [ComposeOutput] +fileprivate struct FfiConverterSequenceTypeActivity: FfiConverterRustBuffer { + typealias SwiftType = [Activity] - public static func write(_ value: [ComposeOutput], into buf: inout [UInt8]) { + public static func write(_ value: [Activity], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeComposeOutput.write(item, into: &buf) + FfiConverterTypeActivity.write(item, into: &buf) } } - 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 -> [Activity] { let len: Int32 = try readInt(&buf) - var seq = [ComposeOutput]() + var seq = [Activity]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeComposeOutput.read(from: &buf)) + seq.append(try FfiConverterTypeActivity.read(from: &buf)) } return seq } @@ -17666,336 +15893,559 @@ public func mnemonicToEntropy(mnemonicPhrase: String)throws -> Data { uniffi_bitkitcore_fn_func_mnemonic_to_entropy( FfiConverterString.lower(mnemonicPhrase),$0 ) -}) +}) +} +public func mnemonicToSeed(mnemonicPhrase: String, passphrase: String?)throws -> Data { + return try FfiConverterData.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { + uniffi_bitkitcore_fn_func_mnemonic_to_seed( + FfiConverterString.lower(mnemonicPhrase), + FfiConverterOptionString.lower(passphrase),$0 + ) +}) +} +public func openChannel(orderId: String, connectionString: String)async throws -> IBtOrder { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_open_channel(FfiConverterString.lower(orderId),FfiConverterString.lower(connectionString) + ) + }, + 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 prepareSweepTransaction(mnemonicPhrase: String, network: Network?, bip39Passphrase: String?, electrumUrl: String, destinationAddress: String, feeRateSatsPerVbyte: UInt32?)async throws -> SweepTransactionPreview { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_prepare_sweep_transaction(FfiConverterString.lower(mnemonicPhrase),FfiConverterOptionTypeNetwork.lower(network),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterString.lower(electrumUrl),FfiConverterString.lower(destinationAddress),FfiConverterOptionUInt32.lower(feeRateSatsPerVbyte) + ) + }, + 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: FfiConverterTypeSweepTransactionPreview_lift, + errorHandler: FfiConverterTypeSweepError_lift + ) +} +/** + * Refresh all active CJIT entries in the database with latest data from the LSP + */ +public func refreshActiveCjitEntries()async throws -> [IcJitEntry] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_refresh_active_cjit_entries( + ) + }, + 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 + ) +} +/** + * Refresh all active orders in the database with latest data from the LSP + */ +public func refreshActiveOrders()async throws -> [IBtOrder] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_refresh_active_orders( + ) + }, + 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 + ) +} +public func registerDevice(deviceToken: String, publicKey: String, features: [String], nodeId: String, isoTimestamp: String, signature: String, isProduction: Bool?, customUrl: String?)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_register_device(FfiConverterString.lower(deviceToken),FfiConverterString.lower(publicKey),FfiConverterSequenceString.lower(features),FfiConverterString.lower(nodeId),FfiConverterString.lower(isoTimestamp),FfiConverterString.lower(signature),FfiConverterOptionBool.lower(isProduction),FfiConverterOptionString.lower(customUrl) + ) + }, + 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: FfiConverterTypeBlocktankError_lift + ) +} +public func regtestCloseChannel(fundingTxId: String, vout: UInt32, forceCloseAfterS: UInt64?)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_regtest_close_channel(FfiConverterString.lower(fundingTxId),FfiConverterUInt32.lower(vout),FfiConverterOptionUInt64.lower(forceCloseAfterS) + ) + }, + 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: FfiConverterTypeBlocktankError_lift + ) +} +public func regtestDeposit(address: String, amountSat: UInt64?)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_regtest_deposit(FfiConverterString.lower(address),FfiConverterOptionUInt64.lower(amountSat) + ) + }, + 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: FfiConverterTypeBlocktankError_lift + ) +} +public func regtestGetPayment(paymentId: String)async throws -> IBtBolt11Invoice { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_regtest_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: FfiConverterTypeIBtBolt11Invoice_lift, + errorHandler: FfiConverterTypeBlocktankError_lift + ) +} +public func regtestMine(count: UInt32?)async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_regtest_mine(FfiConverterOptionUInt32.lower(count) + ) + }, + 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 regtestPay(invoice: String, amountSat: UInt64?)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_regtest_pay(FfiConverterString.lower(invoice),FfiConverterOptionUInt64.lower(amountSat) + ) + }, + 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: FfiConverterTypeBlocktankError_lift + ) +} +public func removeClosedChannelById(channelId: String)throws -> Bool { + return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_remove_closed_channel_by_id( + FfiConverterString.lower(channelId),$0 + ) +}) +} +public func removePreActivityMetadataTags(paymentId: String, tags: [String])throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_remove_pre_activity_metadata_tags( + FfiConverterString.lower(paymentId), + FfiConverterSequenceString.lower(tags),$0 + ) +} +} +public func removeTags(activityId: String, tags: [String])throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_remove_tags( + FfiConverterString.lower(activityId), + FfiConverterSequenceString.lower(tags),$0 + ) +} +} +public func resetPreActivityMetadataTags(paymentId: String)throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags( + FfiConverterString.lower(paymentId),$0 + ) } -public func mnemonicToSeed(mnemonicPhrase: String, passphrase: String?)throws -> Data { - return try FfiConverterData.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { - uniffi_bitkitcore_fn_func_mnemonic_to_seed( - FfiConverterString.lower(mnemonicPhrase), - FfiConverterOptionString.lower(passphrase),$0 - ) -}) } -public func openChannel(orderId: String, connectionString: String)async throws -> IBtOrder { +public func testNotification(deviceToken: String, secretMessage: String, notificationType: String?, customUrl: String?)async throws -> String { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_open_channel(FfiConverterString.lower(orderId),FfiConverterString.lower(connectionString) + uniffi_bitkitcore_fn_func_test_notification(FfiConverterString.lower(deviceToken),FfiConverterString.lower(secretMessage),FfiConverterOptionString.lower(notificationType),FfiConverterOptionString.lower(customUrl) ) }, 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: FfiConverterString.lift, errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func prepareSweepTransaction(mnemonicPhrase: String, network: Network?, bip39Passphrase: String?, electrumUrl: String, destinationAddress: String, feeRateSatsPerVbyte: UInt32?)async throws -> SweepTransactionPreview { +/** + * Clear stored Bluetooth pairing credentials for a specific Trezor device. + * + * This removes any stored credentials, requiring re-pairing on the next connection. + * Useful when a device has been reset or credentials have become stale. + */ +public func trezorClearCredentials(deviceId: String)async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_prepare_sweep_transaction(FfiConverterString.lower(mnemonicPhrase),FfiConverterOptionTypeNetwork.lower(network),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterString.lower(electrumUrl),FfiConverterString.lower(destinationAddress),FfiConverterOptionUInt32.lower(feeRateSatsPerVbyte) + uniffi_bitkitcore_fn_func_trezor_clear_credentials(FfiConverterString.lower(deviceId) ) }, - 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: FfiConverterTypeSweepTransactionPreview_lift, - errorHandler: FfiConverterTypeSweepError_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: FfiConverterTypeTrezorError_lift ) } /** - * Refresh all active CJIT entries in the database with latest data from the LSP + * Connect to a Trezor device by its ID. + * + * For Bluetooth devices, this will use stored credentials if available, + * or trigger pairing if needed. */ -public func refreshActiveCjitEntries()async throws -> [IcJitEntry] { +public func trezorConnect(deviceId: String)async throws -> TrezorFeatures { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_refresh_active_cjit_entries( + uniffi_bitkitcore_fn_func_trezor_connect(FfiConverterString.lower(deviceId) ) }, 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: FfiConverterTypeTrezorFeatures_lift, + errorHandler: FfiConverterTypeTrezorError_lift ) } /** - * Refresh all active orders in the database with latest data from the LSP + * Disconnect from the currently connected Trezor device. */ -public func refreshActiveOrders()async throws -> [IBtOrder] { +public func trezorDisconnect()async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_refresh_active_orders( + uniffi_bitkitcore_fn_func_trezor_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: FfiConverterTypeTrezorError_lift + ) +} +/** + * Get a Bitcoin address from the connected Trezor device. + */ +public func trezorGetAddress(params: TrezorGetAddressParams)async throws -> TrezorAddressResponse { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_trezor_get_address(FfiConverterTypeTrezorGetAddressParams_lower(params) ) }, 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: FfiConverterTypeTrezorAddressResponse_lift, + errorHandler: FfiConverterTypeTrezorError_lift ) } -public func registerDevice(deviceToken: String, publicKey: String, features: [String], nodeId: String, isoTimestamp: String, signature: String, isProduction: Bool?, customUrl: String?)async throws -> String { +/** + * Get information about the currently connected Trezor device. + */ +public func trezorGetConnectedDevice()async -> TrezorDeviceInfo? { return - try await uniffiRustCallAsync( + try! await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_register_device(FfiConverterString.lower(deviceToken),FfiConverterString.lower(publicKey),FfiConverterSequenceString.lower(features),FfiConverterString.lower(nodeId),FfiConverterString.lower(isoTimestamp),FfiConverterString.lower(signature),FfiConverterOptionBool.lower(isProduction),FfiConverterOptionString.lower(customUrl) + uniffi_bitkitcore_fn_func_trezor_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: FfiConverterString.lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterOptionTypeTrezorDeviceInfo.lift, + errorHandler: nil + ) } -public func regtestCloseChannel(fundingTxId: String, vout: UInt32, forceCloseAfterS: UInt64?)async throws -> String { +/** + * Get the device's master root fingerprint as an 8-character hex string. + * + * Returns the root fingerprint in the standard descriptor format (e.g., "73c5da0a"). + * Requires a connected device. + */ +public func trezorGetDeviceFingerprint()async throws -> String { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_regtest_close_channel(FfiConverterString.lower(fundingTxId),FfiConverterUInt32.lower(vout),FfiConverterOptionUInt64.lower(forceCloseAfterS) + uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint( ) }, 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: FfiConverterTypeBlocktankError_lift + errorHandler: FfiConverterTypeTrezorError_lift ) } -public func regtestDeposit(address: String, amountSat: UInt64?)async throws -> String { +/** + * Get the cached features of the currently connected Trezor device. + * + * Returns the features that were obtained during `trezor_connect()`, without + * triggering any device interaction. Returns None if no device is connected. + */ +public func trezorGetFeatures()async -> TrezorFeatures? { return - try await uniffiRustCallAsync( + try! await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_regtest_deposit(FfiConverterString.lower(address),FfiConverterOptionUInt64.lower(amountSat) + uniffi_bitkitcore_fn_func_trezor_get_features( ) }, 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: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterOptionTypeTrezorFeatures.lift, + errorHandler: nil + ) } -public func regtestGetPayment(paymentId: String)async throws -> IBtBolt11Invoice { +/** + * Get a public key (xpub) from the connected Trezor device. + */ +public func trezorGetPublicKey(params: TrezorGetPublicKeyParams)async throws -> TrezorPublicKeyResponse { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_regtest_get_payment(FfiConverterString.lower(paymentId) + uniffi_bitkitcore_fn_func_trezor_get_public_key(FfiConverterTypeTrezorGetPublicKeyParams_lower(params) ) }, 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: FfiConverterTypeTrezorPublicKeyResponse_lift, + errorHandler: FfiConverterTypeTrezorError_lift ) } -public func regtestMine(count: UInt32?)async throws { +/** + * Initialize the Trezor manager with optional credential storage. + * + * The credential_path is used to persist Bluetooth pairing credentials, + * allowing reconnection without re-pairing. + * + * NOTE: On Android, you must call the native initBle() function first! + */ +public func trezorInitialize(credentialPath: String?)async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_regtest_mine(FfiConverterOptionUInt32.lower(count) + uniffi_bitkitcore_fn_func_trezor_initialize(FfiConverterOptionString.lower(credentialPath) ) }, 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: FfiConverterTypeTrezorError_lift ) } -public func regtestPay(invoice: String, amountSat: UInt64?)async throws -> String { +/** + * Check if BLE has been initialized. + * + * On Android: Returns true if BluetoothInit.nativeInit() was called successfully. + * On other platforms: Always returns true (BLE works natively). + */ +public func trezorIsBleAvailable() -> Bool { + return try! FfiConverterBool.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_trezor_is_ble_available($0 + ) +}) +} +/** + * Check if a Trezor device is currently connected. + */ +public func trezorIsConnected()async -> Bool { + return + try! await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_trezor_is_connected( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_i8, + completeFunc: ffi_bitkitcore_rust_future_complete_i8, + freeFunc: ffi_bitkitcore_rust_future_free_i8, + liftFunc: FfiConverterBool.lift, + errorHandler: nil + + ) +} +/** + * Check if the Trezor manager is initialized. + */ +public func trezorIsInitialized()async -> Bool { + return + try! await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_trezor_is_initialized( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_i8, + completeFunc: ffi_bitkitcore_rust_future_complete_i8, + freeFunc: ffi_bitkitcore_rust_future_free_i8, + liftFunc: FfiConverterBool.lift, + errorHandler: nil + + ) +} +/** + * List previously discovered devices without triggering a new scan. + */ +public func trezorListDevices()async throws -> [TrezorDeviceInfo] { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_regtest_pay(FfiConverterString.lower(invoice),FfiConverterOptionUInt64.lower(amountSat) + uniffi_bitkitcore_fn_func_trezor_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: FfiConverterString.lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterSequenceTypeTrezorDeviceInfo.lift, + errorHandler: FfiConverterTypeTrezorError_lift ) } -public func removeClosedChannelById(channelId: String)throws -> Bool { - return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_remove_closed_channel_by_id( - FfiConverterString.lower(channelId),$0 - ) -}) -} -public func removePreActivityMetadataTags(paymentId: String, tags: [String])throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_remove_pre_activity_metadata_tags( - FfiConverterString.lower(paymentId), - FfiConverterSequenceString.lower(tags),$0 - ) -} -} -public func removeTags(activityId: String, tags: [String])throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_remove_tags( - FfiConverterString.lower(activityId), - FfiConverterSequenceString.lower(tags),$0 - ) -} -} -public func resetPreActivityMetadataTags(paymentId: String)throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags( - FfiConverterString.lower(paymentId),$0 - ) -} -} -public func testNotification(deviceToken: String, secretMessage: String, notificationType: String?, customUrl: String?)async throws -> String { +/** + * Scan for available Trezor devices (USB + Bluetooth). + * + * This performs an active Bluetooth scan and enumerates USB devices. + * Returns a list of discovered devices. + */ +public func trezorScan()async throws -> [TrezorDeviceInfo] { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_test_notification(FfiConverterString.lower(deviceToken),FfiConverterString.lower(secretMessage),FfiConverterOptionString.lower(notificationType),FfiConverterOptionString.lower(customUrl) + uniffi_bitkitcore_fn_func_trezor_scan( ) }, 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: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterSequenceTypeTrezorDeviceInfo.lift, + errorHandler: FfiConverterTypeTrezorError_lift ) } -public func trezorComposeTransaction(outputs: [ComposeOutput], coin: String, callbackUrl: String, requestId: String?, trezorEnvironment: TrezorEnvironment?, push: Bool?, sequence: UInt32?, account: ComposeAccount?, feeLevels: [FeeLevel]?, skipPermutation: Bool?, common: CommonParams?)throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_compose_transaction( - FfiConverterSequenceTypeComposeOutput.lower(outputs), - FfiConverterString.lower(coin), - FfiConverterString.lower(callbackUrl), - FfiConverterOptionString.lower(requestId), - FfiConverterOptionTypeTrezorEnvironment.lower(trezorEnvironment), - FfiConverterOptionBool.lower(push), - FfiConverterOptionUInt32.lower(sequence), - FfiConverterOptionTypeComposeAccount.lower(account), - FfiConverterOptionSequenceTypeFeeLevel.lower(feeLevels), - FfiConverterOptionBool.lower(skipPermutation), - FfiConverterOptionTypeCommonParams.lower(common),$0 +/** + * Initialize the Trezor transport with a native callback implementation + * + * This must be called before any Trezor scanning/connection operations. + * The native layer (iOS/Android) must implement the TrezorTransportCallback interface. + */ +public func trezorSetTransportCallback(callback: TrezorTransportCallback) {try! rustCall() { + uniffi_bitkitcore_fn_func_trezor_set_transport_callback( + FfiConverterTypeTrezorTransportCallback_lower(callback),$0 ) -}) } -public func trezorGetAccountInfo(coin: String, callbackUrl: String, requestId: String?, trezorEnvironment: TrezorEnvironment?, path: String?, descriptor: String?, details: AccountInfoDetails?, tokens: TokenFilter?, page: UInt32?, pageSize: UInt32?, from: UInt32?, to: UInt32?, gap: UInt32?, contractFilter: String?, marker: XrpMarker?, defaultAccountType: DefaultAccountType?, suppressBackupWarning: Bool?, common: CommonParams?)throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_get_account_info( - FfiConverterString.lower(coin), - FfiConverterString.lower(callbackUrl), - FfiConverterOptionString.lower(requestId), - FfiConverterOptionTypeTrezorEnvironment.lower(trezorEnvironment), - FfiConverterOptionString.lower(path), - FfiConverterOptionString.lower(descriptor), - FfiConverterOptionTypeAccountInfoDetails.lower(details), - FfiConverterOptionTypeTokenFilter.lower(tokens), - FfiConverterOptionUInt32.lower(page), - FfiConverterOptionUInt32.lower(pageSize), - FfiConverterOptionUInt32.lower(from), - FfiConverterOptionUInt32.lower(to), - FfiConverterOptionUInt32.lower(gap), - FfiConverterOptionString.lower(contractFilter), - FfiConverterOptionTypeXrpMarker.lower(marker), - FfiConverterOptionTypeDefaultAccountType.lower(defaultAccountType), - FfiConverterOptionBool.lower(suppressBackupWarning), - FfiConverterOptionTypeCommonParams.lower(common),$0 - ) -}) } -public func trezorGetAddress(path: String, callbackUrl: String, requestId: String?, trezorEnvironment: TrezorEnvironment?, address: String?, showOnTrezor: Bool?, chunkify: Bool?, useEventListener: Bool?, coin: String?, crossChain: Bool?, multisig: MultisigRedeemScriptType?, scriptType: String?, unlockPath: UnlockPath?, common: CommonParams?)throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_get_address( - FfiConverterString.lower(path), - FfiConverterString.lower(callbackUrl), - FfiConverterOptionString.lower(requestId), - FfiConverterOptionTypeTrezorEnvironment.lower(trezorEnvironment), - FfiConverterOptionString.lower(address), - FfiConverterOptionBool.lower(showOnTrezor), - FfiConverterOptionBool.lower(chunkify), - FfiConverterOptionBool.lower(useEventListener), - FfiConverterOptionString.lower(coin), - FfiConverterOptionBool.lower(crossChain), - FfiConverterOptionTypeMultisigRedeemScriptType.lower(multisig), - FfiConverterOptionString.lower(scriptType), - FfiConverterOptionTypeUnlockPath.lower(unlockPath), - FfiConverterOptionTypeCommonParams.lower(common),$0 +/** + * Set the UI callback for handling PIN and passphrase requests. + * + * This should be called before connecting to a Trezor device if you want + * the library to handle PIN/passphrase requests via your UI instead of + * returning errors. + */ +public func trezorSetUiCallback(callback: TrezorUiCallback) {try! rustCall() { + uniffi_bitkitcore_fn_func_trezor_set_ui_callback( + FfiConverterTypeTrezorUiCallback_lower(callback),$0 ) -}) } -public func trezorGetFeatures(callbackUrl: String, requestId: String?, trezorEnvironment: TrezorEnvironment?)throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_get_features( - FfiConverterString.lower(callbackUrl), - FfiConverterOptionString.lower(requestId), - FfiConverterOptionTypeTrezorEnvironment.lower(trezorEnvironment),$0 - ) -}) } -public func trezorHandleDeepLink(callbackUrl: String)throws -> TrezorResponsePayload { - return try FfiConverterTypeTrezorResponsePayload_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_handle_deep_link( - FfiConverterString.lower(callbackUrl),$0 - ) -}) +/** + * Sign a message with the connected Trezor device. + */ +public func trezorSignMessage(params: TrezorSignMessageParams)async throws -> TrezorSignedMessageResponse { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_trezor_sign_message(FfiConverterTypeTrezorSignMessageParams_lower(params) + ) + }, + 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: FfiConverterTypeTrezorSignedMessageResponse_lift, + errorHandler: FfiConverterTypeTrezorError_lift + ) } -public func trezorSignMessage(path: String, message: String, callbackUrl: String, requestId: String?, trezorEnvironment: TrezorEnvironment?, coin: String?, hex: Bool?, noScriptType: Bool?, common: CommonParams?)throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_sign_message( - FfiConverterString.lower(path), - FfiConverterString.lower(message), - FfiConverterString.lower(callbackUrl), - FfiConverterOptionString.lower(requestId), - FfiConverterOptionTypeTrezorEnvironment.lower(trezorEnvironment), - FfiConverterOptionString.lower(coin), - FfiConverterOptionBool.lower(hex), - FfiConverterOptionBool.lower(noScriptType), - FfiConverterOptionTypeCommonParams.lower(common),$0 - ) -}) +/** + * Sign a Bitcoin transaction with the connected Trezor device. + */ +public func trezorSignTx(params: TrezorSignTxParams)async throws -> TrezorSignedTx { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_trezor_sign_tx(FfiConverterTypeTrezorSignTxParams_lower(params) + ) + }, + 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: FfiConverterTypeTrezorSignedTx_lift, + errorHandler: FfiConverterTypeTrezorError_lift + ) } -public func trezorSignTransaction(coin: String, inputs: [TxInputType], outputs: [TxOutputType], callbackUrl: String, requestId: String?, trezorEnvironment: TrezorEnvironment?, refTxs: [RefTransaction]?, paymentRequests: [TxAckPaymentRequest]?, locktime: UInt32?, version: UInt32?, expiry: UInt32?, versionGroupId: UInt32?, overwintered: Bool?, timestamp: UInt32?, branchId: UInt32?, push: Bool?, amountUnit: AmountUnit?, unlockPath: UnlockPath?, serialize: Bool?, chunkify: Bool?, common: CommonParams?)throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_sign_transaction( - FfiConverterString.lower(coin), - FfiConverterSequenceTypeTxInputType.lower(inputs), - FfiConverterSequenceTypeTxOutputType.lower(outputs), - FfiConverterString.lower(callbackUrl), - FfiConverterOptionString.lower(requestId), - FfiConverterOptionTypeTrezorEnvironment.lower(trezorEnvironment), - FfiConverterOptionSequenceTypeRefTransaction.lower(refTxs), - FfiConverterOptionSequenceTypeTxAckPaymentRequest.lower(paymentRequests), - FfiConverterOptionUInt32.lower(locktime), - FfiConverterOptionUInt32.lower(version), - FfiConverterOptionUInt32.lower(expiry), - FfiConverterOptionUInt32.lower(versionGroupId), - FfiConverterOptionBool.lower(overwintered), - FfiConverterOptionUInt32.lower(timestamp), - FfiConverterOptionUInt32.lower(branchId), - FfiConverterOptionBool.lower(push), - FfiConverterOptionTypeAmountUnit.lower(amountUnit), - FfiConverterOptionTypeUnlockPath.lower(unlockPath), - FfiConverterOptionBool.lower(serialize), - FfiConverterOptionBool.lower(chunkify), - FfiConverterOptionTypeCommonParams.lower(common),$0 - ) -}) +/** + * Sign a Bitcoin transaction from a PSBT (base64-encoded). + * + * Parses the PSBT, extracts inputs/outputs/prev_txs, signs via the connected + * Trezor device, and returns the signed transaction. + * + * # Arguments + * * `psbt_base64` - Base64-encoded PSBT data + * * `network` - Bitcoin network type. Defaults to Bitcoin (mainnet) if None. + */ +public func trezorSignTxFromPsbt(psbtBase64: String, network: TrezorCoinType?)async throws -> TrezorSignedTx { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt(FfiConverterString.lower(psbtBase64),FfiConverterOptionTypeTrezorCoinType.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: FfiConverterTypeTrezorSignedTx_lift, + errorHandler: FfiConverterTypeTrezorError_lift + ) } -public func trezorVerifyMessage(address: String, signature: String, message: String, coin: String, callbackUrl: String, requestId: String?, trezorEnvironment: TrezorEnvironment?, hex: Bool?, common: CommonParams?)throws -> DeepLinkResult { - return try FfiConverterTypeDeepLinkResult_lift(try rustCallWithError(FfiConverterTypeTrezorConnectError_lift) { - uniffi_bitkitcore_fn_func_trezor_verify_message( - FfiConverterString.lower(address), - FfiConverterString.lower(signature), - FfiConverterString.lower(message), - FfiConverterString.lower(coin), - FfiConverterString.lower(callbackUrl), - FfiConverterOptionString.lower(requestId), - FfiConverterOptionTypeTrezorEnvironment.lower(trezorEnvironment), - FfiConverterOptionBool.lower(hex), - FfiConverterOptionTypeCommonParams.lower(common),$0 - ) -}) +/** + * Verify a message signature with the connected Trezor device. + */ +public func trezorVerifyMessage(params: TrezorVerifyMessageParams)async throws -> Bool { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_trezor_verify_message(FfiConverterTypeTrezorVerifyMessageParams_lower(params) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_i8, + completeFunc: ffi_bitkitcore_rust_future_complete_i8, + freeFunc: ffi_bitkitcore_rust_future_free_i8, + liftFunc: FfiConverterBool.lift, + errorHandler: FfiConverterTypeTrezorError_lift + ) } public func updateActivity(activityId: String, activity: Activity)throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { uniffi_bitkitcore_fn_func_update_activity( @@ -18386,28 +16836,64 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_test_notification() != 32857) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_compose_transaction() != 25990) { + if (uniffi_bitkitcore_checksum_func_trezor_clear_credentials() != 41940) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_connect() != 6551) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_disconnect() != 48780) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_get_address() != 12910) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_get_connected_device() != 48383) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint() != 20344) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_get_features() != 13970) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_get_public_key() != 13743) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_initialize() != 16053) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_is_ble_available() != 12897) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_get_account_info() != 14813) { + if (uniffi_bitkitcore_checksum_func_trezor_is_connected() != 42092) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_get_address() != 42202) { + if (uniffi_bitkitcore_checksum_func_trezor_is_initialized() != 59329) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_get_features() != 52582) { + if (uniffi_bitkitcore_checksum_func_trezor_list_devices() != 32859) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_handle_deep_link() != 32721) { + if (uniffi_bitkitcore_checksum_func_trezor_scan() != 54763) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_sign_message() != 18023) { + if (uniffi_bitkitcore_checksum_func_trezor_set_transport_callback() != 30209) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_sign_transaction() != 59932) { + if (uniffi_bitkitcore_checksum_func_trezor_set_ui_callback() != 52321) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_trezor_verify_message() != 44040) { + if (uniffi_bitkitcore_checksum_func_trezor_sign_message() != 2925) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_sign_tx() != 42467) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt() != 18852) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_trezor_verify_message() != 50739) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitkitcore_checksum_func_update_activity() != 42510) { @@ -18467,7 +16953,48 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_wipe_all_transaction_details() != 65339) { return InitializationResult.apiChecksumMismatch } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices() != 18766) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device() != 44156) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device() != 47933) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk() != 7645) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk() != 55967) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size() != 4994) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message() != 19414) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code() != 43475) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential() != 16694) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential() != 48790) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug() != 44848) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request() != 50474) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request() != 63487) { + return InitializationResult.apiChecksumMismatch + } + uniffiCallbackInitTrezorTransportCallback() + uniffiCallbackInitTrezorUiCallback() return InitializationResult.ok }() diff --git a/bindings/ios/bitkitcoreFFI.h b/bindings/ios/bitkitcoreFFI.h index d4a9c1e..ad95039 100644 --- a/bindings/ios/bitkitcoreFFI.h +++ b/bindings/ios/bitkitcoreFFI.h @@ -250,6 +250,219 @@ typedef struct UniffiForeignFutureStructVoid { typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureStructVoid ); +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod0)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod1)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod2)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod3)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod4)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod5)(uint64_t, RustBuffer, uint32_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod6)(uint64_t, RustBuffer, uint16_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod7)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod8)(uint64_t, RustBuffer, RustBuffer, int8_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod9)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 +typedef void (*UniffiCallbackInterfaceTrezorTransportCallbackMethod10)(uint64_t, RustBuffer, RustBuffer, void* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceTrezorUiCallbackMethod0)(uint64_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceTrezorUiCallbackMethod1)(uint64_t, int8_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTrezorTransportCallback { + UniffiCallbackInterfaceTrezorTransportCallbackMethod0 _Nonnull enumerateDevices; + UniffiCallbackInterfaceTrezorTransportCallbackMethod1 _Nonnull openDevice; + UniffiCallbackInterfaceTrezorTransportCallbackMethod2 _Nonnull closeDevice; + UniffiCallbackInterfaceTrezorTransportCallbackMethod3 _Nonnull readChunk; + UniffiCallbackInterfaceTrezorTransportCallbackMethod4 _Nonnull writeChunk; + UniffiCallbackInterfaceTrezorTransportCallbackMethod5 _Nonnull getChunkSize; + UniffiCallbackInterfaceTrezorTransportCallbackMethod6 _Nonnull callMessage; + UniffiCallbackInterfaceTrezorTransportCallbackMethod7 _Nonnull getPairingCode; + UniffiCallbackInterfaceTrezorTransportCallbackMethod8 _Nonnull saveThpCredential; + UniffiCallbackInterfaceTrezorTransportCallbackMethod9 _Nonnull loadThpCredential; + UniffiCallbackInterfaceTrezorTransportCallbackMethod10 _Nonnull logDebug; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceTrezorTransportCallback; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK +typedef struct UniffiVTableCallbackInterfaceTrezorUiCallback { + UniffiCallbackInterfaceTrezorUiCallbackMethod0 _Nonnull onPinRequest; + UniffiCallbackInterfaceTrezorUiCallbackMethod1 _Nonnull onPassphraseRequest; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceTrezorUiCallback; + +#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 +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORTRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORTRANSPORTCALLBACK +void uniffi_bitkitcore_fn_free_trezortransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORTRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORTRANSPORTCALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(const UniffiVTableCallbackInterfaceTrezorTransportCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_open_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_close_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk(void*_Nonnull ptr, RustBuffer path, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +uint32_t uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_call_message(void*_Nonnull ptr, RustBuffer path, uint16_t message_type, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +int8_t uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential(void*_Nonnull ptr, RustBuffer device_id, RustBuffer credential_json, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +RustBuffer uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential(void*_Nonnull ptr, RustBuffer device_id, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +void uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug(void*_Nonnull ptr, RustBuffer tag, RustBuffer message, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORUICALLBACK +void*_Nonnull uniffi_bitkitcore_fn_clone_trezoruicallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_TREZORUICALLBACK +void uniffi_bitkitcore_fn_free_trezoruicallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORUICALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_TREZORUICALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(const UniffiVTableCallbackInterfaceTrezorUiCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +RustBuffer uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +RustBuffer uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request(void*_Nonnull ptr, int8_t on_device, RustCallStatus *_Nonnull out_status +); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ACTIVITY_WIPE_ALL #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ACTIVITY_WIPE_ALL @@ -627,44 +840,113 @@ void uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags(RustBuffer payme uint64_t uniffi_bitkitcore_fn_func_test_notification(RustBuffer device_token, RustBuffer secret_message, RustBuffer notification_type, RustBuffer custom_url ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_COMPOSE_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_COMPOSE_TRANSACTION -RustBuffer uniffi_bitkitcore_fn_func_trezor_compose_transaction(RustBuffer outputs, RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer push, RustBuffer sequence, RustBuffer account, RustBuffer fee_levels, RustBuffer skip_permutation, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CLEAR_CREDENTIALS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CLEAR_CREDENTIALS +uint64_t uniffi_bitkitcore_fn_func_trezor_clear_credentials(RustBuffer device_id ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ACCOUNT_INFO -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ACCOUNT_INFO -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_account_info(RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer path, RustBuffer descriptor, RustBuffer details, RustBuffer tokens, RustBuffer page, RustBuffer pageSize, RustBuffer from, RustBuffer to, RustBuffer gap, RustBuffer contractFilter, RustBuffer marker, RustBuffer defaultAccountType, RustBuffer suppressBackupWarning, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_CONNECT +uint64_t uniffi_bitkitcore_fn_func_trezor_connect(RustBuffer device_id +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_DISCONNECT +uint64_t uniffi_bitkitcore_fn_func_trezor_disconnect(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ADDRESS #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_ADDRESS -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_address(RustBuffer path, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer address, RustBuffer showOnTrezor, RustBuffer chunkify, RustBuffer useEventListener, RustBuffer coin, RustBuffer crossChain, RustBuffer multisig, RustBuffer scriptType, RustBuffer unlockPath, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_get_address(RustBuffer params +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_CONNECTED_DEVICE +uint64_t uniffi_bitkitcore_fn_func_trezor_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +uint64_t uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_FEATURES #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_FEATURES -RustBuffer uniffi_bitkitcore_fn_func_trezor_get_features(RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_get_features(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_GET_PUBLIC_KEY +uint64_t uniffi_bitkitcore_fn_func_trezor_get_public_key(RustBuffer params ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_HANDLE_DEEP_LINK -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_HANDLE_DEEP_LINK -RustBuffer uniffi_bitkitcore_fn_func_trezor_handle_deep_link(RustBuffer callback_url, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_INITIALIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_INITIALIZE +uint64_t uniffi_bitkitcore_fn_func_trezor_initialize(RustBuffer credential_path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_BLE_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_BLE_AVAILABLE +int8_t uniffi_bitkitcore_fn_func_trezor_is_ble_available(RustCallStatus *_Nonnull out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_CONNECTED +uint64_t uniffi_bitkitcore_fn_func_trezor_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_INITIALIZED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_IS_INITIALIZED +uint64_t uniffi_bitkitcore_fn_func_trezor_is_initialized(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_LIST_DEVICES +uint64_t uniffi_bitkitcore_fn_func_trezor_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SCAN +uint64_t uniffi_bitkitcore_fn_func_trezor_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +void uniffi_bitkitcore_fn_func_trezor_set_transport_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_UI_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SET_UI_CALLBACK +void uniffi_bitkitcore_fn_func_trezor_set_ui_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_MESSAGE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_MESSAGE -RustBuffer uniffi_bitkitcore_fn_func_trezor_sign_message(RustBuffer path, RustBuffer message, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer coin, RustBuffer hex, RustBuffer no_script_type, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_message(RustBuffer params +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_tx(RustBuffer params ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TRANSACTION -RustBuffer uniffi_bitkitcore_fn_func_trezor_sign_transaction(RustBuffer coin, RustBuffer inputs, RustBuffer outputs, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer ref_txs, RustBuffer payment_requests, RustBuffer locktime, RustBuffer version, RustBuffer expiry, RustBuffer version_group_id, RustBuffer overwintered, RustBuffer timestamp, RustBuffer branch_id, RustBuffer push, RustBuffer amount_unit, RustBuffer unlock_path, RustBuffer serialize, RustBuffer chunkify, RustBuffer common, RustCallStatus *_Nonnull out_status +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX_FROM_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_SIGN_TX_FROM_PSBT +uint64_t uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt(RustBuffer psbt_base64, RustBuffer network ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_VERIFY_MESSAGE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TREZOR_VERIFY_MESSAGE -RustBuffer uniffi_bitkitcore_fn_func_trezor_verify_message(RustBuffer address, RustBuffer signature, RustBuffer message, RustBuffer coin, RustBuffer callback_url, RustBuffer request_id, RustBuffer trezor_environment, RustBuffer hex, RustBuffer common, RustCallStatus *_Nonnull out_status +uint64_t uniffi_bitkitcore_fn_func_trezor_verify_message(RustBuffer params ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_UPDATE_ACTIVITY @@ -1483,15 +1765,21 @@ uint16_t uniffi_bitkitcore_checksum_func_test_notification(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_COMPOSE_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_COMPOSE_TRANSACTION -uint16_t uniffi_bitkitcore_checksum_func_trezor_compose_transaction(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CLEAR_CREDENTIALS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CLEAR_CREDENTIALS +uint16_t uniffi_bitkitcore_checksum_func_trezor_clear_credentials(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_CONNECT +uint16_t uniffi_bitkitcore_checksum_func_trezor_connect(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ACCOUNT_INFO -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ACCOUNT_INFO -uint16_t uniffi_bitkitcore_checksum_func_trezor_get_account_info(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_DISCONNECT +uint16_t uniffi_bitkitcore_checksum_func_trezor_disconnect(void ); #endif @@ -1499,6 +1787,18 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_get_account_info(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_ADDRESS uint16_t uniffi_bitkitcore_checksum_func_trezor_get_address(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_CONNECTED_DEVICE +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_DEVICE_FINGERPRINT +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_FEATURES @@ -1507,9 +1807,57 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_get_features(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_HANDLE_DEEP_LINK -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_HANDLE_DEEP_LINK -uint16_t uniffi_bitkitcore_checksum_func_trezor_handle_deep_link(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_GET_PUBLIC_KEY +uint16_t uniffi_bitkitcore_checksum_func_trezor_get_public_key(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_INITIALIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_INITIALIZE +uint16_t uniffi_bitkitcore_checksum_func_trezor_initialize(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_BLE_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_BLE_AVAILABLE +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_ble_available(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_CONNECTED +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_INITIALIZED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_IS_INITIALIZED +uint16_t uniffi_bitkitcore_checksum_func_trezor_is_initialized(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_LIST_DEVICES +uint16_t uniffi_bitkitcore_checksum_func_trezor_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SCAN +uint16_t uniffi_bitkitcore_checksum_func_trezor_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_TRANSPORT_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_trezor_set_transport_callback(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_UI_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SET_UI_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_trezor_set_ui_callback(void ); #endif @@ -1519,9 +1867,15 @@ uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_message(void ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TRANSACTION -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TRANSACTION -uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_transaction(void +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX +uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_tx(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX_FROM_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TREZOR_SIGN_TX_FROM_PSBT +uint16_t uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt(void ); #endif @@ -1643,6 +1997,84 @@ uint16_t uniffi_bitkitcore_checksum_func_wipe_all_databases(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_WIPE_ALL_TRANSACTION_DETAILS uint16_t uniffi_bitkitcore_checksum_func_wipe_all_transaction_details(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_OPEN_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CLOSE_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_READ_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_WRITE_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_CHUNK_SIZE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_CALL_MESSAGE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_GET_PAIRING_CODE +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_SAVE_THP_CREDENTIAL +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOAD_THP_CREDENTIAL +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_LOG_DEBUG +uint16_t uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PIN_REQUEST +uint16_t uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORUICALLBACK_ON_PASSPHRASE_REQUEST +uint16_t uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request(void + ); #endif #ifndef UNIFFI_FFIDEF_FFI_BITKITCORE_UNIFFI_CONTRACT_VERSION diff --git a/bindings/python/bitkitcore/bitkitcore.py b/bindings/python/bitkitcore/bitkitcore.py index 1b55dde..efa94ff 100644 --- a/bindings/python/bitkitcore/bitkitcore.py +++ b/bindings/python/bitkitcore/bitkitcore.py @@ -607,21 +607,45 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_func_test_notification() != 32857: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_compose_transaction() != 25990: + if lib.uniffi_bitkitcore_checksum_func_trezor_clear_credentials() != 41940: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_get_account_info() != 14813: + if lib.uniffi_bitkitcore_checksum_func_trezor_connect() != 6551: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_get_address() != 42202: + if lib.uniffi_bitkitcore_checksum_func_trezor_disconnect() != 48780: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_get_features() != 52582: + if lib.uniffi_bitkitcore_checksum_func_trezor_get_address() != 12910: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_handle_deep_link() != 32721: + if lib.uniffi_bitkitcore_checksum_func_trezor_get_connected_device() != 48383: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_sign_message() != 18023: + if lib.uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint() != 20344: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_sign_transaction() != 59932: + if lib.uniffi_bitkitcore_checksum_func_trezor_get_features() != 13970: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_bitkitcore_checksum_func_trezor_verify_message() != 44040: + if lib.uniffi_bitkitcore_checksum_func_trezor_get_public_key() != 13743: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_initialize() != 16053: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_is_ble_available() != 12897: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_is_connected() != 42092: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_is_initialized() != 59329: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_list_devices() != 32859: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_scan() != 54763: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_set_transport_callback() != 30209: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_set_ui_callback() != 52321: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_sign_message() != 2925: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_sign_tx() != 42467: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt() != 18852: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_trezor_verify_message() != 50739: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_func_update_activity() != 42510: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -661,6 +685,32 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_func_wipe_all_transaction_details() != 65339: 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: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device() != 47933: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk() != 7645: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk() != 55967: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size() != 4994: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message() != 19414: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code() != 43475: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential() != 16694: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential() != 48790: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug() != 44848: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request() != 50474: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request() != 63487: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") # A ctypes library to expose the extern-C FFI definitions. # This is an implementation detail which will be called internally by the public API. @@ -767,6 +817,174 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ] _UNIFFI_FOREIGN_FUTURE_COMPLETE_VOID = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructVoid, ) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_uint32), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_uint16,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_int8), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,_UniffiRustBuffer,ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_int8,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +class _UniffiVTableCallbackInterfaceTrezorTransportCallback(ctypes.Structure): + _fields_ = [ + ("enumerate_devices", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0), + ("open_device", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1), + ("close_device", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2), + ("read_chunk", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3), + ("write_chunk", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4), + ("get_chunk_size", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5), + ("call_message", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6), + ("get_pairing_code", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7), + ("save_thp_credential", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD8), + ("load_thp_credential", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9), + ("log_debug", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), + ] +class _UniffiVTableCallbackInterfaceTrezorUiCallback(ctypes.Structure): + _fields_ = [ + ("on_pin_request", _UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0), + ("on_passphrase_request", _UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), + ] +_UniffiLib.uniffi_bitkitcore_fn_clone_trezortransportcallback.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_clone_trezortransportcallback.restype = ctypes.c_void_p +_UniffiLib.uniffi_bitkitcore_fn_free_trezortransportcallback.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_free_trezortransportcallback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceTrezorTransportCallback), +) +_UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_open_device.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_open_device.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_close_device.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_close_device.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size.restype = ctypes.c_uint32 +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_call_message.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_uint16, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_call_message.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential.restype = ctypes.c_int8 +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug.restype = None +_UniffiLib.uniffi_bitkitcore_fn_clone_trezoruicallback.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_clone_trezoruicallback.restype = ctypes.c_void_p +_UniffiLib.uniffi_bitkitcore_fn_free_trezoruicallback.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_free_trezoruicallback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceTrezorUiCallback), +) +_UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request.argtypes = ( + ctypes.c_void_p, + ctypes.c_int8, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request.restype = _UniffiRustBuffer _UniffiLib.uniffi_bitkitcore_fn_func_activity_wipe_all.argtypes = ( ctypes.POINTER(_UniffiRustCallStatus), ) @@ -1174,124 +1392,81 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiRustBuffer, ) _UniffiLib.uniffi_bitkitcore_fn_func_test_notification.restype = ctypes.c_uint64 -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_compose_transaction.argtypes = ( - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_clear_credentials.argtypes = ( _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_compose_transaction.restype = _UniffiRustBuffer -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_account_info.argtypes = ( - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_clear_credentials.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_connect.argtypes = ( _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_account_info.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_connect.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_disconnect.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_disconnect.restype = ctypes.c_uint64 _UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_address.argtypes = ( _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_address.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_address.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_connected_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_connected_device.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint.restype = ctypes.c_uint64 _UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_features.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_features.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_public_key.argtypes = ( _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_public_key.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_initialize.argtypes = ( _UniffiRustBuffer, - _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_initialize.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_ble_available.argtypes = ( ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_features.restype = _UniffiRustBuffer -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_handle_deep_link.argtypes = ( - _UniffiRustBuffer, +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_ble_available.restype = ctypes.c_int8 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_connected.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_connected.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_initialized.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_initialized.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_list_devices.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_list_devices.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_scan.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_scan.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_transport_callback.argtypes = ( + ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_handle_deep_link.restype = _UniffiRustBuffer -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message.argtypes = ( - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_transport_callback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_ui_callback.argtypes = ( + ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message.restype = _UniffiRustBuffer -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_transaction.argtypes = ( - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_ui_callback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message.argtypes = ( _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx.argtypes = ( _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt.argtypes = ( _UniffiRustBuffer, _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_transaction.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt.restype = ctypes.c_uint64 _UniffiLib.uniffi_bitkitcore_fn_func_trezor_verify_message.argtypes = ( _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_bitkitcore_fn_func_trezor_verify_message.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_func_trezor_verify_message.restype = ctypes.c_uint64 _UniffiLib.uniffi_bitkitcore_fn_func_update_activity.argtypes = ( _UniffiRustBuffer, _UniffiRustBuffer, @@ -1867,27 +2042,63 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_bitkitcore_checksum_func_test_notification.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_test_notification.restype = ctypes.c_uint16 -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_compose_transaction.argtypes = ( +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_clear_credentials.argtypes = ( ) -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_compose_transaction.restype = ctypes.c_uint16 -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_account_info.argtypes = ( +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_clear_credentials.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_connect.argtypes = ( ) -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_account_info.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_connect.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_disconnect.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_disconnect.restype = ctypes.c_uint16 _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_address.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_address.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_connected_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_connected_device.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_device_fingerprint.restype = ctypes.c_uint16 _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_features.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_features.restype = ctypes.c_uint16 -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_handle_deep_link.argtypes = ( +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_public_key.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_get_public_key.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_initialize.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_initialize.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_is_ble_available.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_is_ble_available.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_is_connected.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_is_connected.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_is_initialized.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_is_initialized.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_list_devices.argtypes = ( ) -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_handle_deep_link.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_list_devices.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_scan.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_scan.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_set_transport_callback.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_set_transport_callback.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_set_ui_callback.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_set_ui_callback.restype = ctypes.c_uint16 _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_message.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_message.restype = ctypes.c_uint16 -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_transaction.argtypes = ( +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_tx.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_tx.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt.argtypes = ( ) -_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_transaction.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_trezor_sign_tx_from_psbt.restype = ctypes.c_uint16 _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_verify_message.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_trezor_verify_message.restype = ctypes.c_uint16 @@ -1948,6 +2159,45 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_bitkitcore_checksum_func_wipe_all_transaction_details.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_wipe_all_transaction_details.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 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_close_device.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_read_chunk.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_write_chunk.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_get_chunk_size.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_call_message.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_get_pairing_code.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_save_thp_credential.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_load_thp_credential.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_log_debug.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezoruicallback_on_pin_request.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_trezoruicallback_on_passphrase_request.restype = ctypes.c_uint16 _UniffiLib.ffi_bitkitcore_uniffi_contract_version.argtypes = ( ) _UniffiLib.ffi_bitkitcore_uniffi_contract_version.restype = ctypes.c_uint32 @@ -1956,20 +2206,51 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): # _uniffi_check_api_checksums(_UniffiLib) # Public interface members begin here. +# Magic number for the Rust proxy to call using the same mechanism as every other method, +# to free the callback once it's dropped by Rust. +_UNIFFI_IDX_CALLBACK_FREE = 0 +# Return codes for callback calls +_UNIFFI_CALLBACK_SUCCESS = 0 +_UNIFFI_CALLBACK_ERROR = 1 +_UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2 + +class _UniffiCallbackInterfaceFfiConverter: + _handle_map = _UniffiHandleMap() + + @classmethod + def lift(cls, handle): + return cls._handle_map.get(handle) + + @classmethod + def read(cls, buf): + handle = buf.read_u64() + cls.lift(handle) + + @classmethod + def check_lower(cls, cb): + pass + + @classmethod + def lower(cls, cb): + handle = cls._handle_map.insert(cb) + return handle + @classmethod + def write(cls, cb, buf): + buf.write_u64(cls.lower(cb)) -class _UniffiConverterUInt8(_UniffiConverterPrimitiveInt): - CLASS_NAME = "u8" +class _UniffiConverterUInt16(_UniffiConverterPrimitiveInt): + CLASS_NAME = "u16" VALUE_MIN = 0 - VALUE_MAX = 2**8 + VALUE_MAX = 2**16 @staticmethod def read(buf): - return buf.read_u8() + return buf.read_u16() @staticmethod def write(value, buf): - buf.write_u8(value) + buf.write_u16(value) class _UniffiConverterUInt32(_UniffiConverterPrimitiveInt): CLASS_NAME = "u32" @@ -2093,250 +2374,24 @@ def write(value, buf): buf.write(value) -class AccountAddresses: - """ - Account addresses - """ - used: "typing.List[AddressInfo]" - """ - Used addresses - """ - unused: "typing.List[AddressInfo]" - """ - Unused addresses - """ - change: "typing.List[AddressInfo]" - """ - Change addresses - """ - def __init__(self, *, used: "typing.List[AddressInfo]", unused: "typing.List[AddressInfo]", change: "typing.List[AddressInfo]"): - self.used = used - self.unused = unused - self.change = change +class ActivityTags: + activity_id: "str" + tags: "typing.List[str]" + def __init__(self, *, activity_id: "str", tags: "typing.List[str]"): + self.activity_id = activity_id + self.tags = tags def __str__(self): - return "AccountAddresses(used={}, unused={}, change={})".format(self.used, self.unused, self.change) + return "ActivityTags(activity_id={}, tags={})".format(self.activity_id, self.tags) def __eq__(self, other): - if self.used != other.used: - return False - if self.unused != other.unused: + if self.activity_id != other.activity_id: return False - if self.change != other.change: - return False - return True - -class _UniffiConverterTypeAccountAddresses(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return AccountAddresses( - used=_UniffiConverterSequenceTypeAddressInfo.read(buf), - unused=_UniffiConverterSequenceTypeAddressInfo.read(buf), - change=_UniffiConverterSequenceTypeAddressInfo.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterSequenceTypeAddressInfo.check_lower(value.used) - _UniffiConverterSequenceTypeAddressInfo.check_lower(value.unused) - _UniffiConverterSequenceTypeAddressInfo.check_lower(value.change) - - @staticmethod - def write(value, buf): - _UniffiConverterSequenceTypeAddressInfo.write(value.used, buf) - _UniffiConverterSequenceTypeAddressInfo.write(value.unused, buf) - _UniffiConverterSequenceTypeAddressInfo.write(value.change, buf) - - -class AccountInfoResponse: - """ - Account info response - """ - - id: "int" - path: "str" - descriptor: "str" - legacy_xpub: "typing.Optional[str]" - balance: "str" - available_balance: "str" - def __init__(self, *, id: "int", path: "str", descriptor: "str", legacy_xpub: "typing.Optional[str]", balance: "str", available_balance: "str"): - self.id = id - self.path = path - self.descriptor = descriptor - self.legacy_xpub = legacy_xpub - self.balance = balance - self.available_balance = available_balance - - def __str__(self): - return "AccountInfoResponse(id={}, path={}, descriptor={}, legacy_xpub={}, balance={}, available_balance={})".format(self.id, self.path, self.descriptor, self.legacy_xpub, self.balance, self.available_balance) - - def __eq__(self, other): - if self.id != other.id: - return False - if self.path != other.path: - return False - if self.descriptor != other.descriptor: - return False - if self.legacy_xpub != other.legacy_xpub: - return False - if self.balance != other.balance: - return False - if self.available_balance != other.available_balance: - return False - return True - -class _UniffiConverterTypeAccountInfoResponse(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return AccountInfoResponse( - id=_UniffiConverterUInt32.read(buf), - path=_UniffiConverterString.read(buf), - descriptor=_UniffiConverterString.read(buf), - legacy_xpub=_UniffiConverterOptionalString.read(buf), - balance=_UniffiConverterString.read(buf), - available_balance=_UniffiConverterString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterUInt32.check_lower(value.id) - _UniffiConverterString.check_lower(value.path) - _UniffiConverterString.check_lower(value.descriptor) - _UniffiConverterOptionalString.check_lower(value.legacy_xpub) - _UniffiConverterString.check_lower(value.balance) - _UniffiConverterString.check_lower(value.available_balance) - - @staticmethod - def write(value, buf): - _UniffiConverterUInt32.write(value.id, buf) - _UniffiConverterString.write(value.path, buf) - _UniffiConverterString.write(value.descriptor, buf) - _UniffiConverterOptionalString.write(value.legacy_xpub, buf) - _UniffiConverterString.write(value.balance, buf) - _UniffiConverterString.write(value.available_balance, buf) - - -class AccountUtxo: - """ - UTXO information for account - """ - - txid: "str" - """ - Transaction ID - """ - - vout: "int" - """ - Output index - """ - - amount: "str" - """ - Amount in satoshis - """ - - block_height: "typing.Optional[int]" - """ - Block height - """ - - address: "str" - """ - Address - """ - - path: "str" - """ - Derivation path - """ - - confirmations: "typing.Optional[int]" - """ - Number of confirmations - """ - - def __init__(self, *, txid: "str", vout: "int", amount: "str", block_height: "typing.Optional[int]", address: "str", path: "str", confirmations: "typing.Optional[int]"): - self.txid = txid - self.vout = vout - self.amount = amount - self.block_height = block_height - self.address = address - self.path = path - self.confirmations = confirmations - - def __str__(self): - return "AccountUtxo(txid={}, vout={}, amount={}, block_height={}, address={}, path={}, confirmations={})".format(self.txid, self.vout, self.amount, self.block_height, self.address, self.path, self.confirmations) - - def __eq__(self, other): - if self.txid != other.txid: - return False - if self.vout != other.vout: - return False - if self.amount != other.amount: - return False - if self.block_height != other.block_height: - return False - if self.address != other.address: - return False - if self.path != other.path: - return False - if self.confirmations != other.confirmations: - return False - return True - -class _UniffiConverterTypeAccountUtxo(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return AccountUtxo( - txid=_UniffiConverterString.read(buf), - vout=_UniffiConverterUInt32.read(buf), - amount=_UniffiConverterString.read(buf), - block_height=_UniffiConverterOptionalUInt32.read(buf), - address=_UniffiConverterString.read(buf), - path=_UniffiConverterString.read(buf), - confirmations=_UniffiConverterOptionalUInt32.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.txid) - _UniffiConverterUInt32.check_lower(value.vout) - _UniffiConverterString.check_lower(value.amount) - _UniffiConverterOptionalUInt32.check_lower(value.block_height) - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.path) - _UniffiConverterOptionalUInt32.check_lower(value.confirmations) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.txid, buf) - _UniffiConverterUInt32.write(value.vout, buf) - _UniffiConverterString.write(value.amount, buf) - _UniffiConverterOptionalUInt32.write(value.block_height, buf) - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.path, buf) - _UniffiConverterOptionalUInt32.write(value.confirmations, buf) - - -class ActivityTags: - activity_id: "str" - tags: "typing.List[str]" - def __init__(self, *, activity_id: "str", tags: "typing.List[str]"): - self.activity_id = activity_id - self.tags = tags - - def __str__(self): - return "ActivityTags(activity_id={}, tags={})".format(self.activity_id, self.tags) - - def __eq__(self, other): - if self.activity_id != other.activity_id: - return False - if self.tags != other.tags: + if self.tags != other.tags: return False return True @@ -2359,112 +2414,6 @@ def write(value, buf): _UniffiConverterSequenceString.write(value.tags, buf) -class AddressInfo: - """ - Address information - """ - - address: "str" - """ - Address string - """ - - path: "str" - """ - Derivation path - """ - - transfers: "int" - """ - Number of transfers - """ - - def __init__(self, *, address: "str", path: "str", transfers: "int"): - self.address = address - self.path = path - self.transfers = transfers - - def __str__(self): - return "AddressInfo(address={}, path={}, transfers={})".format(self.address, self.path, self.transfers) - - def __eq__(self, other): - if self.address != other.address: - return False - if self.path != other.path: - return False - if self.transfers != other.transfers: - return False - return True - -class _UniffiConverterTypeAddressInfo(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return AddressInfo( - address=_UniffiConverterString.read(buf), - path=_UniffiConverterString.read(buf), - transfers=_UniffiConverterUInt32.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.path) - _UniffiConverterUInt32.check_lower(value.transfers) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.path, buf) - _UniffiConverterUInt32.write(value.transfers, buf) - - -class AddressResponse: - """ - Address response containing the derived address information - """ - - address: "str" - path: "typing.List[int]" - serialized_path: "str" - def __init__(self, *, address: "str", path: "typing.List[int]", serialized_path: "str"): - self.address = address - self.path = path - self.serialized_path = serialized_path - - def __str__(self): - return "AddressResponse(address={}, path={}, serialized_path={})".format(self.address, self.path, self.serialized_path) - - def __eq__(self, other): - if self.address != other.address: - return False - if self.path != other.path: - return False - if self.serialized_path != other.serialized_path: - return False - return True - -class _UniffiConverterTypeAddressResponse(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return AddressResponse( - address=_UniffiConverterString.read(buf), - path=_UniffiConverterSequenceUInt32.read(buf), - serialized_path=_UniffiConverterString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterSequenceUInt32.check_lower(value.path) - _UniffiConverterString.check_lower(value.serialized_path) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterSequenceUInt32.write(value.path, buf) - _UniffiConverterString.write(value.serialized_path, buf) - - class ChannelLiquidityOptions: default_lsp_balance_sat: "int" min_lsp_balance_sat: "int" @@ -2692,228 +2641,29 @@ def write(value, buf): _UniffiConverterString.write(value.channel_closure_reason, buf) -class CoinPurchaseMemo: - """ - Coin purchase memo - """ - - coin_type: "int" - """ - Coin type - """ - - amount: "int" - """ - Amount - """ - - address: "str" - """ - Address - """ - - mac: "str" - """ - MAC - """ - - def __init__(self, *, coin_type: "int", amount: "int", address: "str", mac: "str"): - self.coin_type = coin_type - self.amount = amount - self.address = address - self.mac = mac +class CreateCjitOptions: + source: "typing.Optional[str]" + discount_code: "typing.Optional[str]" + def __init__(self, *, source: "typing.Optional[str]", discount_code: "typing.Optional[str]"): + self.source = source + self.discount_code = discount_code def __str__(self): - return "CoinPurchaseMemo(coin_type={}, amount={}, address={}, mac={})".format(self.coin_type, self.amount, self.address, self.mac) + return "CreateCjitOptions(source={}, discount_code={})".format(self.source, self.discount_code) def __eq__(self, other): - if self.coin_type != other.coin_type: - return False - if self.amount != other.amount: - return False - if self.address != other.address: + if self.source != other.source: return False - if self.mac != other.mac: + if self.discount_code != other.discount_code: return False return True -class _UniffiConverterTypeCoinPurchaseMemo(_UniffiConverterRustBuffer): +class _UniffiConverterTypeCreateCjitOptions(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return CoinPurchaseMemo( - coin_type=_UniffiConverterUInt32.read(buf), - amount=_UniffiConverterUInt64.read(buf), - address=_UniffiConverterString.read(buf), - mac=_UniffiConverterString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterUInt32.check_lower(value.coin_type) - _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.mac) - - @staticmethod - def write(value, buf): - _UniffiConverterUInt32.write(value.coin_type, buf) - _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.mac, buf) - - -class CommonParams: - """ - Common parameters for all Trezor Connect methods - """ - - device: "typing.Optional[DeviceParams]" - """ - Specific device instance to use - """ - - use_empty_passphrase: "typing.Optional[bool]" - """ - Set to true if method should use empty passphrase - """ - - allow_seedless_device: "typing.Optional[bool]" - """ - Allow seedless device - """ - - skip_final_reload: "typing.Optional[bool]" - """ - Skip final reload - """ - - def __init__(self, *, device: "typing.Optional[DeviceParams]", use_empty_passphrase: "typing.Optional[bool]", allow_seedless_device: "typing.Optional[bool]", skip_final_reload: "typing.Optional[bool]"): - self.device = device - self.use_empty_passphrase = use_empty_passphrase - self.allow_seedless_device = allow_seedless_device - self.skip_final_reload = skip_final_reload - - def __str__(self): - return "CommonParams(device={}, use_empty_passphrase={}, allow_seedless_device={}, skip_final_reload={})".format(self.device, self.use_empty_passphrase, self.allow_seedless_device, self.skip_final_reload) - - def __eq__(self, other): - if self.device != other.device: - return False - if self.use_empty_passphrase != other.use_empty_passphrase: - return False - if self.allow_seedless_device != other.allow_seedless_device: - return False - if self.skip_final_reload != other.skip_final_reload: - return False - return True - -class _UniffiConverterTypeCommonParams(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return CommonParams( - device=_UniffiConverterOptionalTypeDeviceParams.read(buf), - use_empty_passphrase=_UniffiConverterOptionalBool.read(buf), - allow_seedless_device=_UniffiConverterOptionalBool.read(buf), - skip_final_reload=_UniffiConverterOptionalBool.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterOptionalTypeDeviceParams.check_lower(value.device) - _UniffiConverterOptionalBool.check_lower(value.use_empty_passphrase) - _UniffiConverterOptionalBool.check_lower(value.allow_seedless_device) - _UniffiConverterOptionalBool.check_lower(value.skip_final_reload) - - @staticmethod - def write(value, buf): - _UniffiConverterOptionalTypeDeviceParams.write(value.device, buf) - _UniffiConverterOptionalBool.write(value.use_empty_passphrase, buf) - _UniffiConverterOptionalBool.write(value.allow_seedless_device, buf) - _UniffiConverterOptionalBool.write(value.skip_final_reload, buf) - - -class ComposeAccount: - """ - Account information for compose transaction - """ - - path: "str" - """ - Derivation path - """ - - addresses: "AccountAddresses" - """ - Account addresses - """ - - utxo: "typing.List[AccountUtxo]" - """ - UTXOs - """ - - def __init__(self, *, path: "str", addresses: "AccountAddresses", utxo: "typing.List[AccountUtxo]"): - self.path = path - self.addresses = addresses - self.utxo = utxo - - def __str__(self): - return "ComposeAccount(path={}, addresses={}, utxo={})".format(self.path, self.addresses, self.utxo) - - def __eq__(self, other): - if self.path != other.path: - return False - if self.addresses != other.addresses: - return False - if self.utxo != other.utxo: - return False - return True - -class _UniffiConverterTypeComposeAccount(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return ComposeAccount( - path=_UniffiConverterString.read(buf), - addresses=_UniffiConverterTypeAccountAddresses.read(buf), - utxo=_UniffiConverterSequenceTypeAccountUtxo.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.path) - _UniffiConverterTypeAccountAddresses.check_lower(value.addresses) - _UniffiConverterSequenceTypeAccountUtxo.check_lower(value.utxo) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.path, buf) - _UniffiConverterTypeAccountAddresses.write(value.addresses, buf) - _UniffiConverterSequenceTypeAccountUtxo.write(value.utxo, buf) - - -class CreateCjitOptions: - source: "typing.Optional[str]" - discount_code: "typing.Optional[str]" - def __init__(self, *, source: "typing.Optional[str]", discount_code: "typing.Optional[str]"): - self.source = source - self.discount_code = discount_code - - def __str__(self): - return "CreateCjitOptions(source={}, discount_code={})".format(self.source, self.discount_code) - - def __eq__(self, other): - if self.source != other.source: - return False - if self.discount_code != other.discount_code: - return False - return True - -class _UniffiConverterTypeCreateCjitOptions(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return CreateCjitOptions( - source=_UniffiConverterOptionalString.read(buf), - discount_code=_UniffiConverterOptionalString.read(buf), + return CreateCjitOptions( + source=_UniffiConverterOptionalString.read(buf), + discount_code=_UniffiConverterOptionalString.read(buf), ) @staticmethod @@ -3040,54 +2790,6 @@ def write(value, buf): _UniffiConverterBool.write(value.announce_channel, buf) -class DeepLinkResult: - """ - Result type for deep link generation, including the URL and the ID used - """ - - url: "str" - """ - The generated deep link URL - """ - - request_id: "str" - """ - The request ID used (either provided or auto-generated) - """ - - def __init__(self, *, url: "str", request_id: "str"): - self.url = url - self.request_id = request_id - - def __str__(self): - return "DeepLinkResult(url={}, request_id={})".format(self.url, self.request_id) - - def __eq__(self, other): - if self.url != other.url: - return False - if self.request_id != other.request_id: - return False - return True - -class _UniffiConverterTypeDeepLinkResult(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return DeepLinkResult( - url=_UniffiConverterString.read(buf), - request_id=_UniffiConverterString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.url) - _UniffiConverterString.check_lower(value.request_id) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.url, buf) - _UniffiConverterString.write(value.request_id, buf) - - class DefaultLspBalanceParams: client_balance_sat: "int" max_channel_size_sat: "int" @@ -3131,54 +2833,6 @@ def write(value, buf): _UniffiConverterUInt64.write(value.sats_per_eur, buf) -class DeviceParams: - """ - Parameters for specifying a particular device - """ - - path: "typing.Optional[str]" - """ - Device instance path - """ - - instance: "typing.Optional[int]" - """ - Device instance ID - """ - - def __init__(self, *, path: "typing.Optional[str]", instance: "typing.Optional[int]"): - self.path = path - self.instance = instance - - def __str__(self): - return "DeviceParams(path={}, instance={})".format(self.path, self.instance) - - def __eq__(self, other): - if self.path != other.path: - return False - if self.instance != other.instance: - return False - return True - -class _UniffiConverterTypeDeviceParams(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return DeviceParams( - path=_UniffiConverterOptionalString.read(buf), - instance=_UniffiConverterOptionalUInt32.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterOptionalString.check_lower(value.path) - _UniffiConverterOptionalUInt32.check_lower(value.instance) - - @staticmethod - def write(value, buf): - _UniffiConverterOptionalString.write(value.path, buf) - _UniffiConverterOptionalUInt32.write(value.instance, buf) - - class ErrorData: error_details: "str" def __init__(self, *, error_details: "str"): @@ -3208,133 +2862,6 @@ def write(value, buf): _UniffiConverterString.write(value.error_details, buf) -class FeatureResponse: - """ - Feature response containing device capabilities and information - """ - - vendor: "str" - major_version: "int" - minor_version: "int" - patch_version: "int" - device_id: "str" - capabilities: "typing.Optional[typing.List[str]]" - def __init__(self, *, vendor: "str", major_version: "int", minor_version: "int", patch_version: "int", device_id: "str", capabilities: "typing.Optional[typing.List[str]]"): - self.vendor = vendor - self.major_version = major_version - self.minor_version = minor_version - self.patch_version = patch_version - self.device_id = device_id - self.capabilities = capabilities - - def __str__(self): - return "FeatureResponse(vendor={}, major_version={}, minor_version={}, patch_version={}, device_id={}, capabilities={})".format(self.vendor, self.major_version, self.minor_version, self.patch_version, self.device_id, self.capabilities) - - def __eq__(self, other): - if self.vendor != other.vendor: - return False - if self.major_version != other.major_version: - return False - if self.minor_version != other.minor_version: - return False - if self.patch_version != other.patch_version: - return False - if self.device_id != other.device_id: - return False - if self.capabilities != other.capabilities: - return False - return True - -class _UniffiConverterTypeFeatureResponse(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return FeatureResponse( - vendor=_UniffiConverterString.read(buf), - major_version=_UniffiConverterUInt32.read(buf), - minor_version=_UniffiConverterUInt32.read(buf), - patch_version=_UniffiConverterUInt32.read(buf), - device_id=_UniffiConverterString.read(buf), - capabilities=_UniffiConverterOptionalSequenceString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.vendor) - _UniffiConverterUInt32.check_lower(value.major_version) - _UniffiConverterUInt32.check_lower(value.minor_version) - _UniffiConverterUInt32.check_lower(value.patch_version) - _UniffiConverterString.check_lower(value.device_id) - _UniffiConverterOptionalSequenceString.check_lower(value.capabilities) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.vendor, buf) - _UniffiConverterUInt32.write(value.major_version, buf) - _UniffiConverterUInt32.write(value.minor_version, buf) - _UniffiConverterUInt32.write(value.patch_version, buf) - _UniffiConverterString.write(value.device_id, buf) - _UniffiConverterOptionalSequenceString.write(value.capabilities, buf) - - -class FeeLevel: - """ - Fee level for compose transaction - """ - - fee_per_unit: "str" - """ - Fee per unit (satoshi/byte or satoshi/vbyte) - """ - - base_fee: "typing.Optional[int]" - """ - Base fee in satoshi (optional, used in RBF and DOGE) - """ - - floor_base_fee: "typing.Optional[bool]" - """ - Floor base fee (optional, used in DOGE) - """ - - def __init__(self, *, fee_per_unit: "str", base_fee: "typing.Optional[int]", floor_base_fee: "typing.Optional[bool]"): - self.fee_per_unit = fee_per_unit - self.base_fee = base_fee - self.floor_base_fee = floor_base_fee - - def __str__(self): - return "FeeLevel(fee_per_unit={}, base_fee={}, floor_base_fee={})".format(self.fee_per_unit, self.base_fee, self.floor_base_fee) - - def __eq__(self, other): - if self.fee_per_unit != other.fee_per_unit: - return False - if self.base_fee != other.base_fee: - return False - if self.floor_base_fee != other.floor_base_fee: - return False - return True - -class _UniffiConverterTypeFeeLevel(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return FeeLevel( - fee_per_unit=_UniffiConverterString.read(buf), - base_fee=_UniffiConverterOptionalUInt32.read(buf), - floor_base_fee=_UniffiConverterOptionalBool.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.fee_per_unit) - _UniffiConverterOptionalUInt32.check_lower(value.base_fee) - _UniffiConverterOptionalBool.check_lower(value.floor_base_fee) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.fee_per_unit, buf) - _UniffiConverterOptionalUInt32.write(value.base_fee, buf) - _UniffiConverterOptionalBool.write(value.floor_base_fee, buf) - - class FeeRates: fast: "int" mid: "int" @@ -3502,166 +3029,15 @@ def write(value, buf): _UniffiConverterSequenceTypeGetAddressResponse.write(value.addresses, buf) -class HdNodePathType: - """ - HD Node Path Type - """ +class IBt0ConfMinTxFeeWindow: + sat_per_vbyte: "float" + validity_ends_at: "str" + def __init__(self, *, sat_per_vbyte: "float", validity_ends_at: "str"): + self.sat_per_vbyte = sat_per_vbyte + self.validity_ends_at = validity_ends_at - node: "HdNodeTypeOrString" - """ - Node data (can be String or HDNodeType) - """ - - address_n: "typing.List[int]" - """ - BIP32 derivation path - """ - - def __init__(self, *, node: "HdNodeTypeOrString", address_n: "typing.List[int]"): - self.node = node - self.address_n = address_n - - def __str__(self): - return "HdNodePathType(node={}, address_n={})".format(self.node, self.address_n) - - def __eq__(self, other): - if self.node != other.node: - return False - if self.address_n != other.address_n: - return False - return True - -class _UniffiConverterTypeHdNodePathType(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return HdNodePathType( - node=_UniffiConverterTypeHdNodeTypeOrString.read(buf), - address_n=_UniffiConverterSequenceUInt32.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterTypeHdNodeTypeOrString.check_lower(value.node) - _UniffiConverterSequenceUInt32.check_lower(value.address_n) - - @staticmethod - def write(value, buf): - _UniffiConverterTypeHdNodeTypeOrString.write(value.node, buf) - _UniffiConverterSequenceUInt32.write(value.address_n, buf) - - -class HdNodeType: - """ - HD Node Type - """ - - depth: "int" - """ - Depth - """ - - fingerprint: "int" - """ - Fingerprint - """ - - child_num: "int" - """ - Child number - """ - - chain_code: "str" - """ - Chain code - """ - - public_key: "str" - """ - Public key - """ - - private_key: "typing.Optional[str]" - """ - Private key (optional) - """ - - address_n: "typing.Optional[typing.List[int]]" - """ - BIP32 derivation path (optional) - """ - - def __init__(self, *, depth: "int", fingerprint: "int", child_num: "int", chain_code: "str", public_key: "str", private_key: "typing.Optional[str]", address_n: "typing.Optional[typing.List[int]]"): - self.depth = depth - self.fingerprint = fingerprint - self.child_num = child_num - self.chain_code = chain_code - self.public_key = public_key - self.private_key = private_key - self.address_n = address_n - - def __str__(self): - return "HdNodeType(depth={}, fingerprint={}, child_num={}, chain_code={}, public_key={}, private_key={}, address_n={})".format(self.depth, self.fingerprint, self.child_num, self.chain_code, self.public_key, self.private_key, self.address_n) - - def __eq__(self, other): - if self.depth != other.depth: - return False - if self.fingerprint != other.fingerprint: - return False - if self.child_num != other.child_num: - return False - if self.chain_code != other.chain_code: - return False - if self.public_key != other.public_key: - return False - if self.private_key != other.private_key: - return False - if self.address_n != other.address_n: - return False - return True - -class _UniffiConverterTypeHdNodeType(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return HdNodeType( - depth=_UniffiConverterUInt32.read(buf), - fingerprint=_UniffiConverterUInt32.read(buf), - child_num=_UniffiConverterUInt32.read(buf), - chain_code=_UniffiConverterString.read(buf), - public_key=_UniffiConverterString.read(buf), - private_key=_UniffiConverterOptionalString.read(buf), - address_n=_UniffiConverterOptionalSequenceUInt32.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterUInt32.check_lower(value.depth) - _UniffiConverterUInt32.check_lower(value.fingerprint) - _UniffiConverterUInt32.check_lower(value.child_num) - _UniffiConverterString.check_lower(value.chain_code) - _UniffiConverterString.check_lower(value.public_key) - _UniffiConverterOptionalString.check_lower(value.private_key) - _UniffiConverterOptionalSequenceUInt32.check_lower(value.address_n) - - @staticmethod - def write(value, buf): - _UniffiConverterUInt32.write(value.depth, buf) - _UniffiConverterUInt32.write(value.fingerprint, buf) - _UniffiConverterUInt32.write(value.child_num, buf) - _UniffiConverterString.write(value.chain_code, buf) - _UniffiConverterString.write(value.public_key, buf) - _UniffiConverterOptionalString.write(value.private_key, buf) - _UniffiConverterOptionalSequenceUInt32.write(value.address_n, buf) - - -class IBt0ConfMinTxFeeWindow: - sat_per_vbyte: "float" - validity_ends_at: "str" - def __init__(self, *, sat_per_vbyte: "float", validity_ends_at: "str"): - self.sat_per_vbyte = sat_per_vbyte - self.validity_ends_at = validity_ends_at - - def __str__(self): - return "IBt0ConfMinTxFeeWindow(sat_per_vbyte={}, validity_ends_at={})".format(self.sat_per_vbyte, self.validity_ends_at) + def __str__(self): + return "IBt0ConfMinTxFeeWindow(sat_per_vbyte={}, validity_ends_at={})".format(self.sat_per_vbyte, self.validity_ends_at) def __eq__(self, other): if self.sat_per_vbyte != other.sat_per_vbyte: @@ -6086,133 +5462,85 @@ def write(value, buf): _UniffiConverterString.write(value.tag, buf) -class MessageSignatureResponse: - """ - Message signature response - """ - - address: "str" - """ - Signer address - """ - - signature: "str" - """ - Signature in base64 format - """ - - def __init__(self, *, address: "str", signature: "str"): - self.address = address - self.signature = signature - - def __str__(self): - return "MessageSignatureResponse(address={}, signature={})".format(self.address, self.signature) - - def __eq__(self, other): - if self.address != other.address: - return False - if self.signature != other.signature: - return False - return True - -class _UniffiConverterTypeMessageSignatureResponse(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return MessageSignatureResponse( - address=_UniffiConverterString.read(buf), - signature=_UniffiConverterString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.signature) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.signature, buf) - - -class MultisigRedeemScriptType: +class NativeDeviceInfo: """ - Multisig Redeem Script Type + Native device information returned from enumeration """ - pubkeys: "typing.List[HdNodePathType]" + path: "str" """ - Public keys + Unique path/identifier for this device """ - signatures: "typing.List[str]" + transport_type: "str" """ - Signatures + Transport type: "usb" or "bluetooth" """ - m: "int" + name: "typing.Optional[str]" """ - M-of-N threshold + Optional device name (from BLE advertisement or USB descriptor) """ - nodes: "typing.Optional[typing.List[HdNodeType]]" + vendor_id: "typing.Optional[int]" """ - Nodes (optional) + USB Vendor ID (for USB devices) """ - pubkeys_order: "typing.Optional[int]" + product_id: "typing.Optional[int]" """ - Pubkeys order (optional): 0 for PRESERVED, 1 for LEXICOGRAPHIC + USB Product ID (for USB devices) """ - def __init__(self, *, pubkeys: "typing.List[HdNodePathType]", signatures: "typing.List[str]", m: "int", nodes: "typing.Optional[typing.List[HdNodeType]]", pubkeys_order: "typing.Optional[int]"): - self.pubkeys = pubkeys - self.signatures = signatures - self.m = m - self.nodes = nodes - self.pubkeys_order = pubkeys_order + 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 "MultisigRedeemScriptType(pubkeys={}, signatures={}, m={}, nodes={}, pubkeys_order={})".format(self.pubkeys, self.signatures, self.m, self.nodes, self.pubkeys_order) + 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.pubkeys != other.pubkeys: + if self.path != other.path: return False - if self.signatures != other.signatures: + if self.transport_type != other.transport_type: return False - if self.m != other.m: + if self.name != other.name: return False - if self.nodes != other.nodes: + if self.vendor_id != other.vendor_id: return False - if self.pubkeys_order != other.pubkeys_order: + if self.product_id != other.product_id: return False return True -class _UniffiConverterTypeMultisigRedeemScriptType(_UniffiConverterRustBuffer): +class _UniffiConverterTypeNativeDeviceInfo(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return MultisigRedeemScriptType( - pubkeys=_UniffiConverterSequenceTypeHdNodePathType.read(buf), - signatures=_UniffiConverterSequenceString.read(buf), - m=_UniffiConverterUInt32.read(buf), - nodes=_UniffiConverterOptionalSequenceTypeHdNodeType.read(buf), - pubkeys_order=_UniffiConverterOptionalUInt8.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): - _UniffiConverterSequenceTypeHdNodePathType.check_lower(value.pubkeys) - _UniffiConverterSequenceString.check_lower(value.signatures) - _UniffiConverterUInt32.check_lower(value.m) - _UniffiConverterOptionalSequenceTypeHdNodeType.check_lower(value.nodes) - _UniffiConverterOptionalUInt8.check_lower(value.pubkeys_order) + _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): - _UniffiConverterSequenceTypeHdNodePathType.write(value.pubkeys, buf) - _UniffiConverterSequenceString.write(value.signatures, buf) - _UniffiConverterUInt32.write(value.m, buf) - _UniffiConverterOptionalSequenceTypeHdNodeType.write(value.nodes, buf) - _UniffiConverterOptionalUInt8.write(value.pubkeys_order, 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: @@ -6427,65 +5755,6 @@ def write(value, buf): _UniffiConverterOptionalUInt64.write(value.seen_at, buf) -class PaymentRequestMemo: - """ - Payment request memo types - """ - - text_memo: "typing.Optional[TextMemo]" - """ - Text memo - """ - - refund_memo: "typing.Optional[RefundMemo]" - """ - Refund memo - """ - - coin_purchase_memo: "typing.Optional[CoinPurchaseMemo]" - """ - Coin purchase memo - """ - - def __init__(self, *, text_memo: "typing.Optional[TextMemo]", refund_memo: "typing.Optional[RefundMemo]", coin_purchase_memo: "typing.Optional[CoinPurchaseMemo]"): - self.text_memo = text_memo - self.refund_memo = refund_memo - self.coin_purchase_memo = coin_purchase_memo - - def __str__(self): - return "PaymentRequestMemo(text_memo={}, refund_memo={}, coin_purchase_memo={})".format(self.text_memo, self.refund_memo, self.coin_purchase_memo) - - def __eq__(self, other): - if self.text_memo != other.text_memo: - return False - if self.refund_memo != other.refund_memo: - return False - if self.coin_purchase_memo != other.coin_purchase_memo: - return False - return True - -class _UniffiConverterTypePaymentRequestMemo(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return PaymentRequestMemo( - text_memo=_UniffiConverterOptionalTypeTextMemo.read(buf), - refund_memo=_UniffiConverterOptionalTypeRefundMemo.read(buf), - coin_purchase_memo=_UniffiConverterOptionalTypeCoinPurchaseMemo.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterOptionalTypeTextMemo.check_lower(value.text_memo) - _UniffiConverterOptionalTypeRefundMemo.check_lower(value.refund_memo) - _UniffiConverterOptionalTypeCoinPurchaseMemo.check_lower(value.coin_purchase_memo) - - @staticmethod - def write(value, buf): - _UniffiConverterOptionalTypeTextMemo.write(value.text_memo, buf) - _UniffiConverterOptionalTypeRefundMemo.write(value.refund_memo, buf) - _UniffiConverterOptionalTypeCoinPurchaseMemo.write(value.coin_purchase_memo, buf) - - class PreActivityMetadata: payment_id: "str" tags: "typing.List[str]" @@ -6578,1602 +5847,1556 @@ def write(value, buf): _UniffiConverterUInt64.write(value.created_at, buf) -class PrecomposedInput: - """ - Precomposed transaction input - """ - - address_n: "typing.List[int]" - """ - BIP32 derivation path - """ - - amount: "str" - """ - Amount in satoshis - """ - - prev_hash: "str" - """ - Previous transaction hash - """ - - prev_index: "int" - """ - Previous output index - """ - - script_type: "ScriptType" - """ - Script type - """ - - def __init__(self, *, address_n: "typing.List[int]", amount: "str", prev_hash: "str", prev_index: "int", script_type: "ScriptType"): - self.address_n = address_n - self.amount = amount - self.prev_hash = prev_hash - self.prev_index = prev_index - self.script_type = script_type +class PubkyAuth: + data: "str" + def __init__(self, *, data: "str"): + self.data = data def __str__(self): - return "PrecomposedInput(address_n={}, amount={}, prev_hash={}, prev_index={}, script_type={})".format(self.address_n, self.amount, self.prev_hash, self.prev_index, self.script_type) + return "PubkyAuth(data={})".format(self.data) def __eq__(self, other): - if self.address_n != other.address_n: - return False - if self.amount != other.amount: - return False - if self.prev_hash != other.prev_hash: - return False - if self.prev_index != other.prev_index: - return False - if self.script_type != other.script_type: + if self.data != other.data: return False return True -class _UniffiConverterTypePrecomposedInput(_UniffiConverterRustBuffer): +class _UniffiConverterTypePubkyAuth(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PrecomposedInput( - address_n=_UniffiConverterSequenceUInt32.read(buf), - amount=_UniffiConverterString.read(buf), - prev_hash=_UniffiConverterString.read(buf), - prev_index=_UniffiConverterUInt32.read(buf), - script_type=_UniffiConverterTypeScriptType.read(buf), + return PubkyAuth( + data=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterSequenceUInt32.check_lower(value.address_n) - _UniffiConverterString.check_lower(value.amount) - _UniffiConverterString.check_lower(value.prev_hash) - _UniffiConverterUInt32.check_lower(value.prev_index) - _UniffiConverterTypeScriptType.check_lower(value.script_type) + _UniffiConverterString.check_lower(value.data) @staticmethod def write(value, buf): - _UniffiConverterSequenceUInt32.write(value.address_n, buf) - _UniffiConverterString.write(value.amount, buf) - _UniffiConverterString.write(value.prev_hash, buf) - _UniffiConverterUInt32.write(value.prev_index, buf) - _UniffiConverterTypeScriptType.write(value.script_type, buf) - + _UniffiConverterString.write(value.data, buf) -class PrecomposedOutput: - """ - Precomposed transaction output - """ - address_n: "typing.Optional[typing.List[int]]" +class SweepResult: + txid: "str" """ - BIP32 derivation path (for change outputs) + The transaction ID of the sweep transaction """ - amount: "str" + amount_swept: "int" """ - Amount in satoshis + The total amount swept (in satoshis) """ - address: "typing.Optional[str]" + fee_paid: "int" """ - Address (for regular outputs) + The fee paid (in satoshis) """ - script_type: "ScriptType" + utxos_swept: "int" """ - Script type + The number of UTXOs swept """ - def __init__(self, *, address_n: "typing.Optional[typing.List[int]]", amount: "str", address: "typing.Optional[str]", script_type: "ScriptType"): - self.address_n = address_n - self.amount = amount - self.address = address - self.script_type = script_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 "PrecomposedOutput(address_n={}, amount={}, address={}, script_type={})".format(self.address_n, self.amount, self.address, self.script_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.address_n != other.address_n: + if self.txid != other.txid: return False - if self.amount != other.amount: + if self.amount_swept != other.amount_swept: return False - if self.address != other.address: + if self.fee_paid != other.fee_paid: return False - if self.script_type != other.script_type: + if self.utxos_swept != other.utxos_swept: return False return True -class _UniffiConverterTypePrecomposedOutput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSweepResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PrecomposedOutput( - address_n=_UniffiConverterOptionalSequenceUInt32.read(buf), - amount=_UniffiConverterString.read(buf), - address=_UniffiConverterOptionalString.read(buf), - script_type=_UniffiConverterTypeScriptType.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): - _UniffiConverterOptionalSequenceUInt32.check_lower(value.address_n) - _UniffiConverterString.check_lower(value.amount) - _UniffiConverterOptionalString.check_lower(value.address) - _UniffiConverterTypeScriptType.check_lower(value.script_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): - _UniffiConverterOptionalSequenceUInt32.write(value.address_n, buf) - _UniffiConverterString.write(value.amount, buf) - _UniffiConverterOptionalString.write(value.address, buf) - _UniffiConverterTypeScriptType.write(value.script_type, buf) - - -class PrecomposedTransaction: - """ - Precomposed transaction - """ + _UniffiConverterString.write(value.txid, buf) + _UniffiConverterUInt64.write(value.amount_swept, buf) + _UniffiConverterUInt64.write(value.fee_paid, buf) + _UniffiConverterUInt32.write(value.utxos_swept, buf) - tx_type: "str" - """ - Transaction type (usually "final" or "error") - """ - total_spent: "typing.Optional[str]" +class SweepTransactionPreview: + psbt: "str" """ - Total amount spent (including fee) + The PSBT (Partially Signed Bitcoin Transaction) in base64 format """ - fee: "typing.Optional[str]" + total_amount: "int" """ - Transaction fee + The total amount available to sweep (in satoshis) """ - fee_per_byte: "typing.Optional[str]" + estimated_fee: "int" """ - Fee per byte + The estimated fee for the transaction (in satoshis) """ - bytes: "typing.Optional[int]" + estimated_vsize: "int" """ - Transaction size in bytes + The estimated virtual size of the transaction (in vbytes) """ - inputs: "typing.Optional[typing.List[PrecomposedInput]]" + utxos_count: "int" """ - Transaction inputs + The number of UTXOs that will be swept """ - outputs: "typing.Optional[typing.List[PrecomposedOutput]]" + destination_address: "str" """ - Transaction outputs + The destination address """ - outputs_permutation: "typing.Optional[typing.List[int]]" + amount_after_fees: "int" """ - Output permutation indices + The amount that will be sent to destination after fees (in satoshis) """ - def __init__(self, *, tx_type: "str", total_spent: "typing.Optional[str]", fee: "typing.Optional[str]", fee_per_byte: "typing.Optional[str]", bytes: "typing.Optional[int]", inputs: "typing.Optional[typing.List[PrecomposedInput]]", outputs: "typing.Optional[typing.List[PrecomposedOutput]]", outputs_permutation: "typing.Optional[typing.List[int]]"): - self.tx_type = tx_type - self.total_spent = total_spent - self.fee = fee - self.fee_per_byte = fee_per_byte - self.bytes = bytes - self.inputs = inputs - self.outputs = outputs - self.outputs_permutation = outputs_permutation + 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 "PrecomposedTransaction(tx_type={}, total_spent={}, fee={}, fee_per_byte={}, bytes={}, inputs={}, outputs={}, outputs_permutation={})".format(self.tx_type, self.total_spent, self.fee, self.fee_per_byte, self.bytes, self.inputs, self.outputs, self.outputs_permutation) + 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.tx_type != other.tx_type: - return False - if self.total_spent != other.total_spent: + if self.psbt != other.psbt: return False - if self.fee != other.fee: + if self.total_amount != other.total_amount: return False - if self.fee_per_byte != other.fee_per_byte: + if self.estimated_fee != other.estimated_fee: return False - if self.bytes != other.bytes: + if self.estimated_vsize != other.estimated_vsize: return False - if self.inputs != other.inputs: + if self.utxos_count != other.utxos_count: return False - if self.outputs != other.outputs: + if self.destination_address != other.destination_address: return False - if self.outputs_permutation != other.outputs_permutation: + if self.amount_after_fees != other.amount_after_fees: return False return True -class _UniffiConverterTypePrecomposedTransaction(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSweepTransactionPreview(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PrecomposedTransaction( - tx_type=_UniffiConverterString.read(buf), - total_spent=_UniffiConverterOptionalString.read(buf), - fee=_UniffiConverterOptionalString.read(buf), - fee_per_byte=_UniffiConverterOptionalString.read(buf), - bytes=_UniffiConverterOptionalUInt32.read(buf), - inputs=_UniffiConverterOptionalSequenceTypePrecomposedInput.read(buf), - outputs=_UniffiConverterOptionalSequenceTypePrecomposedOutput.read(buf), - outputs_permutation=_UniffiConverterOptionalSequenceUInt32.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.tx_type) - _UniffiConverterOptionalString.check_lower(value.total_spent) - _UniffiConverterOptionalString.check_lower(value.fee) - _UniffiConverterOptionalString.check_lower(value.fee_per_byte) - _UniffiConverterOptionalUInt32.check_lower(value.bytes) - _UniffiConverterOptionalSequenceTypePrecomposedInput.check_lower(value.inputs) - _UniffiConverterOptionalSequenceTypePrecomposedOutput.check_lower(value.outputs) - _UniffiConverterOptionalSequenceUInt32.check_lower(value.outputs_permutation) + _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.tx_type, buf) - _UniffiConverterOptionalString.write(value.total_spent, buf) - _UniffiConverterOptionalString.write(value.fee, buf) - _UniffiConverterOptionalString.write(value.fee_per_byte, buf) - _UniffiConverterOptionalUInt32.write(value.bytes, buf) - _UniffiConverterOptionalSequenceTypePrecomposedInput.write(value.inputs, buf) - _UniffiConverterOptionalSequenceTypePrecomposedOutput.write(value.outputs, buf) - _UniffiConverterOptionalSequenceUInt32.write(value.outputs_permutation, 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 PubkyAuth: - data: "str" - def __init__(self, *, data: "str"): - self.data = data +class SweepableBalances: + legacy_balance: "int" + """ + Balance in legacy (P2PKH) addresses (in satoshis) + """ - def __str__(self): - return "PubkyAuth(data={})".format(self.data) + p2sh_balance: "int" + """ + Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) + """ - def __eq__(self, other): - if self.data != other.data: - return False - return True + taproot_balance: "int" + """ + Balance in Taproot (P2TR) addresses (in satoshis) + """ -class _UniffiConverterTypePubkyAuth(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return PubkyAuth( - data=_UniffiConverterString.read(buf), - ) + total_balance: "int" + """ + Total balance across all wallet types (in satoshis) + """ - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.data) + legacy_utxos_count: "int" + """ + Number of UTXOs in legacy wallet + """ - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.data, buf) + p2sh_utxos_count: "int" + """ + Number of UTXOs in P2SH-SegWit wallet + """ + taproot_utxos_count: "int" + """ + Number of UTXOs in Taproot wallet + """ -class PublicKeyResponse: + total_utxos_count: "int" """ - Public key response containing the derived public key information + Total number of UTXOs across all wallet types """ - path: "typing.List[int]" - serialized_path: "str" - xpub: "str" - xpub_segwit: "typing.Optional[str]" - chain_code: "str" - child_num: "int" - public_key: "str" - fingerprint: "int" - depth: "int" - descriptor: "typing.Optional[str]" - def __init__(self, *, path: "typing.List[int]", serialized_path: "str", xpub: "str", xpub_segwit: "typing.Optional[str]", chain_code: "str", child_num: "int", public_key: "str", fingerprint: "int", depth: "int", descriptor: "typing.Optional[str]"): - self.path = path - self.serialized_path = serialized_path - self.xpub = xpub - self.xpub_segwit = xpub_segwit - self.chain_code = chain_code - self.child_num = child_num - self.public_key = public_key - self.fingerprint = fingerprint - self.depth = depth - self.descriptor = descriptor + 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 "PublicKeyResponse(path={}, serialized_path={}, xpub={}, xpub_segwit={}, chain_code={}, child_num={}, public_key={}, fingerprint={}, depth={}, descriptor={})".format(self.path, self.serialized_path, self.xpub, self.xpub_segwit, self.chain_code, self.child_num, self.public_key, self.fingerprint, self.depth, self.descriptor) + 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.path != other.path: - return False - if self.serialized_path != other.serialized_path: - return False - if self.xpub != other.xpub: + if self.legacy_balance != other.legacy_balance: return False - if self.xpub_segwit != other.xpub_segwit: + if self.p2sh_balance != other.p2sh_balance: return False - if self.chain_code != other.chain_code: + if self.taproot_balance != other.taproot_balance: return False - if self.child_num != other.child_num: + if self.total_balance != other.total_balance: return False - if self.public_key != other.public_key: + if self.legacy_utxos_count != other.legacy_utxos_count: return False - if self.fingerprint != other.fingerprint: + if self.p2sh_utxos_count != other.p2sh_utxos_count: return False - if self.depth != other.depth: + if self.taproot_utxos_count != other.taproot_utxos_count: return False - if self.descriptor != other.descriptor: + if self.total_utxos_count != other.total_utxos_count: return False return True -class _UniffiConverterTypePublicKeyResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSweepableBalances(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PublicKeyResponse( - path=_UniffiConverterSequenceUInt32.read(buf), - serialized_path=_UniffiConverterString.read(buf), - xpub=_UniffiConverterString.read(buf), - xpub_segwit=_UniffiConverterOptionalString.read(buf), - chain_code=_UniffiConverterString.read(buf), - child_num=_UniffiConverterUInt32.read(buf), - public_key=_UniffiConverterString.read(buf), - fingerprint=_UniffiConverterUInt32.read(buf), - depth=_UniffiConverterUInt32.read(buf), - descriptor=_UniffiConverterOptionalString.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): - _UniffiConverterSequenceUInt32.check_lower(value.path) - _UniffiConverterString.check_lower(value.serialized_path) - _UniffiConverterString.check_lower(value.xpub) - _UniffiConverterOptionalString.check_lower(value.xpub_segwit) - _UniffiConverterString.check_lower(value.chain_code) - _UniffiConverterUInt32.check_lower(value.child_num) - _UniffiConverterString.check_lower(value.public_key) - _UniffiConverterUInt32.check_lower(value.fingerprint) - _UniffiConverterUInt32.check_lower(value.depth) - _UniffiConverterOptionalString.check_lower(value.descriptor) + _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): - _UniffiConverterSequenceUInt32.write(value.path, buf) - _UniffiConverterString.write(value.serialized_path, buf) - _UniffiConverterString.write(value.xpub, buf) - _UniffiConverterOptionalString.write(value.xpub_segwit, buf) - _UniffiConverterString.write(value.chain_code, buf) - _UniffiConverterUInt32.write(value.child_num, buf) - _UniffiConverterString.write(value.public_key, buf) - _UniffiConverterUInt32.write(value.fingerprint, buf) - _UniffiConverterUInt32.write(value.depth, buf) - _UniffiConverterOptionalString.write(value.descriptor, 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 RefTransaction: +class TransactionDetails: """ - Reference transaction for transaction signing + Details about an onchain transaction. """ - hash: "str" + tx_id: "str" """ - Transaction hash + The transaction ID. """ - version: "typing.Optional[int]" + amount_sats: "int" """ - Transaction version + 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[RefTxInput]" + inputs: "typing.List[TxInput]" """ - Transaction inputs + The transaction inputs with full details. """ - bin_outputs: "typing.List[RefTxOutput]" + outputs: "typing.List[TxOutput]" """ - Transaction outputs (binary format) + The transaction outputs with full details. """ - lock_time: "typing.Optional[int]" - """ - Lock time - """ + def __init__(self, *, tx_id: "str", amount_sats: "int", inputs: "typing.List[TxInput]", outputs: "typing.List[TxOutput]"): + self.tx_id = tx_id + self.amount_sats = amount_sats + self.inputs = inputs + self.outputs = outputs - expiry: "typing.Optional[int]" - """ - Expiry (for Zcash/Decred) - """ + def __str__(self): + return "TransactionDetails(tx_id={}, amount_sats={}, inputs={}, outputs={})".format(self.tx_id, self.amount_sats, self.inputs, self.outputs) - version_group_id: "typing.Optional[int]" - """ - Version group ID (for Zcash) - """ + def __eq__(self, other): + if self.tx_id != other.tx_id: + return False + if self.amount_sats != other.amount_sats: + return False + if self.inputs != other.inputs: + return False + if self.outputs != other.outputs: + return False + return True - overwintered: "typing.Optional[bool]" - """ - Overwintered flag (for Zcash) - """ +class _UniffiConverterTypeTransactionDetails(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TransactionDetails( + 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.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.tx_id, buf) + _UniffiConverterInt64.write(value.amount_sats, buf) + _UniffiConverterSequenceTypeTxInput.write(value.inputs, buf) + _UniffiConverterSequenceTypeTxOutput.write(value.outputs, buf) - timestamp: "typing.Optional[int]" + +class TrezorAddressResponse: """ - Timestamp (for Capricoin) + Address response from device. """ - branch_id: "typing.Optional[int]" + address: "str" """ - Branch ID (for Zcash) + The Bitcoin address """ - extra_data: "typing.Optional[str]" + path: "str" """ - Extra data + The serialized path (e.g., "m/84'/0'/0'/0/0") """ - def __init__(self, *, hash: "str", version: "typing.Optional[int]", inputs: "typing.List[RefTxInput]", bin_outputs: "typing.List[RefTxOutput]", lock_time: "typing.Optional[int]", expiry: "typing.Optional[int]", version_group_id: "typing.Optional[int]", overwintered: "typing.Optional[bool]", timestamp: "typing.Optional[int]", branch_id: "typing.Optional[int]", extra_data: "typing.Optional[str]"): - self.hash = hash - self.version = version - self.inputs = inputs - self.bin_outputs = bin_outputs - self.lock_time = lock_time - self.expiry = expiry - self.version_group_id = version_group_id - self.overwintered = overwintered - self.timestamp = timestamp - self.branch_id = branch_id - self.extra_data = extra_data + def __init__(self, *, address: "str", path: "str"): + self.address = address + self.path = path def __str__(self): - return "RefTransaction(hash={}, version={}, inputs={}, bin_outputs={}, lock_time={}, expiry={}, version_group_id={}, overwintered={}, timestamp={}, branch_id={}, extra_data={})".format(self.hash, self.version, self.inputs, self.bin_outputs, self.lock_time, self.expiry, self.version_group_id, self.overwintered, self.timestamp, self.branch_id, self.extra_data) + 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.inputs != other.inputs: - return False - if self.bin_outputs != other.bin_outputs: - return False - if self.lock_time != other.lock_time: - return False - if self.expiry != other.expiry: - return False - if self.version_group_id != other.version_group_id: - return False - if self.overwintered != other.overwintered: - return False - if self.timestamp != other.timestamp: - return False - if self.branch_id != other.branch_id: + if self.address != other.address: return False - if self.extra_data != other.extra_data: + if self.path != other.path: return False return True -class _UniffiConverterTypeRefTransaction(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorAddressResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return RefTransaction( - hash=_UniffiConverterString.read(buf), - version=_UniffiConverterOptionalUInt32.read(buf), - inputs=_UniffiConverterSequenceTypeRefTxInput.read(buf), - bin_outputs=_UniffiConverterSequenceTypeRefTxOutput.read(buf), - lock_time=_UniffiConverterOptionalUInt32.read(buf), - expiry=_UniffiConverterOptionalUInt32.read(buf), - version_group_id=_UniffiConverterOptionalUInt32.read(buf), - overwintered=_UniffiConverterOptionalBool.read(buf), - timestamp=_UniffiConverterOptionalUInt32.read(buf), - branch_id=_UniffiConverterOptionalUInt32.read(buf), - extra_data=_UniffiConverterOptionalString.read(buf), + return TrezorAddressResponse( + address=_UniffiConverterString.read(buf), + path=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.hash) - _UniffiConverterOptionalUInt32.check_lower(value.version) - _UniffiConverterSequenceTypeRefTxInput.check_lower(value.inputs) - _UniffiConverterSequenceTypeRefTxOutput.check_lower(value.bin_outputs) - _UniffiConverterOptionalUInt32.check_lower(value.lock_time) - _UniffiConverterOptionalUInt32.check_lower(value.expiry) - _UniffiConverterOptionalUInt32.check_lower(value.version_group_id) - _UniffiConverterOptionalBool.check_lower(value.overwintered) - _UniffiConverterOptionalUInt32.check_lower(value.timestamp) - _UniffiConverterOptionalUInt32.check_lower(value.branch_id) - _UniffiConverterOptionalString.check_lower(value.extra_data) + _UniffiConverterString.check_lower(value.address) + _UniffiConverterString.check_lower(value.path) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.hash, buf) - _UniffiConverterOptionalUInt32.write(value.version, buf) - _UniffiConverterSequenceTypeRefTxInput.write(value.inputs, buf) - _UniffiConverterSequenceTypeRefTxOutput.write(value.bin_outputs, buf) - _UniffiConverterOptionalUInt32.write(value.lock_time, buf) - _UniffiConverterOptionalUInt32.write(value.expiry, buf) - _UniffiConverterOptionalUInt32.write(value.version_group_id, buf) - _UniffiConverterOptionalBool.write(value.overwintered, buf) - _UniffiConverterOptionalUInt32.write(value.timestamp, buf) - _UniffiConverterOptionalUInt32.write(value.branch_id, buf) - _UniffiConverterOptionalString.write(value.extra_data, buf) + _UniffiConverterString.write(value.address, buf) + _UniffiConverterString.write(value.path, buf) -class RefTxInput: +class TrezorCallMessageResult: """ - Reference transaction input + Result from a high-level message call (for BLE/THP devices) """ - prev_hash: "str" + success: "bool" """ - Previous transaction hash + Whether the call succeeded """ - prev_index: "int" + message_type: "int" """ - Previous transaction output index + Response message type """ - script_sig: "str" + data: "bytes" """ - Script signature + 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 + def __init__(self, *, success: "bool", message_type: "int", data: "bytes", error: "str"): + self.success = success + self.message_type = message_type + self.data = data + self.error = error def __str__(self): - return "RefTxInput(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={})".format(self.success, self.message_type, self.data, self.error) 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 return True -class _UniffiConverterTypeRefTxInput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorCallMessageResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return RefTxInput( - 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), ) @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) @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) -class RefTxOutput: +class TrezorDeviceInfo: """ - Reference transaction output (binary format) + Device information exposed to FFI. """ - amount: "int" + id: "str" """ - Amount in satoshis + Unique identifier for the device """ - script_pubkey: "str" + transport_type: "TrezorTransportType" """ - Script public key (binary hex) + 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) + """ + + path: "str" + """ + Transport-specific path (used internally for connection) + """ + + label: "typing.Optional[str]" + """ + Device label (set by user during device setup) + """ + + model: "typing.Optional[str]" + """ + Device model (e.g., "T2", "Safe 5", "Safe 7") + """ + + is_bootloader: "bool" + """ + Whether the device is in bootloader mode + """ + + 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 "RefTxOutput(amount={}, script_pubkey={})".format(self.amount, self.script_pubkey) + 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.amount != other.amount: + if self.id != other.id: return False - if self.script_pubkey != other.script_pubkey: + 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 _UniffiConverterTypeRefTxOutput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return RefTxOutput( - amount=_UniffiConverterUInt64.read(buf), - script_pubkey=_UniffiConverterString.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): - _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterString.check_lower(value.script_pubkey) + _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): - _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterString.write(value.script_pubkey, 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 RefundMemo: +class TrezorFeatures: """ - Refund memo + Device features after initialization. """ - address: "str" + vendor: "typing.Optional[str]" """ - Refund address + Vendor string """ - mac: "str" + model: "typing.Optional[str]" """ - MAC + Device model """ - def __init__(self, *, address: "str", mac: "str"): - self.address = address - self.mac = mac + label: "typing.Optional[str]" + """ + Device label (set by user during device setup) + """ + + device_id: "typing.Optional[str]" + """ + Device ID (unique per device) + """ + + major_version: "typing.Optional[int]" + """ + Major firmware version + """ + + minor_version: "typing.Optional[int]" + """ + Minor firmware version + """ + + patch_version: "typing.Optional[int]" + """ + Patch firmware version + """ + + pin_protection: "typing.Optional[bool]" + """ + Whether PIN protection is enabled + """ + + 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 + """ + + 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]", passphrase_protection: "typing.Optional[bool]", initialized: "typing.Optional[bool]", needs_backup: "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.passphrase_protection = passphrase_protection + self.initialized = initialized + self.needs_backup = needs_backup def __str__(self): - return "RefundMemo(address={}, mac={})".format(self.address, self.mac) + return "TrezorFeatures(vendor={}, model={}, label={}, device_id={}, major_version={}, minor_version={}, patch_version={}, pin_protection={}, passphrase_protection={}, initialized={}, needs_backup={})".format(self.vendor, self.model, self.label, self.device_id, self.major_version, self.minor_version, self.patch_version, self.pin_protection, self.passphrase_protection, self.initialized, self.needs_backup) def __eq__(self, other): - if self.address != other.address: + if self.vendor != other.vendor: + return False + if self.model != other.model: return False - if self.mac != other.mac: + if self.label != other.label: + return False + if self.device_id != other.device_id: + return False + if self.major_version != other.major_version: + return False + if self.minor_version != other.minor_version: + return False + if self.patch_version != other.patch_version: + return False + if self.pin_protection != other.pin_protection: + 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 return True -class _UniffiConverterTypeRefundMemo(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorFeatures(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return RefundMemo( - address=_UniffiConverterString.read(buf), - mac=_UniffiConverterString.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), + passphrase_protection=_UniffiConverterOptionalBool.read(buf), + initialized=_UniffiConverterOptionalBool.read(buf), + needs_backup=_UniffiConverterOptionalBool.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.mac) + _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.passphrase_protection) + _UniffiConverterOptionalBool.check_lower(value.initialized) + _UniffiConverterOptionalBool.check_lower(value.needs_backup) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.mac, 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.passphrase_protection, buf) + _UniffiConverterOptionalBool.write(value.initialized, buf) + _UniffiConverterOptionalBool.write(value.needs_backup, buf) -class SignedTransactionResponse: +class TrezorGetAddressParams: """ - Signed transaction response + Parameters for getting an address from the device. """ - signatures: "typing.List[str]" + path: "str" """ - Array of signer signatures + BIP32 path (e.g., "m/84'/0'/0'/0/0") """ - serialized_tx: "str" + coin: "typing.Optional[TrezorCoinType]" """ - Serialized transaction + Coin network (default: Bitcoin) """ - txid: "typing.Optional[str]" + show_on_trezor: "bool" """ - Broadcasted transaction ID (if push was true) + Whether to display the address on the 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 + 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 "SignedTransactionResponse(signatures={}, serialized_tx={}, txid={})".format(self.signatures, self.serialized_tx, self.txid) + 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.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 + if self.script_type != other.script_type: return False return True -class _UniffiConverterTypeSignedTransactionResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorGetAddressParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return SignedTransactionResponse( - signatures=_UniffiConverterSequenceString.read(buf), - serialized_tx=_UniffiConverterString.read(buf), - txid=_UniffiConverterOptionalString.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): - _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) + _UniffiConverterOptionalTypeTrezorScriptType.check_lower(value.script_type) @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) + _UniffiConverterOptionalTypeTrezorScriptType.write(value.script_type, buf) -class SweepResult: - txid: "str" +class TrezorGetPublicKeyParams: """ - The transaction ID of the sweep transaction + Parameters for getting a public key from the device. """ - amount_swept: "int" + path: "str" """ - The total amount swept (in satoshis) + BIP32 path (e.g., "m/84'/0'/0'") """ - fee_paid: "int" + coin: "typing.Optional[TrezorCoinType]" """ - The fee paid (in satoshis) + Coin network (default: Bitcoin) """ - utxos_swept: "int" + show_on_trezor: "bool" """ - The number of UTXOs swept + Whether to display on device for confirmation """ - 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 __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 "SweepResult(txid={}, amount_swept={}, fee_paid={}, utxos_swept={})".format(self.txid, self.amount_swept, self.fee_paid, self.utxos_swept) + return "TrezorGetPublicKeyParams(path={}, coin={}, show_on_trezor={})".format(self.path, self.coin, self.show_on_trezor) def __eq__(self, other): - if self.txid != other.txid: - return False - if self.amount_swept != other.amount_swept: + if self.path != other.path: return False - if self.fee_paid != other.fee_paid: + if self.coin != other.coin: return False - if self.utxos_swept != other.utxos_swept: + if self.show_on_trezor != other.show_on_trezor: return False return True -class _UniffiConverterTypeSweepResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorGetPublicKeyParams(_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 TrezorGetPublicKeyParams( + path=_UniffiConverterString.read(buf), + coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), + show_on_trezor=_UniffiConverterBool.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.path) + _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) + _UniffiConverterBool.check_lower(value.show_on_trezor) @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.path, buf) + _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) + _UniffiConverterBool.write(value.show_on_trezor, buf) -class SweepTransactionPreview: - psbt: "str" - """ - The PSBT (Partially Signed Bitcoin Transaction) in base64 format - """ - total_amount: "int" +class TrezorPrevTx: """ - The total amount available to sweep (in satoshis) + Previous transaction data (for non-SegWit input verification). """ - estimated_fee: "int" + hash: "str" """ - The estimated fee for the transaction (in satoshis) + Transaction hash (hex encoded) """ - estimated_vsize: "int" + version: "int" """ - The estimated virtual size of the transaction (in vbytes) + Transaction version """ - utxos_count: "int" + lock_time: "int" """ - The number of UTXOs that will be swept + Lock time """ - destination_address: "str" + inputs: "typing.List[TrezorPrevTxInput]" """ - The destination address + Transaction inputs """ - amount_after_fees: "int" + outputs: "typing.List[TrezorPrevTxOutput]" """ - The amount that will be sent to destination after fees (in satoshis) + Transaction outputs """ - 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, *, 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 "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 "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.psbt != other.psbt: - return False - if self.total_amount != other.total_amount: - return False - if self.estimated_fee != other.estimated_fee: + if self.hash != other.hash: return False - if self.estimated_vsize != other.estimated_vsize: + if self.version != other.version: return False - if self.utxos_count != other.utxos_count: + if self.lock_time != other.lock_time: return False - if self.destination_address != other.destination_address: + if self.inputs != other.inputs: return False - if self.amount_after_fees != other.amount_after_fees: + if self.outputs != other.outputs: return False return True -class _UniffiConverterTypeSweepTransactionPreview(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPrevTx(_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 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): - _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.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): - _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 SweepableBalances: - legacy_balance: "int" - """ - Balance in legacy (P2PKH) addresses (in satoshis) - """ - - p2sh_balance: "int" - """ - Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) - """ + _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) - taproot_balance: "int" - """ - Balance in Taproot (P2TR) addresses (in satoshis) - """ - total_balance: "int" +class TrezorPrevTxInput: """ - Total balance across all wallet types (in satoshis) + Input of a previous transaction. """ - legacy_utxos_count: "int" + prev_hash: "str" """ - Number of UTXOs in legacy wallet + Previous transaction hash (hex encoded) """ - p2sh_utxos_count: "int" + prev_index: "int" """ - Number of UTXOs in P2SH-SegWit wallet + Previous output index """ - taproot_utxos_count: "int" + script_sig: "str" """ - Number of UTXOs in Taproot wallet + Script signature (hex encoded) """ - total_utxos_count: "int" + sequence: "int" """ - Total number of UTXOs across all wallet types + Sequence number """ - 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, *, 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 "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 "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.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: - return False - if self.legacy_utxos_count != other.legacy_utxos_count: + if self.prev_hash != other.prev_hash: return False - if self.p2sh_utxos_count != other.p2sh_utxos_count: + if self.prev_index != other.prev_index: return False - if self.taproot_utxos_count != other.taproot_utxos_count: + if self.script_sig != other.script_sig: return False - if self.total_utxos_count != other.total_utxos_count: + if self.sequence != other.sequence: return False return True -class _UniffiConverterTypeSweepableBalances(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPrevTxInput(_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 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): - _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.prev_hash) + _UniffiConverterUInt32.check_lower(value.prev_index) + _UniffiConverterString.check_lower(value.script_sig) + _UniffiConverterUInt32.check_lower(value.sequence) @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.prev_hash, buf) + _UniffiConverterUInt32.write(value.prev_index, buf) + _UniffiConverterString.write(value.script_sig, buf) + _UniffiConverterUInt32.write(value.sequence, buf) + +class TrezorPrevTxOutput: + """ + Output of a previous transaction. + """ -class TextMemo: + amount: "int" """ - Text memo + Amount in satoshis """ - text: "str" + script_pubkey: "str" """ - Text content + Script pubkey (hex encoded) """ - def __init__(self, *, text: "str"): - self.text = text + def __init__(self, *, amount: "int", script_pubkey: "str"): + self.amount = amount + self.script_pubkey = script_pubkey def __str__(self): - return "TextMemo(text={})".format(self.text) + return "TrezorPrevTxOutput(amount={}, script_pubkey={})".format(self.amount, self.script_pubkey) def __eq__(self, other): - if self.text != other.text: + if self.amount != other.amount: + return False + if self.script_pubkey != other.script_pubkey: return False return True -class _UniffiConverterTypeTextMemo(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPrevTxOutput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TextMemo( - text=_UniffiConverterString.read(buf), + return TrezorPrevTxOutput( + amount=_UniffiConverterUInt64.read(buf), + script_pubkey=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.text) + _UniffiConverterUInt64.check_lower(value.amount) + _UniffiConverterString.check_lower(value.script_pubkey) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.text, buf) + _UniffiConverterUInt64.write(value.amount, buf) + _UniffiConverterString.write(value.script_pubkey, buf) -class TransactionDetails: +class TrezorPublicKeyResponse: """ - Details about an onchain transaction. + Public key response from device. """ - tx_id: "str" + xpub: "str" """ - The transaction ID. + Extended public key (xpub) """ - amount_sats: "int" + path: "str" """ - 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. + The serialized path (e.g., "m/84'/0'/0'") """ - inputs: "typing.List[TxInput]" + public_key: "str" """ - The transaction inputs with full details. + Compressed public key (hex encoded) """ - outputs: "typing.List[TxOutput]" + chain_code: "str" """ - The transaction outputs with full details. + Chain code (hex encoded) """ - def __init__(self, *, tx_id: "str", amount_sats: "int", inputs: "typing.List[TxInput]", outputs: "typing.List[TxOutput]"): - self.tx_id = tx_id - self.amount_sats = amount_sats - self.inputs = inputs - self.outputs = outputs + fingerprint: "int" + """ + Parent key fingerprint + """ + + depth: "int" + """ + Derivation depth + """ + + root_fingerprint: "typing.Optional[int]" + """ + Master root fingerprint (from the device's master seed) + """ + + 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.public_key = public_key + self.chain_code = chain_code + self.fingerprint = fingerprint + self.depth = depth + self.root_fingerprint = root_fingerprint def __str__(self): - return "TransactionDetails(tx_id={}, amount_sats={}, inputs={}, outputs={})".format(self.tx_id, self.amount_sats, self.inputs, self.outputs) + 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.tx_id != other.tx_id: + if self.xpub != other.xpub: return False - if self.amount_sats != other.amount_sats: + if self.path != other.path: return False - if self.inputs != other.inputs: + if self.public_key != other.public_key: return False - if self.outputs != other.outputs: + if self.chain_code != other.chain_code: + return False + if self.fingerprint != other.fingerprint: + return False + if self.depth != other.depth: + return False + if self.root_fingerprint != other.root_fingerprint: return False return True -class _UniffiConverterTypeTransactionDetails(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPublicKeyResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TransactionDetails( - tx_id=_UniffiConverterString.read(buf), - amount_sats=_UniffiConverterInt64.read(buf), - inputs=_UniffiConverterSequenceTypeTxInput.read(buf), - outputs=_UniffiConverterSequenceTypeTxOutput.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): - _UniffiConverterString.check_lower(value.tx_id) - _UniffiConverterInt64.check_lower(value.amount_sats) - _UniffiConverterSequenceTypeTxInput.check_lower(value.inputs) - _UniffiConverterSequenceTypeTxOutput.check_lower(value.outputs) + _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): - _UniffiConverterString.write(value.tx_id, buf) - _UniffiConverterInt64.write(value.amount_sats, buf) - _UniffiConverterSequenceTypeTxInput.write(value.inputs, buf) - _UniffiConverterSequenceTypeTxOutput.write(value.outputs, buf) - - -class TxAckPaymentRequest: - """ - Payment request - """ + _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) - nonce: "typing.Optional[str]" - """ - Nonce - """ - recipient_name: "str" +class TrezorSignMessageParams: """ - Recipient name + Parameters for signing a message. """ - memos: "typing.Optional[typing.List[PaymentRequestMemo]]" + path: "str" """ - Memos + BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") """ - amount: "typing.Optional[int]" + message: "str" """ - Amount + Message to sign """ - signature: "str" + coin: "typing.Optional[TrezorCoinType]" """ - Signature + Coin network (default: Bitcoin) """ - def __init__(self, *, nonce: "typing.Optional[str]", recipient_name: "str", memos: "typing.Optional[typing.List[PaymentRequestMemo]]", amount: "typing.Optional[int]", signature: "str"): - self.nonce = nonce - self.recipient_name = recipient_name - self.memos = memos - self.amount = amount - 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 "TxAckPaymentRequest(nonce={}, recipient_name={}, memos={}, amount={}, signature={})".format(self.nonce, self.recipient_name, self.memos, self.amount, self.signature) + return "TrezorSignMessageParams(path={}, message={}, coin={})".format(self.path, self.message, self.coin) def __eq__(self, other): - if self.nonce != other.nonce: - return False - if self.recipient_name != other.recipient_name: - return False - if self.memos != other.memos: + if self.path != other.path: return False - if self.amount != other.amount: + if self.message != other.message: return False - if self.signature != other.signature: + if self.coin != other.coin: return False return True -class _UniffiConverterTypeTxAckPaymentRequest(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorSignMessageParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TxAckPaymentRequest( - nonce=_UniffiConverterOptionalString.read(buf), - recipient_name=_UniffiConverterString.read(buf), - memos=_UniffiConverterOptionalSequenceTypePaymentRequestMemo.read(buf), - amount=_UniffiConverterOptionalUInt64.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): - _UniffiConverterOptionalString.check_lower(value.nonce) - _UniffiConverterString.check_lower(value.recipient_name) - _UniffiConverterOptionalSequenceTypePaymentRequestMemo.check_lower(value.memos) - _UniffiConverterOptionalUInt64.check_lower(value.amount) - _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): - _UniffiConverterOptionalString.write(value.nonce, buf) - _UniffiConverterString.write(value.recipient_name, buf) - _UniffiConverterOptionalSequenceTypePaymentRequestMemo.write(value.memos, buf) - _UniffiConverterOptionalUInt64.write(value.amount, buf) - _UniffiConverterString.write(value.signature, buf) + _UniffiConverterString.write(value.path, buf) + _UniffiConverterString.write(value.message, buf) + _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) -class TxInput: +class TrezorSignTxParams: """ - Details about a transaction input. + Parameters for signing a transaction. """ - txid: "str" + inputs: "typing.List[TrezorTxInput]" """ - The transaction ID of the previous output being spent. + Transaction inputs """ - vout: "int" + outputs: "typing.List[TrezorTxOutput]" """ - The output index of the previous output being spent. + Transaction outputs """ - scriptsig: "str" + coin: "typing.Optional[TrezorCoinType]" """ - The script signature (hex-encoded). + Coin network (default: Bitcoin) """ - witness: "typing.List[str]" + lock_time: "typing.Optional[int]" """ - The witness stack (hex-encoded strings). + Lock time (default: 0) """ - sequence: "int" + version: "typing.Optional[int]" """ - The sequence number. + Version (default: 2) """ - 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 + 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 "TxInput(txid={}, vout={}, scriptsig={}, witness={}, sequence={})".format(self.txid, self.vout, self.scriptsig, self.witness, self.sequence) + 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.scriptsig != other.scriptsig: + if self.coin != other.coin: return False - if self.witness != other.witness: + if self.lock_time != other.lock_time: return False - if self.sequence != other.sequence: + if self.version != other.version: + return False + if self.prev_txs != other.prev_txs: return False return True -class _UniffiConverterTypeTxInput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorSignTxParams(_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 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) - _UniffiConverterString.check_lower(value.scriptsig) - _UniffiConverterSequenceString.check_lower(value.witness) - _UniffiConverterUInt32.check_lower(value.sequence) + _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) - _UniffiConverterString.write(value.scriptsig, buf) - _UniffiConverterSequenceString.write(value.witness, buf) - _UniffiConverterUInt32.write(value.sequence, 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) -class TxInputType: +class TrezorSignedMessageResponse: """ - Transaction input type + Response from signing a message. """ - prev_hash: "str" + address: "str" """ - Previous transaction hash + Bitcoin address that signed the message """ - prev_index: "int" + signature: "str" """ - Previous transaction output index + Signature (base64 encoded) """ - amount: "int" - """ - Amount in satoshis - """ + def __init__(self, *, address: "str", signature: "str"): + self.address = address + self.signature = signature - sequence: "typing.Optional[int]" - """ - Transaction sequence - """ + def __str__(self): + return "TrezorSignedMessageResponse(address={}, signature={})".format(self.address, self.signature) - address_n: "typing.Optional[typing.List[int]]" - """ - BIP32 derivation path - """ + def __eq__(self, other): + if self.address != other.address: + return False + if self.signature != other.signature: + return False + return True - script_type: "typing.Optional[ScriptType]" - """ - Script type - """ +class _UniffiConverterTypeTrezorSignedMessageResponse(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TrezorSignedMessageResponse( + address=_UniffiConverterString.read(buf), + signature=_UniffiConverterString.read(buf), + ) - multisig: "typing.Optional[MultisigRedeemScriptType]" - """ - Multisig information - """ + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.address) + _UniffiConverterString.check_lower(value.signature) - script_pubkey: "typing.Optional[str]" - """ - Script public key (for external inputs) - """ + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.address, buf) + _UniffiConverterString.write(value.signature, buf) - script_sig: "typing.Optional[str]" + +class TrezorSignedTx: """ - Script signature + Signed transaction result. """ - witness: "typing.Optional[str]" + signatures: "typing.List[str]" """ - Witness data + Signatures for each input (hex encoded) """ - ownership_proof: "typing.Optional[str]" + serialized_tx: "str" """ - Ownership proof + Serialized transaction (hex) """ - commitment_data: "typing.Optional[str]" + def __init__(self, *, signatures: "typing.List[str]", serialized_tx: "str"): + self.signatures = signatures + self.serialized_tx = serialized_tx + + def __str__(self): + return "TrezorSignedTx(signatures={}, serialized_tx={})".format(self.signatures, self.serialized_tx) + + def __eq__(self, other): + if self.signatures != other.signatures: + return False + if self.serialized_tx != other.serialized_tx: + return False + return True + +class _UniffiConverterTypeTrezorSignedTx(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TrezorSignedTx( + signatures=_UniffiConverterSequenceString.read(buf), + serialized_tx=_UniffiConverterString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterSequenceString.check_lower(value.signatures) + _UniffiConverterString.check_lower(value.serialized_tx) + + @staticmethod + def write(value, buf): + _UniffiConverterSequenceString.write(value.signatures, buf) + _UniffiConverterString.write(value.serialized_tx, buf) + + +class TrezorTransportReadResult: """ - Commitment data + Result from a transport read operation """ - orig_hash: "typing.Optional[str]" + success: "bool" """ - Original hash for RBF + Whether the read succeeded """ - orig_index: "typing.Optional[int]" + data: "bytes" """ - Original index for RBF + Data read (empty on failure) """ - coinjoin_flags: "typing.Optional[int]" + error: "str" """ - Coinjoin flags + Error message (empty on success) """ - def __init__(self, *, prev_hash: "str", prev_index: "int", amount: "int", sequence: "typing.Optional[int]", address_n: "typing.Optional[typing.List[int]]", script_type: "typing.Optional[ScriptType]", multisig: "typing.Optional[MultisigRedeemScriptType]", script_pubkey: "typing.Optional[str]", script_sig: "typing.Optional[str]", witness: "typing.Optional[str]", ownership_proof: "typing.Optional[str]", commitment_data: "typing.Optional[str]", orig_hash: "typing.Optional[str]", orig_index: "typing.Optional[int]", coinjoin_flags: "typing.Optional[int]"): - self.prev_hash = prev_hash - self.prev_index = prev_index - self.amount = amount - self.sequence = sequence - self.address_n = address_n - self.script_type = script_type - self.multisig = multisig - self.script_pubkey = script_pubkey - self.script_sig = script_sig - self.witness = witness - self.ownership_proof = ownership_proof - self.commitment_data = commitment_data - self.orig_hash = orig_hash - self.orig_index = orig_index - self.coinjoin_flags = coinjoin_flags + def __init__(self, *, success: "bool", data: "bytes", error: "str"): + self.success = success + self.data = data + self.error = error def __str__(self): - return "TxInputType(prev_hash={}, prev_index={}, amount={}, sequence={}, address_n={}, script_type={}, multisig={}, script_pubkey={}, script_sig={}, witness={}, ownership_proof={}, commitment_data={}, orig_hash={}, orig_index={}, coinjoin_flags={})".format(self.prev_hash, self.prev_index, self.amount, self.sequence, self.address_n, self.script_type, self.multisig, self.script_pubkey, self.script_sig, self.witness, self.ownership_proof, self.commitment_data, self.orig_hash, self.orig_index, self.coinjoin_flags) + return "TrezorTransportReadResult(success={}, data={}, error={})".format(self.success, self.data, self.error) 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: - return False - if self.amount != other.amount: - return False - if self.sequence != other.sequence: - return False - if self.address_n != other.address_n: + if self.data != other.data: return False - if self.script_type != other.script_type: - return False - if self.multisig != other.multisig: - return False - if self.script_pubkey != other.script_pubkey: - return False - if self.script_sig != other.script_sig: - return False - if self.witness != other.witness: - return False - if self.ownership_proof != other.ownership_proof: - return False - if self.commitment_data != other.commitment_data: - return False - if self.orig_hash != other.orig_hash: - return False - if self.orig_index != other.orig_index: - return False - if self.coinjoin_flags != other.coinjoin_flags: + if self.error != other.error: return False return True -class _UniffiConverterTypeTxInputType(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTransportReadResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TxInputType( - prev_hash=_UniffiConverterString.read(buf), - prev_index=_UniffiConverterUInt32.read(buf), - amount=_UniffiConverterUInt64.read(buf), - sequence=_UniffiConverterOptionalUInt32.read(buf), - address_n=_UniffiConverterOptionalSequenceUInt32.read(buf), - script_type=_UniffiConverterOptionalTypeScriptType.read(buf), - multisig=_UniffiConverterOptionalTypeMultisigRedeemScriptType.read(buf), - script_pubkey=_UniffiConverterOptionalString.read(buf), - script_sig=_UniffiConverterOptionalString.read(buf), - witness=_UniffiConverterOptionalString.read(buf), - ownership_proof=_UniffiConverterOptionalString.read(buf), - commitment_data=_UniffiConverterOptionalString.read(buf), - orig_hash=_UniffiConverterOptionalString.read(buf), - orig_index=_UniffiConverterOptionalUInt32.read(buf), - coinjoin_flags=_UniffiConverterOptionalUInt32.read(buf), + return TrezorTransportReadResult( + success=_UniffiConverterBool.read(buf), + data=_UniffiConverterBytes.read(buf), + error=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.prev_hash) - _UniffiConverterUInt32.check_lower(value.prev_index) - _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterOptionalUInt32.check_lower(value.sequence) - _UniffiConverterOptionalSequenceUInt32.check_lower(value.address_n) - _UniffiConverterOptionalTypeScriptType.check_lower(value.script_type) - _UniffiConverterOptionalTypeMultisigRedeemScriptType.check_lower(value.multisig) - _UniffiConverterOptionalString.check_lower(value.script_pubkey) - _UniffiConverterOptionalString.check_lower(value.script_sig) - _UniffiConverterOptionalString.check_lower(value.witness) - _UniffiConverterOptionalString.check_lower(value.ownership_proof) - _UniffiConverterOptionalString.check_lower(value.commitment_data) - _UniffiConverterOptionalString.check_lower(value.orig_hash) - _UniffiConverterOptionalUInt32.check_lower(value.orig_index) - _UniffiConverterOptionalUInt32.check_lower(value.coinjoin_flags) + _UniffiConverterBool.check_lower(value.success) + _UniffiConverterBytes.check_lower(value.data) + _UniffiConverterString.check_lower(value.error) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.prev_hash, buf) - _UniffiConverterUInt32.write(value.prev_index, buf) - _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterOptionalUInt32.write(value.sequence, buf) - _UniffiConverterOptionalSequenceUInt32.write(value.address_n, buf) - _UniffiConverterOptionalTypeScriptType.write(value.script_type, buf) - _UniffiConverterOptionalTypeMultisigRedeemScriptType.write(value.multisig, buf) - _UniffiConverterOptionalString.write(value.script_pubkey, buf) - _UniffiConverterOptionalString.write(value.script_sig, buf) - _UniffiConverterOptionalString.write(value.witness, buf) - _UniffiConverterOptionalString.write(value.ownership_proof, buf) - _UniffiConverterOptionalString.write(value.commitment_data, buf) - _UniffiConverterOptionalString.write(value.orig_hash, buf) - _UniffiConverterOptionalUInt32.write(value.orig_index, buf) - _UniffiConverterOptionalUInt32.write(value.coinjoin_flags, buf) + _UniffiConverterBool.write(value.success, buf) + _UniffiConverterBytes.write(value.data, buf) + _UniffiConverterString.write(value.error, 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]" +class TrezorTransportWriteResult: """ - The address corresponding to this script (if decodable). + Result from a transport write or open operation """ - value: "int" + success: "bool" """ - The value in satoshis. + Whether the operation succeeded """ - n: "int" + error: "str" """ - The output index in the transaction. + Error message (empty on success) """ - 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", error: "str"): + self.success = success + self.error = error 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 "TrezorTransportWriteResult(success={}, error={})".format(self.success, self.error) 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: + if self.success != other.success: return False - if self.n != other.n: + if self.error != other.error: return False return True -class _UniffiConverterTypeTxOutput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTransportWriteResult(_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 TrezorTransportWriteResult( + success=_UniffiConverterBool.read(buf), + error=_UniffiConverterString.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) + _UniffiConverterString.check_lower(value.error) @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) + _UniffiConverterString.write(value.error, buf) -class TxOutputType: +class TrezorTxInput: """ - Transaction output type + Transaction input for signing. """ - address: "typing.Optional[str]" + prev_hash: "str" + """ + Previous transaction hash (hex, 32 bytes) """ - Output address (for address outputs) + + prev_index: "int" + """ + Previous output index """ - address_n: "typing.Optional[typing.List[int]]" + path: "str" """ - BIP32 derivation path (for change outputs) + BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") """ amount: "int" @@ -8181,359 +7404,471 @@ class TxOutputType: Amount in satoshis """ - script_type: "ScriptType" + script_type: "TrezorScriptType" """ Script type """ - multisig: "typing.Optional[MultisigRedeemScriptType]" - """ - Multisig information - """ - - op_return_data: "typing.Optional[str]" + sequence: "typing.Optional[int]" """ - OP_RETURN data + Sequence number (default: 0xFFFFFFFD for RBF) """ orig_hash: "typing.Optional[str]" """ - Original hash for RBF + Original transaction hash for RBF replacement (hex encoded) """ orig_index: "typing.Optional[int]" """ - Original index for RBF - """ - - payment_req_index: "typing.Optional[int]" - """ - Payment request index + Original input index for RBF replacement """ - def __init__(self, *, address: "typing.Optional[str]", address_n: "typing.Optional[typing.List[int]]", amount: "int", script_type: "ScriptType", multisig: "typing.Optional[MultisigRedeemScriptType]", op_return_data: "typing.Optional[str]", orig_hash: "typing.Optional[str]", orig_index: "typing.Optional[int]", payment_req_index: "typing.Optional[int]"): - self.address = address - self.address_n = address_n + 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.multisig = multisig - self.op_return_data = op_return_data + self.sequence = sequence self.orig_hash = orig_hash self.orig_index = orig_index - self.payment_req_index = payment_req_index def __str__(self): - return "TxOutputType(address={}, address_n={}, amount={}, script_type={}, multisig={}, op_return_data={}, orig_hash={}, orig_index={}, payment_req_index={})".format(self.address, self.address_n, self.amount, self.script_type, self.multisig, self.op_return_data, self.orig_hash, self.orig_index, self.payment_req_index) + 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.address != other.address: + if self.prev_hash != other.prev_hash: + return False + if self.prev_index != other.prev_index: return False - if self.address_n != other.address_n: + 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.multisig != other.multisig: - return False - if self.op_return_data != other.op_return_data: + 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 - if self.payment_req_index != other.payment_req_index: - return False return True -class _UniffiConverterTypeTxOutputType(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTxInput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TxOutputType( - address=_UniffiConverterOptionalString.read(buf), - address_n=_UniffiConverterOptionalSequenceUInt32.read(buf), + return TrezorTxInput( + prev_hash=_UniffiConverterString.read(buf), + prev_index=_UniffiConverterUInt32.read(buf), + path=_UniffiConverterString.read(buf), amount=_UniffiConverterUInt64.read(buf), - script_type=_UniffiConverterTypeScriptType.read(buf), - multisig=_UniffiConverterOptionalTypeMultisigRedeemScriptType.read(buf), - op_return_data=_UniffiConverterOptionalString.read(buf), + script_type=_UniffiConverterTypeTrezorScriptType.read(buf), + sequence=_UniffiConverterOptionalUInt32.read(buf), orig_hash=_UniffiConverterOptionalString.read(buf), orig_index=_UniffiConverterOptionalUInt32.read(buf), - payment_req_index=_UniffiConverterOptionalUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterOptionalString.check_lower(value.address) - _UniffiConverterOptionalSequenceUInt32.check_lower(value.address_n) + _UniffiConverterString.check_lower(value.prev_hash) + _UniffiConverterUInt32.check_lower(value.prev_index) + _UniffiConverterString.check_lower(value.path) _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterTypeScriptType.check_lower(value.script_type) - _UniffiConverterOptionalTypeMultisigRedeemScriptType.check_lower(value.multisig) - _UniffiConverterOptionalString.check_lower(value.op_return_data) + _UniffiConverterTypeTrezorScriptType.check_lower(value.script_type) + _UniffiConverterOptionalUInt32.check_lower(value.sequence) _UniffiConverterOptionalString.check_lower(value.orig_hash) _UniffiConverterOptionalUInt32.check_lower(value.orig_index) - _UniffiConverterOptionalUInt32.check_lower(value.payment_req_index) @staticmethod def write(value, buf): - _UniffiConverterOptionalString.write(value.address, buf) - _UniffiConverterOptionalSequenceUInt32.write(value.address_n, buf) + _UniffiConverterString.write(value.prev_hash, buf) + _UniffiConverterUInt32.write(value.prev_index, buf) + _UniffiConverterString.write(value.path, buf) _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterTypeScriptType.write(value.script_type, buf) - _UniffiConverterOptionalTypeMultisigRedeemScriptType.write(value.multisig, buf) - _UniffiConverterOptionalString.write(value.op_return_data, buf) + _UniffiConverterTypeTrezorScriptType.write(value.script_type, buf) + _UniffiConverterOptionalUInt32.write(value.sequence, buf) _UniffiConverterOptionalString.write(value.orig_hash, buf) _UniffiConverterOptionalUInt32.write(value.orig_index, buf) - _UniffiConverterOptionalUInt32.write(value.payment_req_index, buf) -class UnlockPath: +class TrezorTxOutput: """ - Unlock Path parameters + Transaction output for signing. """ - address_n: "typing.List[int]" + address: "typing.Optional[str]" """ - BIP32 derivation path + Destination address (for external outputs) """ - mac: "typing.Optional[str]" + path: "typing.Optional[str]" """ - MAC (optional) + BIP32 path (for change outputs) """ - def __init__(self, *, address_n: "typing.List[int]", mac: "typing.Optional[str]"): - self.address_n = address_n - self.mac = mac - - def __str__(self): - return "UnlockPath(address_n={}, mac={})".format(self.address_n, self.mac) - - def __eq__(self, other): - if self.address_n != other.address_n: - return False - if self.mac != other.mac: - return False - return True + amount: "int" + """ + Amount in satoshis + """ -class _UniffiConverterTypeUnlockPath(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return UnlockPath( - address_n=_UniffiConverterSequenceUInt32.read(buf), - mac=_UniffiConverterOptionalString.read(buf), - ) + script_type: "typing.Optional[TrezorScriptType]" + """ + Script type (for change outputs) + """ - @staticmethod - def check_lower(value): - _UniffiConverterSequenceUInt32.check_lower(value.address_n) - _UniffiConverterOptionalString.check_lower(value.mac) + op_return_data: "typing.Optional[str]" + """ + OP_RETURN data (hex encoded, for data outputs) + """ - @staticmethod - def write(value, buf): - _UniffiConverterSequenceUInt32.write(value.address_n, buf) - _UniffiConverterOptionalString.write(value.mac, buf) + orig_hash: "typing.Optional[str]" + """ + Original transaction hash for RBF replacement (hex encoded) + """ + orig_index: "typing.Optional[int]" + """ + Original output index for RBF replacement + """ -class ValidationResult: - address: "str" - network: "NetworkType" - address_type: "AddressType" - def __init__(self, *, address: "str", network: "NetworkType", address_type: "AddressType"): + 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.network = network - self.address_type = address_type + 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 "ValidationResult(address={}, network={}, address_type={})".format(self.address, self.network, self.address_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.address != other.address: return False - if self.network != other.network: + if self.path != other.path: return False - if self.address_type != other.address_type: + if self.amount != other.amount: + return False + if self.script_type != other.script_type: + return False + 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 _UniffiConverterTypeValidationResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTxOutput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return ValidationResult( - address=_UniffiConverterString.read(buf), - network=_UniffiConverterTypeNetworkType.read(buf), - address_type=_UniffiConverterTypeAddressType.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.address) - _UniffiConverterTypeNetworkType.check_lower(value.network) - _UniffiConverterTypeAddressType.check_lower(value.address_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.address, buf) - _UniffiConverterTypeNetworkType.write(value.network, buf) - _UniffiConverterTypeAddressType.write(value.address_type, 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) + + +class TrezorVerifyMessageParams: + """ + Parameters for verifying a message signature. + """ + address: "str" + """ + Bitcoin address that signed the message + """ -class VerifyMessageResponse: + signature: "str" """ - Verify message response + Signature (base64 encoded) """ message: "str" """ - Verification result message + Original message """ - def __init__(self, *, message: "str"): + coin: "typing.Optional[TrezorCoinType]" + """ + Coin network (default: Bitcoin) + """ + + 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 "VerifyMessageResponse(message={})".format(self.message) + return "TrezorVerifyMessageParams(address={}, signature={}, message={}, coin={})".format(self.address, self.signature, self.message, self.coin) def __eq__(self, other): + if self.address != other.address: + return False + if self.signature != other.signature: + return False if self.message != other.message: return False + if self.coin != other.coin: + return False return True -class _UniffiConverterTypeVerifyMessageResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorVerifyMessageParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return VerifyMessageResponse( + 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.address) + _UniffiConverterString.check_lower(value.signature) _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.message, buf) + _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) -class XrpMarker: +class TxInput: """ - Marker object for XRP accounts + Details about a transaction input. """ - ledger: "int" + txid: "str" """ - Ledger number + The transaction ID of the previous output being spent. """ - seq: "int" + vout: "int" """ - Sequence number + The output index of the previous output being spent. """ - def __init__(self, *, ledger: "int", seq: "int"): - self.ledger = ledger - self.seq = seq + scriptsig: "str" + """ + The script signature (hex-encoded). + """ - def __str__(self): - return "XrpMarker(ledger={}, seq={})".format(self.ledger, self.seq) + witness: "typing.List[str]" + """ + The witness stack (hex-encoded strings). + """ + + sequence: "int" + """ + 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) def __eq__(self, other): - if self.ledger != other.ledger: + if self.txid != other.txid: + return False + if self.vout != other.vout: + return False + if self.scriptsig != other.scriptsig: return False - if self.seq != other.seq: + if self.witness != other.witness: + return False + if self.sequence != other.sequence: return False return True -class _UniffiConverterTypeXrpMarker(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTxInput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return XrpMarker( - ledger=_UniffiConverterUInt64.read(buf), - seq=_UniffiConverterUInt64.read(buf), + 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): - _UniffiConverterUInt64.check_lower(value.ledger) - _UniffiConverterUInt64.check_lower(value.seq) + _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): - _UniffiConverterUInt64.write(value.ledger, buf) - _UniffiConverterUInt64.write(value.seq, 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) +class TxOutput: + """ + Details about a transaction output. + """ -class AccountInfoDetails(enum.Enum): + scriptpubkey: "str" """ - Level of details to be returned by getAccountInfo + The script public key (hex-encoded). """ - BASIC = 0 + scriptpubkey_type: "typing.Optional[str]" """ - Return only account balances (default) + The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). """ - - TOKENS = 1 + scriptpubkey_address: "typing.Optional[str]" """ - Return with derived addresses or ERC20 tokens + The address corresponding to this script (if decodable). """ - - TOKEN_BALANCES = 2 + value: "int" """ - Same as tokens with balances + The value in satoshis. """ - - TXS = 3 + n: "int" """ - TokenBalances + complete account transaction history + The output index in the transaction. """ - + 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 __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 __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 -class _UniffiConverterTypeAccountInfoDetails(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTxOutput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - variant = buf.read_i32() - if variant == 1: - return AccountInfoDetails.BASIC - if variant == 2: - return AccountInfoDetails.TOKENS - if variant == 3: - return AccountInfoDetails.TOKEN_BALANCES - if variant == 4: - return AccountInfoDetails.TXS - raise InternalError("Raw enum value doesn't match any cases") + return TxOutput( + scriptpubkey=_UniffiConverterString.read(buf), + scriptpubkey_type=_UniffiConverterOptionalString.read(buf), + scriptpubkey_address=_UniffiConverterOptionalString.read(buf), + value=_UniffiConverterInt64.read(buf), + n=_UniffiConverterUInt32.read(buf), + ) @staticmethod def check_lower(value): - if value == AccountInfoDetails.BASIC: - return - if value == AccountInfoDetails.TOKENS: - return - if value == AccountInfoDetails.TOKEN_BALANCES: - return - if value == AccountInfoDetails.TXS: - return - raise ValueError(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) @staticmethod def write(value, buf): - if value == AccountInfoDetails.BASIC: - buf.write_i32(1) - if value == AccountInfoDetails.TOKENS: - buf.write_i32(2) - if value == AccountInfoDetails.TOKEN_BALANCES: - buf.write_i32(3) - if value == AccountInfoDetails.TXS: - buf.write_i32(4) + _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) + + +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), + ) + + @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) @@ -9076,64 +8411,6 @@ def write(value, buf): -class AmountUnit(enum.Enum): - """ - Amount unit for display - """ - - BITCOIN = 0 - - MILLI_BITCOIN = 1 - - MICRO_BITCOIN = 2 - - SATOSHI = 3 - - - -class _UniffiConverterTypeAmountUnit(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return AmountUnit.BITCOIN - if variant == 2: - return AmountUnit.MILLI_BITCOIN - if variant == 3: - return AmountUnit.MICRO_BITCOIN - if variant == 4: - return AmountUnit.SATOSHI - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value == AmountUnit.BITCOIN: - return - if value == AmountUnit.MILLI_BITCOIN: - return - if value == AmountUnit.MICRO_BITCOIN: - return - if value == AmountUnit.SATOSHI: - return - raise ValueError(value) - - @staticmethod - def write(value, buf): - if value == AmountUnit.BITCOIN: - buf.write_i32(1) - if value == AmountUnit.MILLI_BITCOIN: - buf.write_i32(2) - if value == AmountUnit.MICRO_BITCOIN: - buf.write_i32(3) - if value == AmountUnit.SATOSHI: - buf.write_i32(4) - - - - - - - class BitcoinNetworkEnum(enum.Enum): MAINNET = 0 @@ -9928,399 +9205,51 @@ def write(value, buf): +# DbError +# 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 DbError(Exception): + pass +_UniffiTempDbError = DbError +class DbError: # type: ignore + class DbActivityError(_UniffiTempDbError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details -class ComposeOutput: - """ - Output type for compose transaction - """ - - def __init__(self): - raise RuntimeError("ComposeOutput cannot be instantiated directly") - - # Each enum variant is a nested class of the enum itself. - class REGULAR: - """ - Regular output with amount and address - """ - - amount: "str" - """ - Amount in satoshis - """ + def __repr__(self): + return "DbError.DbActivityError({})".format(str(self)) + _UniffiTempDbError.DbActivityError = DbActivityError # type: ignore + class DbBlocktankError(_UniffiTempDbError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - address: "str" - """ - Recipient address - """ + def __repr__(self): + return "DbError.DbBlocktankError({})".format(str(self)) + _UniffiTempDbError.DbBlocktankError = DbBlocktankError # type: ignore + class InitializationError(_UniffiTempDbError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "DbError.InitializationError({})".format(str(self)) + _UniffiTempDbError.InitializationError = InitializationError # type: ignore - def __init__(self,amount: "str", address: "str"): - self.amount = amount - self.address = address - - def __str__(self): - return "ComposeOutput.REGULAR(amount={}, address={})".format(self.amount, self.address) - - def __eq__(self, other): - if not other.is_REGULAR(): - return False - if self.amount != other.amount: - return False - if self.address != other.address: - return False - return True - - class SEND_MAX: - """ - Send max output - """ - - address: "str" - """ - Recipient address - """ - - - def __init__(self,address: "str"): - self.address = address - - def __str__(self): - return "ComposeOutput.SEND_MAX(address={})".format(self.address) - - def __eq__(self, other): - if not other.is_SEND_MAX(): - return False - if self.address != other.address: - return False - return True - - class OP_RETURN: - """ - OP_RETURN output - """ - - data_hex: "str" - """ - Hexadecimal string with arbitrary data - """ - - - def __init__(self,data_hex: "str"): - self.data_hex = data_hex - - def __str__(self): - return "ComposeOutput.OP_RETURN(data_hex={})".format(self.data_hex) - - def __eq__(self, other): - if not other.is_OP_RETURN(): - return False - if self.data_hex != other.data_hex: - return False - return True - - class PAYMENT_NO_ADDRESS: - """ - Payment without address (precompose only) - """ - - amount: "str" - """ - Amount in satoshis - """ - - - def __init__(self,amount: "str"): - self.amount = amount - - def __str__(self): - return "ComposeOutput.PAYMENT_NO_ADDRESS(amount={})".format(self.amount) - - def __eq__(self, other): - if not other.is_PAYMENT_NO_ADDRESS(): - return False - if self.amount != other.amount: - return False - return True - - class SEND_MAX_NO_ADDRESS: - """ - Send max without address (precompose only) - """ - - - def __init__(self,): - pass - - def __str__(self): - return "ComposeOutput.SEND_MAX_NO_ADDRESS()".format() - - def __eq__(self, other): - if not other.is_SEND_MAX_NO_ADDRESS(): - 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_REGULAR(self) -> bool: - return isinstance(self, ComposeOutput.REGULAR) - def is_regular(self) -> bool: - return isinstance(self, ComposeOutput.REGULAR) - def is_SEND_MAX(self) -> bool: - return isinstance(self, ComposeOutput.SEND_MAX) - def is_send_max(self) -> bool: - return isinstance(self, ComposeOutput.SEND_MAX) - def is_OP_RETURN(self) -> bool: - return isinstance(self, ComposeOutput.OP_RETURN) - def is_op_return(self) -> bool: - return isinstance(self, ComposeOutput.OP_RETURN) - def is_PAYMENT_NO_ADDRESS(self) -> bool: - return isinstance(self, ComposeOutput.PAYMENT_NO_ADDRESS) - def is_payment_no_address(self) -> bool: - return isinstance(self, ComposeOutput.PAYMENT_NO_ADDRESS) - def is_SEND_MAX_NO_ADDRESS(self) -> bool: - return isinstance(self, ComposeOutput.SEND_MAX_NO_ADDRESS) - def is_send_max_no_address(self) -> bool: - return isinstance(self, ComposeOutput.SEND_MAX_NO_ADDRESS) - - -# 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. -ComposeOutput.REGULAR = type("ComposeOutput.REGULAR", (ComposeOutput.REGULAR, ComposeOutput,), {}) # type: ignore -ComposeOutput.SEND_MAX = type("ComposeOutput.SEND_MAX", (ComposeOutput.SEND_MAX, ComposeOutput,), {}) # type: ignore -ComposeOutput.OP_RETURN = type("ComposeOutput.OP_RETURN", (ComposeOutput.OP_RETURN, ComposeOutput,), {}) # type: ignore -ComposeOutput.PAYMENT_NO_ADDRESS = type("ComposeOutput.PAYMENT_NO_ADDRESS", (ComposeOutput.PAYMENT_NO_ADDRESS, ComposeOutput,), {}) # type: ignore -ComposeOutput.SEND_MAX_NO_ADDRESS = type("ComposeOutput.SEND_MAX_NO_ADDRESS", (ComposeOutput.SEND_MAX_NO_ADDRESS, ComposeOutput,), {}) # type: ignore - - - - -class _UniffiConverterTypeComposeOutput(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return ComposeOutput.REGULAR( - _UniffiConverterString.read(buf), - _UniffiConverterString.read(buf), - ) - if variant == 2: - return ComposeOutput.SEND_MAX( - _UniffiConverterString.read(buf), - ) - if variant == 3: - return ComposeOutput.OP_RETURN( - _UniffiConverterString.read(buf), - ) - if variant == 4: - return ComposeOutput.PAYMENT_NO_ADDRESS( - _UniffiConverterString.read(buf), - ) - if variant == 5: - return ComposeOutput.SEND_MAX_NO_ADDRESS( - ) - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value.is_REGULAR(): - _UniffiConverterString.check_lower(value.amount) - _UniffiConverterString.check_lower(value.address) - return - if value.is_SEND_MAX(): - _UniffiConverterString.check_lower(value.address) - return - if value.is_OP_RETURN(): - _UniffiConverterString.check_lower(value.data_hex) - return - if value.is_PAYMENT_NO_ADDRESS(): - _UniffiConverterString.check_lower(value.amount) - return - if value.is_SEND_MAX_NO_ADDRESS(): - return - raise ValueError(value) - - @staticmethod - def write(value, buf): - if value.is_REGULAR(): - buf.write_i32(1) - _UniffiConverterString.write(value.amount, buf) - _UniffiConverterString.write(value.address, buf) - if value.is_SEND_MAX(): - buf.write_i32(2) - _UniffiConverterString.write(value.address, buf) - if value.is_OP_RETURN(): - buf.write_i32(3) - _UniffiConverterString.write(value.data_hex, buf) - if value.is_PAYMENT_NO_ADDRESS(): - buf.write_i32(4) - _UniffiConverterString.write(value.amount, buf) - if value.is_SEND_MAX_NO_ADDRESS(): - buf.write_i32(5) - - - - - - - -class ComposeTransactionResponse: - """ - Compose transaction response - """ - - def __init__(self): - raise RuntimeError("ComposeTransactionResponse cannot be instantiated directly") - - # Each enum variant is a nested class of the enum itself. - class SIGNED_TRANSACTION: - """ - Signed transaction (payment mode) - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"ComposeTransactionResponse.SIGNED_TRANSACTION{self._values!r}" - - def __eq__(self, other): - if not other.is_SIGNED_TRANSACTION(): - return False - return self._values == other._values - class PRECOMPOSED_TRANSACTIONS: - """ - Precomposed transactions (precompose mode) - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"ComposeTransactionResponse.PRECOMPOSED_TRANSACTIONS{self._values!r}" - - def __eq__(self, other): - if not other.is_PRECOMPOSED_TRANSACTIONS(): - 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_SIGNED_TRANSACTION(self) -> bool: - return isinstance(self, ComposeTransactionResponse.SIGNED_TRANSACTION) - def is_signed_transaction(self) -> bool: - return isinstance(self, ComposeTransactionResponse.SIGNED_TRANSACTION) - def is_PRECOMPOSED_TRANSACTIONS(self) -> bool: - return isinstance(self, ComposeTransactionResponse.PRECOMPOSED_TRANSACTIONS) - def is_precomposed_transactions(self) -> bool: - return isinstance(self, ComposeTransactionResponse.PRECOMPOSED_TRANSACTIONS) - - -# 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. -ComposeTransactionResponse.SIGNED_TRANSACTION = type("ComposeTransactionResponse.SIGNED_TRANSACTION", (ComposeTransactionResponse.SIGNED_TRANSACTION, ComposeTransactionResponse,), {}) # type: ignore -ComposeTransactionResponse.PRECOMPOSED_TRANSACTIONS = type("ComposeTransactionResponse.PRECOMPOSED_TRANSACTIONS", (ComposeTransactionResponse.PRECOMPOSED_TRANSACTIONS, ComposeTransactionResponse,), {}) # type: ignore - - - - -class _UniffiConverterTypeComposeTransactionResponse(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return ComposeTransactionResponse.SIGNED_TRANSACTION( - _UniffiConverterTypeSignedTransactionResponse.read(buf), - ) - if variant == 2: - return ComposeTransactionResponse.PRECOMPOSED_TRANSACTIONS( - _UniffiConverterSequenceTypePrecomposedTransaction.read(buf), - ) - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value.is_SIGNED_TRANSACTION(): - _UniffiConverterTypeSignedTransactionResponse.check_lower(value._values[0]) - return - if value.is_PRECOMPOSED_TRANSACTIONS(): - _UniffiConverterSequenceTypePrecomposedTransaction.check_lower(value._values[0]) - return - raise ValueError(value) - - @staticmethod - def write(value, buf): - if value.is_SIGNED_TRANSACTION(): - buf.write_i32(1) - _UniffiConverterTypeSignedTransactionResponse.write(value._values[0], buf) - if value.is_PRECOMPOSED_TRANSACTIONS(): - buf.write_i32(2) - _UniffiConverterSequenceTypePrecomposedTransaction.write(value._values[0], buf) - - - - -# DbError -# 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 DbError(Exception): - pass - -_UniffiTempDbError = DbError - -class DbError: # type: ignore - class DbActivityError(_UniffiTempDbError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - - def __repr__(self): - return "DbError.DbActivityError({})".format(str(self)) - _UniffiTempDbError.DbActivityError = DbActivityError # type: ignore - class DbBlocktankError(_UniffiTempDbError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - - def __repr__(self): - return "DbError.DbBlocktankError({})".format(str(self)) - _UniffiTempDbError.DbBlocktankError = DbBlocktankError # type: ignore - class InitializationError(_UniffiTempDbError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - - def __repr__(self): - return "DbError.InitializationError({})".format(str(self)) - _UniffiTempDbError.InitializationError = InitializationError # type: ignore - -DbError = _UniffiTempDbError # type: ignore -del _UniffiTempDbError +DbError = _UniffiTempDbError # type: ignore +del _UniffiTempDbError class _UniffiConverterTypeDbError(_UniffiConverterRustBuffer): @@ -10586,194 +9515,21 @@ def write(value, buf): _UniffiConverterString.write(value.error_message, buf) +# 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 DefaultAccountType(enum.Enum): - """ - Bitcoin account types for default display - """ - - NORMAL = 0 - """ - Normal account - """ - - - SEGWIT = 1 - """ - SegWit account - """ - - - LEGACY = 2 - """ - Legacy account - """ - - - - -class _UniffiConverterTypeDefaultAccountType(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return DefaultAccountType.NORMAL - if variant == 2: - return DefaultAccountType.SEGWIT - if variant == 3: - return DefaultAccountType.LEGACY - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value == DefaultAccountType.NORMAL: - return - if value == DefaultAccountType.SEGWIT: - return - if value == DefaultAccountType.LEGACY: - return - raise ValueError(value) - - @staticmethod - def write(value, buf): - if value == DefaultAccountType.NORMAL: - buf.write_i32(1) - if value == DefaultAccountType.SEGWIT: - buf.write_i32(2) - if value == DefaultAccountType.LEGACY: - buf.write_i32(3) - - - - - - - -class HdNodeTypeOrString: - """ - Union type for HD Node (either a String or HDNodeType) - """ - - def __init__(self): - raise RuntimeError("HdNodeTypeOrString cannot be instantiated directly") - - # Each enum variant is a nested class of the enum itself. - class STRING: - """ - HD Node as a string - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"HdNodeTypeOrString.STRING{self._values!r}" - - def __eq__(self, other): - if not other.is_STRING(): - return False - return self._values == other._values - class NODE: - """ - HD Node as an object - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"HdNodeTypeOrString.NODE{self._values!r}" - - def __eq__(self, other): - if not other.is_NODE(): - 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_STRING(self) -> bool: - return isinstance(self, HdNodeTypeOrString.STRING) - def is_string(self) -> bool: - return isinstance(self, HdNodeTypeOrString.STRING) - def is_NODE(self) -> bool: - return isinstance(self, HdNodeTypeOrString.NODE) - def is_node(self) -> bool: - return isinstance(self, HdNodeTypeOrString.NODE) - - -# 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. -HdNodeTypeOrString.STRING = type("HdNodeTypeOrString.STRING", (HdNodeTypeOrString.STRING, HdNodeTypeOrString,), {}) # type: ignore -HdNodeTypeOrString.NODE = type("HdNodeTypeOrString.NODE", (HdNodeTypeOrString.NODE, HdNodeTypeOrString,), {}) # type: ignore - - - - -class _UniffiConverterTypeHdNodeTypeOrString(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return HdNodeTypeOrString.STRING( - _UniffiConverterString.read(buf), - ) - if variant == 2: - return HdNodeTypeOrString.NODE( - _UniffiConverterTypeHdNodeType.read(buf), - ) - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value.is_STRING(): - _UniffiConverterString.check_lower(value._values[0]) - return - if value.is_NODE(): - _UniffiConverterTypeHdNodeType.check_lower(value._values[0]) - return - raise ValueError(value) - - @staticmethod - def write(value, buf): - if value.is_STRING(): - buf.write_i32(1) - _UniffiConverterString.write(value._values[0], buf) - if value.is_NODE(): - buf.write_i32(2) - _UniffiConverterTypeHdNodeType.write(value._values[0], buf) - - - - -# 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): - pass +class LnurlError: # type: ignore + class InvalidAddress(_UniffiTempLnurlError): + def __init__(self): + pass def __repr__(self): return "LnurlError.InvalidAddress({})".format(str(self)) @@ -11547,136 +10303,6 @@ def write(value, buf): -class ScriptType(enum.Enum): - """ - Script type for inputs and outputs - """ - - SPEND_ADDRESS = 0 - - SPEND_MULTISIG = 1 - - SPEND_WITNESS = 2 - - SPEND_P2SH_WITNESS = 3 - - SPEND_TAPROOT = 4 - - EXTERNAL = 5 - - PAY_TO_ADDRESS = 6 - - PAY_TO_SCRIPT_HASH = 7 - - PAY_TO_MULTISIG = 8 - - PAY_TO_WITNESS = 9 - - PAY_TO_P2SH_WITNESS = 10 - - PAY_TO_TAPROOT = 11 - - PAY_TO_OP_RETURN = 12 - - - -class _UniffiConverterTypeScriptType(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return ScriptType.SPEND_ADDRESS - if variant == 2: - return ScriptType.SPEND_MULTISIG - if variant == 3: - return ScriptType.SPEND_WITNESS - if variant == 4: - return ScriptType.SPEND_P2SH_WITNESS - if variant == 5: - return ScriptType.SPEND_TAPROOT - if variant == 6: - return ScriptType.EXTERNAL - if variant == 7: - return ScriptType.PAY_TO_ADDRESS - if variant == 8: - return ScriptType.PAY_TO_SCRIPT_HASH - if variant == 9: - return ScriptType.PAY_TO_MULTISIG - if variant == 10: - return ScriptType.PAY_TO_WITNESS - if variant == 11: - return ScriptType.PAY_TO_P2SH_WITNESS - if variant == 12: - return ScriptType.PAY_TO_TAPROOT - if variant == 13: - return ScriptType.PAY_TO_OP_RETURN - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value == ScriptType.SPEND_ADDRESS: - return - if value == ScriptType.SPEND_MULTISIG: - return - if value == ScriptType.SPEND_WITNESS: - return - if value == ScriptType.SPEND_P2SH_WITNESS: - return - if value == ScriptType.SPEND_TAPROOT: - return - if value == ScriptType.EXTERNAL: - return - if value == ScriptType.PAY_TO_ADDRESS: - return - if value == ScriptType.PAY_TO_SCRIPT_HASH: - return - if value == ScriptType.PAY_TO_MULTISIG: - return - if value == ScriptType.PAY_TO_WITNESS: - return - if value == ScriptType.PAY_TO_P2SH_WITNESS: - return - if value == ScriptType.PAY_TO_TAPROOT: - return - if value == ScriptType.PAY_TO_OP_RETURN: - return - raise ValueError(value) - - @staticmethod - def write(value, buf): - if value == ScriptType.SPEND_ADDRESS: - buf.write_i32(1) - if value == ScriptType.SPEND_MULTISIG: - buf.write_i32(2) - if value == ScriptType.SPEND_WITNESS: - buf.write_i32(3) - if value == ScriptType.SPEND_P2SH_WITNESS: - buf.write_i32(4) - if value == ScriptType.SPEND_TAPROOT: - buf.write_i32(5) - if value == ScriptType.EXTERNAL: - buf.write_i32(6) - if value == ScriptType.PAY_TO_ADDRESS: - buf.write_i32(7) - if value == ScriptType.PAY_TO_SCRIPT_HASH: - buf.write_i32(8) - if value == ScriptType.PAY_TO_MULTISIG: - buf.write_i32(9) - if value == ScriptType.PAY_TO_WITNESS: - buf.write_i32(10) - if value == ScriptType.PAY_TO_P2SH_WITNESS: - buf.write_i32(11) - if value == ScriptType.PAY_TO_TAPROOT: - buf.write_i32(12) - if value == ScriptType.PAY_TO_OP_RETURN: - buf.write_i32(13) - - - - - - - class SortDirection(enum.Enum): ASC = 0 @@ -11798,88 +10424,100 @@ def write(value, buf): -class TokenFilter(enum.Enum): +class TrezorCoinType(enum.Enum): + """ + Bitcoin network / coin type for Trezor operations. + """ + + BITCOIN = 0 """ - Token filter options for getAccountInfo + Bitcoin mainnet """ - NONZERO = 0 + + TESTNET = 1 """ - Return only addresses with nonzero balance (default) + Bitcoin testnet """ - USED = 1 + SIGNET = 2 """ - Return addresses with at least one transaction + Bitcoin signet (treated as testnet by the device) """ - DERIVED = 2 + REGTEST = 3 """ - Return all derived addresses + Bitcoin regtest """ -class _UniffiConverterTypeTokenFilter(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorCoinType(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return TokenFilter.NONZERO + return TrezorCoinType.BITCOIN if variant == 2: - return TokenFilter.USED + return TrezorCoinType.TESTNET if variant == 3: - return TokenFilter.DERIVED + 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 == TokenFilter.NONZERO: + if value == TrezorCoinType.BITCOIN: + return + if value == TrezorCoinType.TESTNET: return - if value == TokenFilter.USED: + if value == TrezorCoinType.SIGNET: return - if value == TokenFilter.DERIVED: + if value == TrezorCoinType.REGTEST: return raise ValueError(value) @staticmethod def write(value, buf): - if value == TokenFilter.NONZERO: + if value == TrezorCoinType.BITCOIN: buf.write_i32(1) - if value == TokenFilter.USED: + if value == TrezorCoinType.TESTNET: buf.write_i32(2) - if value == TokenFilter.DERIVED: + if value == TrezorCoinType.SIGNET: buf.write_i32(3) + if value == TrezorCoinType.REGTEST: + buf.write_i32(4) -# TrezorConnectError +# 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 TrezorConnectError(Exception): +class TrezorError(Exception): """ - Error types for Trezor Connect operations + Trezor-related errors exposed via FFI. """ pass -_UniffiTempTrezorConnectError = TrezorConnectError +_UniffiTempTrezorError = TrezorError -class TrezorConnectError: # type: ignore +class TrezorError: # type: ignore """ - Error types for Trezor Connect operations + Trezor-related errors exposed via FFI. """ - class SerdeError(_UniffiTempTrezorConnectError): + class TransportError(_UniffiTempTrezorError): """ - Error during serialization/deserialization + Transport layer error (USB/Bluetooth communication) """ def __init__(self, error_details): @@ -11889,25 +10527,33 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "TrezorConnectError.SerdeError({})".format(str(self)) - _UniffiTempTrezorConnectError.SerdeError = SerdeError # type: ignore - class UrlError(_UniffiTempTrezorConnectError): + return "TrezorError.TransportError({})".format(str(self)) + _UniffiTempTrezorError.TransportError = TransportError # type: ignore + class DeviceNotFound(_UniffiTempTrezorError): """ - Error with URL parsing or formatting + No Trezor device found """ - 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 "TrezorError.DeviceNotFound({})".format(str(self)) + _UniffiTempTrezorError.DeviceNotFound = DeviceNotFound # type: ignore + class DeviceDisconnected(_UniffiTempTrezorError): + """ + Device disconnected during operation + """ + + def __init__(self): + pass def __repr__(self): - return "TrezorConnectError.UrlError({})".format(str(self)) - _UniffiTempTrezorConnectError.UrlError = UrlError # type: ignore - class EnvironmentError(_UniffiTempTrezorConnectError): + return "TrezorError.DeviceDisconnected({})".format(str(self)) + _UniffiTempTrezorError.DeviceDisconnected = DeviceDisconnected # type: ignore + class ConnectionError(_UniffiTempTrezorError): """ - Environment-related errors + Connection error """ def __init__(self, error_details): @@ -11917,11 +10563,11 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "TrezorConnectError.EnvironmentError({})".format(str(self)) - _UniffiTempTrezorConnectError.EnvironmentError = EnvironmentError # type: ignore - class Other(_UniffiTempTrezorConnectError): + return "TrezorError.ConnectionError({})".format(str(self)) + _UniffiTempTrezorError.ConnectionError = ConnectionError # type: ignore + class ProtocolError(_UniffiTempTrezorError): """ - General errors + Protocol error (encoding/decoding) """ def __init__(self, error_details): @@ -11931,9 +10577,24 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "TrezorConnectError.Other({})".format(str(self)) - _UniffiTempTrezorConnectError.Other = Other # type: ignore - class ClientError(_UniffiTempTrezorConnectError): + return "TrezorError.ProtocolError({})".format(str(self)) + _UniffiTempTrezorError.ProtocolError = ProtocolError # type: ignore + class PairingRequired(_UniffiTempTrezorError): + """ + Pairing required for Bluetooth connection + """ + + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.PairingRequired({})".format(str(self)) + _UniffiTempTrezorError.PairingRequired = PairingRequired # type: ignore + class PairingFailed(_UniffiTempTrezorError): + """ + Pairing failed + """ + def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -11941,134 +10602,421 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "TrezorConnectError.ClientError({})".format(str(self)) - _UniffiTempTrezorConnectError.ClientError = ClientError # type: ignore + return "TrezorError.PairingFailed({})".format(str(self)) + _UniffiTempTrezorError.PairingFailed = PairingFailed # type: ignore + class PinRequired(_UniffiTempTrezorError): + """ + PIN is required + """ -TrezorConnectError = _UniffiTempTrezorConnectError # type: ignore -del _UniffiTempTrezorConnectError + def __init__(self): + pass + def __repr__(self): + return "TrezorError.PinRequired({})".format(str(self)) + _UniffiTempTrezorError.PinRequired = PinRequired # type: ignore + class PinCancelled(_UniffiTempTrezorError): + """ + PIN entry cancelled + """ -class _UniffiConverterTypeTrezorConnectError(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.PinCancelled({})".format(str(self)) + _UniffiTempTrezorError.PinCancelled = PinCancelled # type: ignore + class InvalidPin(_UniffiTempTrezorError): + """ + Invalid PIN entered + """ + + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.InvalidPin({})".format(str(self)) + _UniffiTempTrezorError.InvalidPin = InvalidPin # type: ignore + class PassphraseRequired(_UniffiTempTrezorError): + """ + Passphrase is required + """ + + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.PassphraseRequired({})".format(str(self)) + _UniffiTempTrezorError.PassphraseRequired = PassphraseRequired # type: ignore + class UserCancelled(_UniffiTempTrezorError): + """ + Action cancelled by user on device + """ + + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.UserCancelled({})".format(str(self)) + _UniffiTempTrezorError.UserCancelled = UserCancelled # type: ignore + class Timeout(_UniffiTempTrezorError): + """ + Operation timed out + """ + + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.Timeout({})".format(str(self)) + _UniffiTempTrezorError.Timeout = Timeout # type: ignore + class InvalidPath(_UniffiTempTrezorError): + """ + Invalid derivation path + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "TrezorError.InvalidPath({})".format(str(self)) + _UniffiTempTrezorError.InvalidPath = InvalidPath # type: ignore + class DeviceError(_UniffiTempTrezorError): + """ + Device returned an error + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "TrezorError.DeviceError({})".format(str(self)) + _UniffiTempTrezorError.DeviceError = DeviceError # type: ignore + class NotInitialized(_UniffiTempTrezorError): + """ + Trezor manager not initialized + """ + + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.NotInitialized({})".format(str(self)) + _UniffiTempTrezorError.NotInitialized = NotInitialized # type: ignore + class NotConnected(_UniffiTempTrezorError): + """ + No device connected + """ + + def __init__(self): + pass + + def __repr__(self): + return "TrezorError.NotConnected({})".format(str(self)) + _UniffiTempTrezorError.NotConnected = NotConnected # type: ignore + class SessionError(_UniffiTempTrezorError): + """ + Session error + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "TrezorError.SessionError({})".format(str(self)) + _UniffiTempTrezorError.SessionError = SessionError # type: ignore + class IoError(_UniffiTempTrezorError): + """ + IO error + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "TrezorError.IoError({})".format(str(self)) + _UniffiTempTrezorError.IoError = IoError # type: ignore + +TrezorError = _UniffiTempTrezorError # type: ignore +del _UniffiTempTrezorError + + +class _UniffiConverterTypeTrezorError(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): variant = buf.read_i32() if variant == 1: - return TrezorConnectError.SerdeError( + return TrezorError.TransportError( _UniffiConverterString.read(buf), ) if variant == 2: - return TrezorConnectError.UrlError( - _UniffiConverterString.read(buf), + return TrezorError.DeviceNotFound( ) if variant == 3: - return TrezorConnectError.EnvironmentError( - _UniffiConverterString.read(buf), + return TrezorError.DeviceDisconnected( ) if variant == 4: - return TrezorConnectError.Other( + return TrezorError.ConnectionError( _UniffiConverterString.read(buf), ) if variant == 5: - return TrezorConnectError.ClientError( + return TrezorError.ProtocolError( + _UniffiConverterString.read(buf), + ) + if variant == 6: + return TrezorError.PairingRequired( + ) + if variant == 7: + return TrezorError.PairingFailed( + _UniffiConverterString.read(buf), + ) + if variant == 8: + return TrezorError.PinRequired( + ) + if variant == 9: + return TrezorError.PinCancelled( + ) + if variant == 10: + return TrezorError.InvalidPin( + ) + if variant == 11: + return TrezorError.PassphraseRequired( + ) + if variant == 12: + return TrezorError.UserCancelled( + ) + if variant == 13: + return TrezorError.Timeout( + ) + if variant == 14: + return TrezorError.InvalidPath( + _UniffiConverterString.read(buf), + ) + if variant == 15: + return TrezorError.DeviceError( + _UniffiConverterString.read(buf), + ) + if variant == 16: + return TrezorError.NotInitialized( + ) + if variant == 17: + return TrezorError.NotConnected( + ) + if variant == 18: + return TrezorError.SessionError( + _UniffiConverterString.read(buf), + ) + if variant == 19: + return TrezorError.IoError( _UniffiConverterString.read(buf), ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, TrezorConnectError.SerdeError): + if isinstance(value, TrezorError.TransportError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, TrezorError.DeviceNotFound): + return + if isinstance(value, TrezorError.DeviceDisconnected): + return + if isinstance(value, TrezorError.ConnectionError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, TrezorError.ProtocolError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, TrezorError.PairingRequired): + return + if isinstance(value, TrezorError.PairingFailed): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, TrezorConnectError.UrlError): + if isinstance(value, TrezorError.PinRequired): + return + if isinstance(value, TrezorError.PinCancelled): + return + if isinstance(value, TrezorError.InvalidPin): + return + if isinstance(value, TrezorError.PassphraseRequired): + return + if isinstance(value, TrezorError.UserCancelled): + return + if isinstance(value, TrezorError.Timeout): + return + if isinstance(value, TrezorError.InvalidPath): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, TrezorConnectError.EnvironmentError): + if isinstance(value, TrezorError.DeviceError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, TrezorConnectError.Other): + if isinstance(value, TrezorError.NotInitialized): + return + if isinstance(value, TrezorError.NotConnected): + return + if isinstance(value, TrezorError.SessionError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, TrezorConnectError.ClientError): + if isinstance(value, TrezorError.IoError): _UniffiConverterString.check_lower(value.error_details) return @staticmethod def write(value, buf): - if isinstance(value, TrezorConnectError.SerdeError): + if isinstance(value, TrezorError.TransportError): buf.write_i32(1) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, TrezorConnectError.UrlError): + if isinstance(value, TrezorError.DeviceNotFound): buf.write_i32(2) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, TrezorConnectError.EnvironmentError): + if isinstance(value, TrezorError.DeviceDisconnected): buf.write_i32(3) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, TrezorConnectError.Other): + if isinstance(value, TrezorError.ConnectionError): buf.write_i32(4) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, TrezorConnectError.ClientError): + if isinstance(value, TrezorError.ProtocolError): buf.write_i32(5) _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, TrezorError.PairingRequired): + buf.write_i32(6) + if isinstance(value, TrezorError.PairingFailed): + buf.write_i32(7) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, TrezorError.PinRequired): + buf.write_i32(8) + if isinstance(value, TrezorError.PinCancelled): + buf.write_i32(9) + if isinstance(value, TrezorError.InvalidPin): + buf.write_i32(10) + if isinstance(value, TrezorError.PassphraseRequired): + buf.write_i32(11) + if isinstance(value, TrezorError.UserCancelled): + buf.write_i32(12) + if isinstance(value, TrezorError.Timeout): + buf.write_i32(13) + if isinstance(value, TrezorError.InvalidPath): + buf.write_i32(14) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, TrezorError.DeviceError): + buf.write_i32(15) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, TrezorError.NotInitialized): + buf.write_i32(16) + if isinstance(value, TrezorError.NotConnected): + buf.write_i32(17) + if isinstance(value, TrezorError.SessionError): + buf.write_i32(18) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, TrezorError.IoError): + buf.write_i32(19) + _UniffiConverterString.write(value.error_details, buf) -class TrezorEnvironment(enum.Enum): +class TrezorScriptType(enum.Enum): + """ + Script types for address derivation. + """ + + SPEND_ADDRESS = 0 + """ + P2PKH (legacy) + """ + + + SPEND_P2SH_WITNESS = 1 + """ + P2SH-P2WPKH (nested SegWit) + """ + + + SPEND_WITNESS = 2 """ - Environment options for Trezor deep linking + P2WPKH (native SegWit) """ - PRODUCTION = 0 + + SPEND_TAPROOT = 3 """ - Production environment (currently unavailable according to docs) + P2TR (Taproot) """ - DEVELOPMENT = 1 + SPEND_MULTISIG = 4 """ - Development environment + P2SH multisig """ - LOCAL = 2 + EXTERNAL = 5 """ - Local environment + External/watch-only input (not signed by device) """ -class _UniffiConverterTypeTrezorEnvironment(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorScriptType(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return TrezorEnvironment.PRODUCTION + return TrezorScriptType.SPEND_ADDRESS if variant == 2: - return TrezorEnvironment.DEVELOPMENT + return TrezorScriptType.SPEND_P2SH_WITNESS if variant == 3: - return TrezorEnvironment.LOCAL + 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 == TrezorEnvironment.PRODUCTION: + if value == TrezorScriptType.SPEND_ADDRESS: + return + if value == TrezorScriptType.SPEND_P2SH_WITNESS: + return + if value == TrezorScriptType.SPEND_WITNESS: return - if value == TrezorEnvironment.DEVELOPMENT: + if value == TrezorScriptType.SPEND_TAPROOT: return - if value == TrezorEnvironment.LOCAL: + if value == TrezorScriptType.SPEND_MULTISIG: + return + if value == TrezorScriptType.EXTERNAL: return raise ValueError(value) @staticmethod def write(value, buf): - if value == TrezorEnvironment.PRODUCTION: + if value == TrezorScriptType.SPEND_ADDRESS: buf.write_i32(1) - if value == TrezorEnvironment.DEVELOPMENT: + if value == TrezorScriptType.SPEND_P2SH_WITNESS: buf.write_i32(2) - if value == TrezorEnvironment.LOCAL: + 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) @@ -12076,338 +11024,67 @@ def write(value, buf): -class TrezorResponsePayload: +class TrezorTransportType(enum.Enum): """ - Enum representing the different types of Trezor responses + Transport type for Trezor devices. """ - def __init__(self): - raise RuntimeError("TrezorResponsePayload cannot be instantiated directly") - - # Each enum variant is a nested class of the enum itself. - class FEATURES: - """ - Response from getFeatures method - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values + USB = 0 + """ + USB connection + """ - def __getitem__(self, index): - return self._values[index] + + BLUETOOTH = 1 + """ + Bluetooth connection + """ - def __str__(self): - return f"TrezorResponsePayload.FEATURES{self._values!r}" + - def __eq__(self, other): - if not other.is_FEATURES(): - return False - return self._values == other._values - class ADDRESS: - """ - Response from getAddress method - """ - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values +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") - def __getitem__(self, index): - return self._values[index] + @staticmethod + def check_lower(value): + if value == TrezorTransportType.USB: + return + if value == TrezorTransportType.BLUETOOTH: + return + raise ValueError(value) - def __str__(self): - return f"TrezorResponsePayload.ADDRESS{self._values!r}" + @staticmethod + def write(value, buf): + if value == TrezorTransportType.USB: + buf.write_i32(1) + if value == TrezorTransportType.BLUETOOTH: + buf.write_i32(2) - def __eq__(self, other): - if not other.is_ADDRESS(): - return False - return self._values == other._values - class PUBLIC_KEY: - """ - Response from getPublicKey method - """ - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - def __getitem__(self, index): - return self._values[index] - def __str__(self): - return f"TrezorResponsePayload.PUBLIC_KEY{self._values!r}" - def __eq__(self, other): - if not other.is_PUBLIC_KEY(): - return False - return self._values == other._values - class ACCOUNT_INFO: - """ - Response from getAccountInfo method - """ - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - def __getitem__(self, index): - return self._values[index] +class WordCount(enum.Enum): + WORDS12 = 12 + """ + 12-word mnemonic (128 bits of entropy) + """ - def __str__(self): - return f"TrezorResponsePayload.ACCOUNT_INFO{self._values!r}" - - def __eq__(self, other): - if not other.is_ACCOUNT_INFO(): - return False - return self._values == other._values - class COMPOSE_TRANSACTION: - """ - Response from composeTransaction method - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"TrezorResponsePayload.COMPOSE_TRANSACTION{self._values!r}" - - def __eq__(self, other): - if not other.is_COMPOSE_TRANSACTION(): - return False - return self._values == other._values - class VERIFY_MESSAGE: - """ - Response from verifyMessage method - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"TrezorResponsePayload.VERIFY_MESSAGE{self._values!r}" - - def __eq__(self, other): - if not other.is_VERIFY_MESSAGE(): - return False - return self._values == other._values - class MESSAGE_SIGNATURE: - """ - Response from signMessage method - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"TrezorResponsePayload.MESSAGE_SIGNATURE{self._values!r}" - - def __eq__(self, other): - if not other.is_MESSAGE_SIGNATURE(): - return False - return self._values == other._values - class SIGNED_TRANSACTION: - """ - Response from signTransaction method - """ - - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values - - def __getitem__(self, index): - return self._values[index] - - def __str__(self): - return f"TrezorResponsePayload.SIGNED_TRANSACTION{self._values!r}" - - def __eq__(self, other): - if not other.is_SIGNED_TRANSACTION(): - 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_FEATURES(self) -> bool: - return isinstance(self, TrezorResponsePayload.FEATURES) - def is_features(self) -> bool: - return isinstance(self, TrezorResponsePayload.FEATURES) - def is_ADDRESS(self) -> bool: - return isinstance(self, TrezorResponsePayload.ADDRESS) - def is_address(self) -> bool: - return isinstance(self, TrezorResponsePayload.ADDRESS) - def is_PUBLIC_KEY(self) -> bool: - return isinstance(self, TrezorResponsePayload.PUBLIC_KEY) - def is_public_key(self) -> bool: - return isinstance(self, TrezorResponsePayload.PUBLIC_KEY) - def is_ACCOUNT_INFO(self) -> bool: - return isinstance(self, TrezorResponsePayload.ACCOUNT_INFO) - def is_account_info(self) -> bool: - return isinstance(self, TrezorResponsePayload.ACCOUNT_INFO) - def is_COMPOSE_TRANSACTION(self) -> bool: - return isinstance(self, TrezorResponsePayload.COMPOSE_TRANSACTION) - def is_compose_transaction(self) -> bool: - return isinstance(self, TrezorResponsePayload.COMPOSE_TRANSACTION) - def is_VERIFY_MESSAGE(self) -> bool: - return isinstance(self, TrezorResponsePayload.VERIFY_MESSAGE) - def is_verify_message(self) -> bool: - return isinstance(self, TrezorResponsePayload.VERIFY_MESSAGE) - def is_MESSAGE_SIGNATURE(self) -> bool: - return isinstance(self, TrezorResponsePayload.MESSAGE_SIGNATURE) - def is_message_signature(self) -> bool: - return isinstance(self, TrezorResponsePayload.MESSAGE_SIGNATURE) - def is_SIGNED_TRANSACTION(self) -> bool: - return isinstance(self, TrezorResponsePayload.SIGNED_TRANSACTION) - def is_signed_transaction(self) -> bool: - return isinstance(self, TrezorResponsePayload.SIGNED_TRANSACTION) - - -# 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. -TrezorResponsePayload.FEATURES = type("TrezorResponsePayload.FEATURES", (TrezorResponsePayload.FEATURES, TrezorResponsePayload,), {}) # type: ignore -TrezorResponsePayload.ADDRESS = type("TrezorResponsePayload.ADDRESS", (TrezorResponsePayload.ADDRESS, TrezorResponsePayload,), {}) # type: ignore -TrezorResponsePayload.PUBLIC_KEY = type("TrezorResponsePayload.PUBLIC_KEY", (TrezorResponsePayload.PUBLIC_KEY, TrezorResponsePayload,), {}) # type: ignore -TrezorResponsePayload.ACCOUNT_INFO = type("TrezorResponsePayload.ACCOUNT_INFO", (TrezorResponsePayload.ACCOUNT_INFO, TrezorResponsePayload,), {}) # type: ignore -TrezorResponsePayload.COMPOSE_TRANSACTION = type("TrezorResponsePayload.COMPOSE_TRANSACTION", (TrezorResponsePayload.COMPOSE_TRANSACTION, TrezorResponsePayload,), {}) # type: ignore -TrezorResponsePayload.VERIFY_MESSAGE = type("TrezorResponsePayload.VERIFY_MESSAGE", (TrezorResponsePayload.VERIFY_MESSAGE, TrezorResponsePayload,), {}) # type: ignore -TrezorResponsePayload.MESSAGE_SIGNATURE = type("TrezorResponsePayload.MESSAGE_SIGNATURE", (TrezorResponsePayload.MESSAGE_SIGNATURE, TrezorResponsePayload,), {}) # type: ignore -TrezorResponsePayload.SIGNED_TRANSACTION = type("TrezorResponsePayload.SIGNED_TRANSACTION", (TrezorResponsePayload.SIGNED_TRANSACTION, TrezorResponsePayload,), {}) # type: ignore - - - - -class _UniffiConverterTypeTrezorResponsePayload(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return TrezorResponsePayload.FEATURES( - _UniffiConverterTypeFeatureResponse.read(buf), - ) - if variant == 2: - return TrezorResponsePayload.ADDRESS( - _UniffiConverterTypeAddressResponse.read(buf), - ) - if variant == 3: - return TrezorResponsePayload.PUBLIC_KEY( - _UniffiConverterTypePublicKeyResponse.read(buf), - ) - if variant == 4: - return TrezorResponsePayload.ACCOUNT_INFO( - _UniffiConverterTypeAccountInfoResponse.read(buf), - ) - if variant == 5: - return TrezorResponsePayload.COMPOSE_TRANSACTION( - _UniffiConverterTypeComposeTransactionResponse.read(buf), - ) - if variant == 6: - return TrezorResponsePayload.VERIFY_MESSAGE( - _UniffiConverterTypeVerifyMessageResponse.read(buf), - ) - if variant == 7: - return TrezorResponsePayload.MESSAGE_SIGNATURE( - _UniffiConverterTypeMessageSignatureResponse.read(buf), - ) - if variant == 8: - return TrezorResponsePayload.SIGNED_TRANSACTION( - _UniffiConverterTypeSignedTransactionResponse.read(buf), - ) - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value.is_FEATURES(): - _UniffiConverterTypeFeatureResponse.check_lower(value._values[0]) - return - if value.is_ADDRESS(): - _UniffiConverterTypeAddressResponse.check_lower(value._values[0]) - return - if value.is_PUBLIC_KEY(): - _UniffiConverterTypePublicKeyResponse.check_lower(value._values[0]) - return - if value.is_ACCOUNT_INFO(): - _UniffiConverterTypeAccountInfoResponse.check_lower(value._values[0]) - return - if value.is_COMPOSE_TRANSACTION(): - _UniffiConverterTypeComposeTransactionResponse.check_lower(value._values[0]) - return - if value.is_VERIFY_MESSAGE(): - _UniffiConverterTypeVerifyMessageResponse.check_lower(value._values[0]) - return - if value.is_MESSAGE_SIGNATURE(): - _UniffiConverterTypeMessageSignatureResponse.check_lower(value._values[0]) - return - if value.is_SIGNED_TRANSACTION(): - _UniffiConverterTypeSignedTransactionResponse.check_lower(value._values[0]) - return - raise ValueError(value) - - @staticmethod - def write(value, buf): - if value.is_FEATURES(): - buf.write_i32(1) - _UniffiConverterTypeFeatureResponse.write(value._values[0], buf) - if value.is_ADDRESS(): - buf.write_i32(2) - _UniffiConverterTypeAddressResponse.write(value._values[0], buf) - if value.is_PUBLIC_KEY(): - buf.write_i32(3) - _UniffiConverterTypePublicKeyResponse.write(value._values[0], buf) - if value.is_ACCOUNT_INFO(): - buf.write_i32(4) - _UniffiConverterTypeAccountInfoResponse.write(value._values[0], buf) - if value.is_COMPOSE_TRANSACTION(): - buf.write_i32(5) - _UniffiConverterTypeComposeTransactionResponse.write(value._values[0], buf) - if value.is_VERIFY_MESSAGE(): - buf.write_i32(6) - _UniffiConverterTypeVerifyMessageResponse.write(value._values[0], buf) - if value.is_MESSAGE_SIGNATURE(): - buf.write_i32(7) - _UniffiConverterTypeMessageSignatureResponse.write(value._values[0], buf) - if value.is_SIGNED_TRANSACTION(): - buf.write_i32(8) - _UniffiConverterTypeSignedTransactionResponse.write(value._values[0], buf) - - - - - - - -class WordCount(enum.Enum): - WORDS12 = 12 - """ - 12-word mnemonic (128 bits of entropy) - """ - - - WORDS15 = 15 - """ - 15-word mnemonic (160 bits of entropy) - """ + + WORDS15 = 15 + """ + 15-word mnemonic (160 bits of entropy) + """ WORDS18 = 18 @@ -12477,11 +11154,11 @@ def write(value, buf): -class _UniffiConverterOptionalUInt8(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalUInt16(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterUInt8.check_lower(value) + _UniffiConverterUInt16.check_lower(value) @classmethod def write(cls, value, buf): @@ -12490,7 +11167,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterUInt8.write(value, buf) + _UniffiConverterUInt16.write(value, buf) @classmethod def read(cls, buf): @@ -12498,7 +11175,7 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterUInt8.read(buf) + return _UniffiConverterUInt16.read(buf) else: raise InternalError("Unexpected flag byte for optional type") @@ -12666,87 +11343,6 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeCoinPurchaseMemo(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeCoinPurchaseMemo.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeCoinPurchaseMemo.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeCoinPurchaseMemo.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalTypeCommonParams(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeCommonParams.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeCommonParams.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeCommonParams.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalTypeComposeAccount(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeComposeAccount.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeComposeAccount.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeComposeAccount.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - class _UniffiConverterOptionalTypeCreateCjitOptions(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -12801,33 +11397,6 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeDeviceParams(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeDeviceParams.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeDeviceParams.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeDeviceParams.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - class _UniffiConverterOptionalTypeIBtBolt11Invoice(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -13206,11 +11775,11 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeMultisigRedeemScriptType(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeOnchainActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeMultisigRedeemScriptType.check_lower(value) + _UniffiConverterTypeOnchainActivity.check_lower(value) @classmethod def write(cls, value, buf): @@ -13219,7 +11788,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeMultisigRedeemScriptType.write(value, buf) + _UniffiConverterTypeOnchainActivity.write(value, buf) @classmethod def read(cls, buf): @@ -13227,17 +11796,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeMultisigRedeemScriptType.read(buf) + return _UniffiConverterTypeOnchainActivity.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeOnchainActivity(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypePreActivityMetadata(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeOnchainActivity.check_lower(value) + _UniffiConverterTypePreActivityMetadata.check_lower(value) @classmethod def write(cls, value, buf): @@ -13246,7 +11815,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeOnchainActivity.write(value, buf) + _UniffiConverterTypePreActivityMetadata.write(value, buf) @classmethod def read(cls, buf): @@ -13254,17 +11823,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeOnchainActivity.read(buf) + return _UniffiConverterTypePreActivityMetadata.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypePreActivityMetadata(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTransactionDetails(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypePreActivityMetadata.check_lower(value) + _UniffiConverterTypeTransactionDetails.check_lower(value) @classmethod def write(cls, value, buf): @@ -13273,7 +11842,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypePreActivityMetadata.write(value, buf) + _UniffiConverterTypeTransactionDetails.write(value, buf) @classmethod def read(cls, buf): @@ -13281,17 +11850,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypePreActivityMetadata.read(buf) + return _UniffiConverterTypeTransactionDetails.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeRefundMemo(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorCallMessageResult(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeRefundMemo.check_lower(value) + _UniffiConverterTypeTrezorCallMessageResult.check_lower(value) @classmethod def write(cls, value, buf): @@ -13300,7 +11869,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeRefundMemo.write(value, buf) + _UniffiConverterTypeTrezorCallMessageResult.write(value, buf) @classmethod def read(cls, buf): @@ -13308,17 +11877,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeRefundMemo.read(buf) + return _UniffiConverterTypeTrezorCallMessageResult.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeTextMemo(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTextMemo.check_lower(value) + _UniffiConverterTypeTrezorDeviceInfo.check_lower(value) @classmethod def write(cls, value, buf): @@ -13327,7 +11896,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTextMemo.write(value, buf) + _UniffiConverterTypeTrezorDeviceInfo.write(value, buf) @classmethod def read(cls, buf): @@ -13335,17 +11904,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTextMemo.read(buf) + return _UniffiConverterTypeTrezorDeviceInfo.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeTransactionDetails(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorFeatures(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTransactionDetails.check_lower(value) + _UniffiConverterTypeTrezorFeatures.check_lower(value) @classmethod def write(cls, value, buf): @@ -13354,88 +11923,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTransactionDetails.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeTransactionDetails.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalTypeUnlockPath(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeUnlockPath.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeUnlockPath.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeUnlockPath.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalTypeXrpMarker(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeXrpMarker.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeXrpMarker.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeXrpMarker.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalTypeAccountInfoDetails(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeAccountInfoDetails.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeAccountInfoDetails.write(value, buf) + _UniffiConverterTypeTrezorFeatures.write(value, buf) @classmethod def read(cls, buf): @@ -13443,7 +11931,7 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeAccountInfoDetails.read(buf) + return _UniffiConverterTypeTrezorFeatures.read(buf) else: raise InternalError("Unexpected flag byte for optional type") @@ -13503,33 +11991,6 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeAmountUnit(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeAmountUnit.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeAmountUnit.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeAmountUnit.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - class _UniffiConverterOptionalTypeBtOrderState2(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -13611,33 +12072,6 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeDefaultAccountType(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeDefaultAccountType.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeDefaultAccountType.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeDefaultAccountType.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - class _UniffiConverterOptionalTypeNetwork(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -13692,33 +12126,6 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeScriptType(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeScriptType.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeScriptType.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeScriptType.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - class _UniffiConverterOptionalTypeSortDirection(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -13746,11 +12153,11 @@ def read(cls, buf): -class _UniffiConverterOptionalTypeTokenFilter(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorCoinType(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTokenFilter.check_lower(value) + _UniffiConverterTypeTrezorCoinType.check_lower(value) @classmethod def write(cls, value, buf): @@ -13759,7 +12166,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTokenFilter.write(value, buf) + _UniffiConverterTypeTrezorCoinType.write(value, buf) @classmethod def read(cls, buf): @@ -13767,17 +12174,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTokenFilter.read(buf) + return _UniffiConverterTypeTrezorCoinType.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeTrezorEnvironment(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorScriptType(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTrezorEnvironment.check_lower(value) + _UniffiConverterTypeTrezorScriptType.check_lower(value) @classmethod def write(cls, value, buf): @@ -13786,7 +12193,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTrezorEnvironment.write(value, buf) + _UniffiConverterTypeTrezorScriptType.write(value, buf) @classmethod def read(cls, buf): @@ -13794,7 +12201,7 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTrezorEnvironment.read(buf) + return _UniffiConverterTypeTrezorScriptType.read(buf) else: raise InternalError("Unexpected flag byte for optional type") @@ -13827,11 +12234,11 @@ def read(cls, buf): -class _UniffiConverterOptionalSequenceUInt32(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalSequenceString(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterSequenceUInt32.check_lower(value) + _UniffiConverterSequenceString.check_lower(value) @classmethod def write(cls, value, buf): @@ -13840,7 +12247,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterSequenceUInt32.write(value, buf) + _UniffiConverterSequenceString.write(value, buf) @classmethod def read(cls, buf): @@ -13848,17 +12255,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterSequenceUInt32.read(buf) + return _UniffiConverterSequenceString.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalSequenceString(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalSequenceTypeIManualRefund(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterSequenceString.check_lower(value) + _UniffiConverterSequenceTypeIManualRefund.check_lower(value) @classmethod def write(cls, value, buf): @@ -13867,7 +12274,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterSequenceString.write(value, buf) + _UniffiConverterSequenceTypeIManualRefund.write(value, buf) @classmethod def read(cls, buf): @@ -13875,17 +12282,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterSequenceString.read(buf) + return _UniffiConverterSequenceTypeIManualRefund.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalSequenceTypeFeeLevel(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalMapStringString(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterSequenceTypeFeeLevel.check_lower(value) + _UniffiConverterMapStringString.check_lower(value) @classmethod def write(cls, value, buf): @@ -13894,7 +12301,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterSequenceTypeFeeLevel.write(value, buf) + _UniffiConverterMapStringString.write(value, buf) @classmethod def read(cls, buf): @@ -13902,240 +12309,99 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterSequenceTypeFeeLevel.read(buf) + return _UniffiConverterMapStringString.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalSequenceTypeHdNodeType(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceString(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypeHdNodeType.check_lower(value) + for item in value: + _UniffiConverterString.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceTypeHdNodeType.write(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 _UniffiConverterSequenceTypeHdNodeType.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 _UniffiConverterOptionalSequenceTypeIManualRefund(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeActivityTags(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypeIManualRefund.check_lower(value) + for item in value: + _UniffiConverterTypeActivityTags.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: + _UniffiConverterTypeActivityTags.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 [ + _UniffiConverterTypeActivityTags.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalSequenceTypePaymentRequestMemo(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeClosedChannelDetails(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypePaymentRequestMemo.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 - - buf.write_u8(1) - _UniffiConverterSequenceTypePaymentRequestMemo.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeClosedChannelDetails.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceTypePaymentRequestMemo.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 [ + _UniffiConverterTypeClosedChannelDetails.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalSequenceTypePrecomposedInput(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeGetAddressResponse(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypePrecomposedInput.check_lower(value) + for item in value: + _UniffiConverterTypeGetAddressResponse.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceTypePrecomposedInput.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceTypePrecomposedInput.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalSequenceTypePrecomposedOutput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypePrecomposedOutput.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceTypePrecomposedOutput.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceTypePrecomposedOutput.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalSequenceTypeRefTransaction(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypeRefTransaction.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceTypeRefTransaction.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceTypeRefTransaction.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalSequenceTypeTxAckPaymentRequest(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypeTxAckPaymentRequest.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceTypeTxAckPaymentRequest.write(value, buf) - - @classmethod - def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceTypeTxAckPaymentRequest.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") - - - -class _UniffiConverterOptionalMapStringString(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - if value is not None: - _UniffiConverterMapStringString.check_lower(value) - - @classmethod - def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterMapStringString.write(value, 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") - - - -class _UniffiConverterSequenceUInt32(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterUInt32.check_lower(item) - - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterUInt32.write(item, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeGetAddressResponse.write(item, buf) @classmethod def read(cls, buf): @@ -14144,23 +12410,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterUInt32.read(buf) for i in range(count) + _UniffiConverterTypeGetAddressResponse.read(buf) for i in range(count) ] -class _UniffiConverterSequenceString(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeIBtOnchainTransaction(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterString.check_lower(item) + _UniffiConverterTypeIBtOnchainTransaction.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterString.write(item, buf) + _UniffiConverterTypeIBtOnchainTransaction.write(item, buf) @classmethod def read(cls, buf): @@ -14169,23 +12435,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterString.read(buf) for i in range(count) + _UniffiConverterTypeIBtOnchainTransaction.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeAccountUtxo(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeIBtOrder(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeAccountUtxo.check_lower(item) + _UniffiConverterTypeIBtOrder.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeAccountUtxo.write(item, buf) + _UniffiConverterTypeIBtOrder.write(item, buf) @classmethod def read(cls, buf): @@ -14194,23 +12460,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeAccountUtxo.read(buf) for i in range(count) + _UniffiConverterTypeIBtOrder.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeActivityTags(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeILspNode(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeActivityTags.check_lower(item) + _UniffiConverterTypeILspNode.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeActivityTags.write(item, buf) + _UniffiConverterTypeILspNode.write(item, buf) @classmethod def read(cls, buf): @@ -14219,23 +12485,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeActivityTags.read(buf) for i in range(count) + _UniffiConverterTypeILspNode.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeAddressInfo(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeIManualRefund(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeAddressInfo.check_lower(item) + _UniffiConverterTypeIManualRefund.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeAddressInfo.write(item, buf) + _UniffiConverterTypeIManualRefund.write(item, buf) @classmethod def read(cls, buf): @@ -14244,23 +12510,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeAddressInfo.read(buf) for i in range(count) + _UniffiConverterTypeIManualRefund.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeClosedChannelDetails(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeIcJitEntry(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeClosedChannelDetails.check_lower(item) + _UniffiConverterTypeIcJitEntry.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeClosedChannelDetails.write(item, buf) + _UniffiConverterTypeIcJitEntry.write(item, buf) @classmethod def read(cls, buf): @@ -14269,23 +12535,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeClosedChannelDetails.read(buf) for i in range(count) + _UniffiConverterTypeIcJitEntry.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeFeeLevel(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeLightningActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeFeeLevel.check_lower(item) + _UniffiConverterTypeLightningActivity.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeFeeLevel.write(item, buf) + _UniffiConverterTypeLightningActivity.write(item, buf) @classmethod def read(cls, buf): @@ -14294,23 +12560,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeFeeLevel.read(buf) for i in range(count) + _UniffiConverterTypeLightningActivity.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeGetAddressResponse(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeNativeDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeGetAddressResponse.check_lower(item) + _UniffiConverterTypeNativeDeviceInfo.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeGetAddressResponse.write(item, buf) + _UniffiConverterTypeNativeDeviceInfo.write(item, buf) @classmethod def read(cls, buf): @@ -14319,23 +12585,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeGetAddressResponse.read(buf) for i in range(count) + _UniffiConverterTypeNativeDeviceInfo.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeHdNodePathType(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeOnchainActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeHdNodePathType.check_lower(item) + _UniffiConverterTypeOnchainActivity.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeHdNodePathType.write(item, buf) + _UniffiConverterTypeOnchainActivity.write(item, buf) @classmethod def read(cls, buf): @@ -14344,23 +12610,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeHdNodePathType.read(buf) for i in range(count) + _UniffiConverterTypeOnchainActivity.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeHdNodeType(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypePreActivityMetadata(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeHdNodeType.check_lower(item) + _UniffiConverterTypePreActivityMetadata.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeHdNodeType.write(item, buf) + _UniffiConverterTypePreActivityMetadata.write(item, buf) @classmethod def read(cls, buf): @@ -14369,23 +12635,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeHdNodeType.read(buf) for i in range(count) + _UniffiConverterTypePreActivityMetadata.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIBtOnchainTransaction(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTransactionDetails(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIBtOnchainTransaction.check_lower(item) + _UniffiConverterTypeTransactionDetails.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIBtOnchainTransaction.write(item, buf) + _UniffiConverterTypeTransactionDetails.write(item, buf) @classmethod def read(cls, buf): @@ -14394,23 +12660,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIBtOnchainTransaction.read(buf) for i in range(count) + _UniffiConverterTypeTransactionDetails.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIBtOrder(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIBtOrder.check_lower(item) + _UniffiConverterTypeTrezorDeviceInfo.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIBtOrder.write(item, buf) + _UniffiConverterTypeTrezorDeviceInfo.write(item, buf) @classmethod def read(cls, buf): @@ -14419,23 +12685,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIBtOrder.read(buf) for i in range(count) + _UniffiConverterTypeTrezorDeviceInfo.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeILspNode(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorPrevTx(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeILspNode.check_lower(item) + _UniffiConverterTypeTrezorPrevTx.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeILspNode.write(item, buf) + _UniffiConverterTypeTrezorPrevTx.write(item, buf) @classmethod def read(cls, buf): @@ -14444,23 +12710,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeILspNode.read(buf) for i in range(count) + _UniffiConverterTypeTrezorPrevTx.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIManualRefund(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorPrevTxInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIManualRefund.check_lower(item) + _UniffiConverterTypeTrezorPrevTxInput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIManualRefund.write(item, buf) + _UniffiConverterTypeTrezorPrevTxInput.write(item, buf) @classmethod def read(cls, buf): @@ -14469,23 +12735,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIManualRefund.read(buf) for i in range(count) + _UniffiConverterTypeTrezorPrevTxInput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIcJitEntry(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorPrevTxOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIcJitEntry.check_lower(item) + _UniffiConverterTypeTrezorPrevTxOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIcJitEntry.write(item, buf) + _UniffiConverterTypeTrezorPrevTxOutput.write(item, buf) @classmethod def read(cls, buf): @@ -14494,23 +12760,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIcJitEntry.read(buf) for i in range(count) + _UniffiConverterTypeTrezorPrevTxOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeLightningActivity(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorTxInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeLightningActivity.check_lower(item) + _UniffiConverterTypeTrezorTxInput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeLightningActivity.write(item, buf) + _UniffiConverterTypeTrezorTxInput.write(item, buf) @classmethod def read(cls, buf): @@ -14519,23 +12785,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeLightningActivity.read(buf) for i in range(count) + _UniffiConverterTypeTrezorTxInput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeOnchainActivity(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorTxOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeOnchainActivity.check_lower(item) + _UniffiConverterTypeTrezorTxOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeOnchainActivity.write(item, buf) + _UniffiConverterTypeTrezorTxOutput.write(item, buf) @classmethod def read(cls, buf): @@ -14544,23 +12810,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeOnchainActivity.read(buf) for i in range(count) + _UniffiConverterTypeTrezorTxOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypePaymentRequestMemo(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTxInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypePaymentRequestMemo.check_lower(item) + _UniffiConverterTypeTxInput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypePaymentRequestMemo.write(item, buf) + _UniffiConverterTypeTxInput.write(item, buf) @classmethod def read(cls, buf): @@ -14569,23 +12835,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypePaymentRequestMemo.read(buf) for i in range(count) + _UniffiConverterTypeTxInput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypePreActivityMetadata(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTxOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypePreActivityMetadata.check_lower(item) + _UniffiConverterTypeTxOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypePreActivityMetadata.write(item, buf) + _UniffiConverterTypeTxOutput.write(item, buf) @classmethod def read(cls, buf): @@ -14594,23 +12860,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypePreActivityMetadata.read(buf) for i in range(count) + _UniffiConverterTypeTxOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypePrecomposedInput(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypePrecomposedInput.check_lower(item) + _UniffiConverterTypeActivity.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypePrecomposedInput.write(item, buf) + _UniffiConverterTypeActivity.write(item, buf) @classmethod def read(cls, buf): @@ -14619,368 +12885,1134 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypePrecomposedInput.read(buf) for i in range(count) + _UniffiConverterTypeActivity.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypePrecomposedOutput(_UniffiConverterRustBuffer): +class _UniffiConverterMapStringString(_UniffiConverterRustBuffer): @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypePrecomposedOutput.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: - _UniffiConverterTypePrecomposedOutput.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 [ - _UniffiConverterTypePrecomposedOutput.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 TrezorTransportCallbackProtocol(typing.Protocol): + """ + Callback interface for native Trezor transport operations + This trait must be implemented by the native iOS/Android code. + The implementation handles actual USB or Bluetooth communication. -class _UniffiConverterSequenceTypePrecomposedTransaction(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypePrecomposedTransaction.check_lower(item) + # 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 - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypePrecomposedTransaction.write(item, buf) + 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 - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + # iOS Implementation + Use IOKit/CoreBluetooth with same service/characteristic UUIDs. + """ - return [ - _UniffiConverterTypePrecomposedTransaction.read(buf) for i in range(count) - ] + def enumerate_devices(self, ): + """ + Enumerate all connected Trezor devices + """ + raise NotImplementedError + def open_device(self, path: "str"): + """ + Open a connection to a device + """ + raise NotImplementedError + def close_device(self, path: "str"): + """ + Close the connection to a device + """ -class _UniffiConverterSequenceTypeRefTransaction(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeRefTransaction.check_lower(item) + raise NotImplementedError + def read_chunk(self, path: "str"): + """ + Read a chunk of data from the device + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeRefTransaction.write(item, buf) + raise NotImplementedError + def write_chunk(self, path: "str",data: "bytes"): + """ + Write a chunk of data to the device + """ - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + raise NotImplementedError + def get_chunk_size(self, path: "str"): + """ + Get the chunk size for a device (64 for USB, 244 for Bluetooth) + """ - return [ - _UniffiConverterTypeRefTransaction.read(buf) for i in range(count) - ] + raise NotImplementedError + def call_message(self, path: "str",message_type: "int",data: "bytes"): + """ + 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. -class _UniffiConverterSequenceTypeRefTxInput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeRefTxInput.check_lower(item) + # Arguments + * `path` - Device path + * `message_type` - Protobuf message type (e.g., GetAddress = 29) + * `data` - Serialized protobuf message data + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeRefTxInput.write(item, buf) + raise NotImplementedError + def get_pairing_code(self, ): + """ + Get pairing code from user during BLE THP pairing. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + This is called when the Trezor device displays a 6-digit code + that must be entered to complete Bluetooth pairing. - return [ - _UniffiConverterTypeRefTxInput.read(buf) for i in range(count) - ] + 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. + """ + raise NotImplementedError + def save_thp_credential(self, device_id: "str",credential_json: "str"): + """ + Save THP pairing credentials for a device. -class _UniffiConverterSequenceTypeRefTxOutput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeRefTxOutput.check_lower(item) + Called after successful BLE pairing to store credentials for reconnection. + The credential_json is a JSON string containing the serialized ThpCredentials. - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeRefTxOutput.write(item, buf) + # Arguments + * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * `credential_json` - JSON string with credential data - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + Returns true if credentials were saved successfully. + """ - return [ - _UniffiConverterTypeRefTxOutput.read(buf) for i in range(count) - ] + raise NotImplementedError + def load_thp_credential(self, device_id: "str"): + """ + 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") -class _UniffiConverterSequenceTypeTransactionDetails(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTransactionDetails.check_lower(item) + Returns the JSON string containing ThpCredentials, or None if not found. + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTransactionDetails.write(item, buf) + raise NotImplementedError + def log_debug(self, tag: "str",message: "str"): + """ + Log a debug message from the Rust THP handshake layer. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + 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. - return [ - _UniffiConverterTypeTransactionDetails.read(buf) for i in range(count) - ] + # Arguments + * `tag` - Short tag identifying the subsystem (e.g., "HANDSHAKE", "THP") + * `message` - Human-readable debug message + """ + raise NotImplementedError +# TrezorTransportCallback 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 _UniffiConverterSequenceTypeTxAckPaymentRequest(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxAckPaymentRequest.check_lower(item) +class TrezorTransportCallback(): + """ + Callback interface for native Trezor transport operations - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxAckPaymentRequest.write(item, buf) + This trait must be implemented by the native iOS/Android code. + The implementation handles actual USB or Bluetooth communication. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + # 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 - return [ - _UniffiConverterTypeTxAckPaymentRequest.read(buf) for i in range(count) - ] + 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. + """ + def enumerate_devices(self, ): + """ + Enumerate all connected Trezor devices + """ -class _UniffiConverterSequenceTypeTxInput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxInput.check_lower(item) + raise NotImplementedError + def open_device(self, path: "str"): + """ + Open a connection to a device + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxInput.write(item, buf) + raise NotImplementedError + def close_device(self, path: "str"): + """ + Close the connection to a device + """ - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + raise NotImplementedError + def read_chunk(self, path: "str"): + """ + Read a chunk of data from the device + """ - return [ - _UniffiConverterTypeTxInput.read(buf) for i in range(count) - ] + raise NotImplementedError + def write_chunk(self, path: "str",data: "bytes"): + """ + Write a chunk of data to the device + """ + raise NotImplementedError + def get_chunk_size(self, path: "str"): + """ + Get the chunk size for a device (64 for USB, 244 for Bluetooth) + """ + raise NotImplementedError + def call_message(self, path: "str",message_type: "int",data: "bytes"): + """ + High-level message call for BLE/THP devices. -class _UniffiConverterSequenceTypeTxInputType(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxInputType.check_lower(item) + 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. - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxInputType.write(item, buf) + Returns None if not supported (will fall back to Protocol V1 chunks). + Returns Some(result) to use native THP handling. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + # Arguments + * `path` - Device path + * `message_type` - Protobuf message type (e.g., GetAddress = 29) + * `data` - Serialized protobuf message data + """ - return [ - _UniffiConverterTypeTxInputType.read(buf) for i in range(count) - ] + raise NotImplementedError + def get_pairing_code(self, ): + """ + 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. -class _UniffiConverterSequenceTypeTxOutput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxOutput.check_lower(item) + Returns the 6-digit code as a string, or empty string to cancel. + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxOutput.write(item, buf) + raise NotImplementedError + def save_thp_credential(self, device_id: "str",credential_json: "str"): + """ + Save THP pairing credentials for a device. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + Called after successful BLE pairing to store credentials for reconnection. + The credential_json is a JSON string containing the serialized ThpCredentials. - return [ - _UniffiConverterTypeTxOutput.read(buf) for i in range(count) - ] + # 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. + """ + raise NotImplementedError + def load_thp_credential(self, device_id: "str"): + """ + Load THP pairing credentials for a device. -class _UniffiConverterSequenceTypeTxOutputType(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxOutputType.check_lower(item) + Called before BLE handshake to check for stored credentials. + If credentials are found, they will be used to skip the pairing dialog. - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxOutputType.write(item, buf) + # Arguments + * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + Returns the JSON string containing ThpCredentials, or None if not found. + """ - return [ - _UniffiConverterTypeTxOutputType.read(buf) for i in range(count) - ] + raise NotImplementedError + def log_debug(self, tag: "str",message: "str"): + """ + 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 + """ -class _UniffiConverterSequenceTypeActivity(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeActivity.check_lower(item) + raise NotImplementedError +# `TrezorTransportCallbackImpl` is the implementation for a Rust implemented version. +class TrezorTransportCallbackImpl(): + """ + Callback interface for native Trezor transport operations - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeActivity.write(item, buf) + This trait must be implemented by the native iOS/Android code. + The implementation handles actual USB or Bluetooth communication. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + # 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 - return [ - _UniffiConverterTypeActivity.read(buf) for i in range(count) - ] + 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. + """ + _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_trezortransportcallback, pointer) -class _UniffiConverterSequenceTypeComposeOutput(_UniffiConverterRustBuffer): + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_trezortransportcallback, self._pointer) + + # Used by alternative constructors or any methods which return this type. @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeComposeOutput.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 + + + def enumerate_devices(self, ) -> "typing.List[NativeDeviceInfo]": + """ + Enumerate all connected Trezor devices + """ + + return _UniffiConverterSequenceTypeNativeDeviceInfo.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices,self._uniffi_clone_pointer(),) + ) + + + + + + def open_device(self, path: "str") -> "TrezorTransportWriteResult": + """ + Open a connection to a device + """ + + _UniffiConverterString.check_lower(path) + + return _UniffiConverterTypeTrezorTransportWriteResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_open_device,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path)) + ) + + + + + + def close_device(self, path: "str") -> "TrezorTransportWriteResult": + """ + Close the connection to a device + """ + + _UniffiConverterString.check_lower(path) + + return _UniffiConverterTypeTrezorTransportWriteResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_close_device,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path)) + ) + + + + + + def read_chunk(self, path: "str") -> "TrezorTransportReadResult": + """ + Read a chunk of data from the device + """ + + _UniffiConverterString.check_lower(path) + + return _UniffiConverterTypeTrezorTransportReadResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path)) + ) + + + + + + def write_chunk(self, path: "str",data: "bytes") -> "TrezorTransportWriteResult": + """ + Write a chunk of data to the device + """ + + _UniffiConverterString.check_lower(path) + + _UniffiConverterBytes.check_lower(data) + + return _UniffiConverterTypeTrezorTransportWriteResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path), + _UniffiConverterBytes.lower(data)) + ) + + + + + + def get_chunk_size(self, path: "str") -> "int": + """ + Get the chunk size for a device (64 for USB, 244 for Bluetooth) + """ + + _UniffiConverterString.check_lower(path) + + return _UniffiConverterUInt32.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path)) + ) + + + + + + def call_message(self, path: "str",message_type: "int",data: "bytes") -> "typing.Optional[TrezorCallMessageResult]": + """ + 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 + """ + + _UniffiConverterString.check_lower(path) + + _UniffiConverterUInt16.check_lower(message_type) + + _UniffiConverterBytes.check_lower(data) + + return _UniffiConverterOptionalTypeTrezorCallMessageResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_call_message,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path), + _UniffiConverterUInt16.lower(message_type), + _UniffiConverterBytes.lower(data)) + ) + + + + + + def get_pairing_code(self, ) -> "str": + """ + 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. + """ + + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code,self._uniffi_clone_pointer(),) + ) + + + + + + def save_thp_credential(self, device_id: "str",credential_json: "str") -> "bool": + """ + 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. + """ + + _UniffiConverterString.check_lower(device_id) + + _UniffiConverterString.check_lower(credential_json) + + return _UniffiConverterBool.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(device_id), + _UniffiConverterString.lower(credential_json)) + ) + + + + + + def load_thp_credential(self, device_id: "str") -> "typing.Optional[str]": + """ + 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. + """ + + _UniffiConverterString.check_lower(device_id) + + return _UniffiConverterOptionalString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(device_id)) + ) + + + + + + def log_debug(self, tag: "str",message: "str") -> None: + """ + 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 + """ + + _UniffiConverterString.check_lower(tag) + + _UniffiConverterString.check_lower(message) + + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(tag), + _UniffiConverterString.lower(message)) + + + + + + +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplTrezorTransportCallback: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 + def enumerate_devices( + uniffi_handle, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = () + method = uniffi_obj.enumerate_devices + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterSequenceTypeNativeDeviceInfo.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD1 + def open_device( + uniffi_handle, + path, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), ) + method = uniffi_obj.open_device + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterTypeTrezorTransportWriteResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD2 + def close_device( + uniffi_handle, + path, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._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] = _UniffiConverterTypeTrezorTransportWriteResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD3 + def read_chunk( + uniffi_handle, + path, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), ) + method = uniffi_obj.read_chunk + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterTypeTrezorTransportReadResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD4 + def write_chunk( + uniffi_handle, + path, + data, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._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] = _UniffiConverterTypeTrezorTransportWriteResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD5 + def get_chunk_size( + uniffi_handle, + path, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), ) + method = uniffi_obj.get_chunk_size + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterUInt32.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD6 + def call_message( + uniffi_handle, + path, + message_type, + data, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), _UniffiConverterUInt16.lift(message_type), _UniffiConverterBytes.lift(data), ) + method = uniffi_obj.call_message + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterOptionalTypeTrezorCallMessageResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD7 + def get_pairing_code( + uniffi_handle, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = () + method = uniffi_obj.get_pairing_code + 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_TRANSPORT_CALLBACK_METHOD8 + def save_thp_credential( + uniffi_handle, + device_id, + credential_json, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(device_id), _UniffiConverterString.lift(credential_json), ) + method = uniffi_obj.save_thp_credential + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterBool.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD9 + def load_thp_credential( + uniffi_handle, + device_id, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(device_id), ) + method = uniffi_obj.load_thp_credential + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterOptionalString.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD10 + def log_debug( + uniffi_handle, + tag, + message, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(tag), _UniffiConverterString.lift(message), ) + method = uniffi_obj.log_debug + 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): + _UniffiConverterTypeTrezorTransportCallback._handle_map.remove(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceTrezorTransportCallback( + enumerate_devices, + open_device, + close_device, + read_chunk, + write_chunk, + get_chunk_size, + call_message, + get_pairing_code, + save_thp_credential, + load_thp_credential, + log_debug, + _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_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 write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeComposeOutput.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: 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. - return [ - _UniffiConverterTypeComposeOutput.read(buf) for i in range(count) - ] + The native layer (iOS/Android) should implement this to show PIN/passphrase + input UI when the device requests it during operations like signing. + Methods return `String`: + - Empty string (`""`) = cancel the request + - Non-empty string = the user's input (PIN or passphrase) + This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. + """ -class _UniffiConverterMapStringString(_UniffiConverterRustBuffer): + 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 user should enter on the Trezor itself — + return any non-empty string (e.g., "ok") to acknowledge. + + If `on_device` is false, show a passphrase input UI and return the value. + Return empty string to 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. + + Methods return `String`: + - Empty string (`""`) = cancel the request + - Non-empty string = the user's input (PIN or passphrase) + + This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. + """ + + 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 user should enter on the Trezor itself — + return any non-empty string (e.g., "ok") to acknowledge. + + If `on_device` is false, show a passphrase input UI and return the value. + Return empty string to 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. + + Methods return `String`: + - Empty string (`""`) = cancel the request + - Non-empty string = the user's input (PIN or passphrase) + + This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. + """ + + _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 check_lower(cls, items): - for (key, value) in items.items(): - _UniffiConverterString.check_lower(key) - _UniffiConverterString.check_lower(value) + 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") -> "str": + """ + Called when the device requests a passphrase. + + If `on_device` is true, the user should enter on the Trezor itself — + return any non-empty string (e.g., "ok") to acknowledge. + + If `on_device` is false, show a passphrase input UI and return the value. + Return empty string to cancel. + """ + + _UniffiConverterBool.check_lower(on_device) + + return _UniffiConverterString.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] = _UniffiConverterString.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 _UniffiConverterTypeTrezorUiCallback: + _handle_map = _UniffiHandleMap() + + @staticmethod + def lift(value: int): + return TrezorUiCallbackImpl._make_instance_(value) + + @staticmethod + def check_lower(value: TrezorUiCallback): + pass - @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) + @staticmethod + def lower(value: TrezorUiCallbackProtocol): + return _UniffiConverterTypeTrezorUiCallback._handle_map.insert(value) @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative map size") - - # 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 + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) -# objects. + @classmethod + def write(cls, value: TrezorUiCallbackProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) # Async support# RustFuturePoll values _UNIFFI_RUST_FUTURE_POLL_READY = 0 @@ -15948,10 +14980,274 @@ async def regtest_close_channel(funding_tx_id: "str",vout: "int",force_close_aft _UniffiConverterOptionalUInt64.check_lower(force_close_after_s) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_regtest_close_channel( - _UniffiConverterString.lower(funding_tx_id), - _UniffiConverterUInt32.lower(vout), - _UniffiConverterOptionalUInt64.lower(force_close_after_s)), + _UniffiLib.uniffi_bitkitcore_fn_func_regtest_close_channel( + _UniffiConverterString.lower(funding_tx_id), + _UniffiConverterUInt32.lower(vout), + _UniffiConverterOptionalUInt64.lower(force_close_after_s)), + _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 +_UniffiConverterTypeBlocktankError, + + ) +async def regtest_deposit(address: "str",amount_sat: "typing.Optional[int]") -> "str": + + _UniffiConverterString.check_lower(address) + + _UniffiConverterOptionalUInt64.check_lower(amount_sat) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_regtest_deposit( + _UniffiConverterString.lower(address), + _UniffiConverterOptionalUInt64.lower(amount_sat)), + _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 +_UniffiConverterTypeBlocktankError, + + ) +async def regtest_get_payment(payment_id: "str") -> "IBtBolt11Invoice": + + _UniffiConverterString.check_lower(payment_id) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_regtest_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 + _UniffiConverterTypeIBtBolt11Invoice.lift, + + # Error FFI converter +_UniffiConverterTypeBlocktankError, + + ) +async def regtest_mine(count: "typing.Optional[int]") -> None: + + _UniffiConverterOptionalUInt32.check_lower(count) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_regtest_mine( + _UniffiConverterOptionalUInt32.lower(count)), + _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 regtest_pay(invoice: "str",amount_sat: "typing.Optional[int]") -> "str": + + _UniffiConverterString.check_lower(invoice) + + _UniffiConverterOptionalUInt64.check_lower(amount_sat) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_regtest_pay( + _UniffiConverterString.lower(invoice), + _UniffiConverterOptionalUInt64.lower(amount_sat)), + _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 +_UniffiConverterTypeBlocktankError, + + ) + +def remove_closed_channel_by_id(channel_id: "str") -> "bool": + _UniffiConverterString.check_lower(channel_id) + + return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_remove_closed_channel_by_id, + _UniffiConverterString.lower(channel_id))) + + +def remove_pre_activity_metadata_tags(payment_id: "str",tags: "typing.List[str]") -> None: + _UniffiConverterString.check_lower(payment_id) + + _UniffiConverterSequenceString.check_lower(tags) + + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_remove_pre_activity_metadata_tags, + _UniffiConverterString.lower(payment_id), + _UniffiConverterSequenceString.lower(tags)) + + +def remove_tags(activity_id: "str",tags: "typing.List[str]") -> None: + _UniffiConverterString.check_lower(activity_id) + + _UniffiConverterSequenceString.check_lower(tags) + + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_remove_tags, + _UniffiConverterString.lower(activity_id), + _UniffiConverterSequenceString.lower(tags)) + + +def reset_pre_activity_metadata_tags(payment_id: "str") -> None: + _UniffiConverterString.check_lower(payment_id) + + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags, + _UniffiConverterString.lower(payment_id)) + +async def test_notification(device_token: "str",secret_message: "str",notification_type: "typing.Optional[str]",custom_url: "typing.Optional[str]") -> "str": + + _UniffiConverterString.check_lower(device_token) + + _UniffiConverterString.check_lower(secret_message) + + _UniffiConverterOptionalString.check_lower(notification_type) + + _UniffiConverterOptionalString.check_lower(custom_url) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_test_notification( + _UniffiConverterString.lower(device_token), + _UniffiConverterString.lower(secret_message), + _UniffiConverterOptionalString.lower(notification_type), + _UniffiConverterOptionalString.lower(custom_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 + _UniffiConverterString.lift, + + # Error FFI converter +_UniffiConverterTypeBlocktankError, + + ) +async def trezor_clear_credentials(device_id: "str") -> None: + + """ + Clear stored Bluetooth pairing credentials for a specific Trezor device. + + This removes any stored credentials, requiring re-pairing on the next connection. + Useful when a device has been reset or credentials have become stale. + """ + + _UniffiConverterString.check_lower(device_id) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_clear_credentials( + _UniffiConverterString.lower(device_id)), + _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 +_UniffiConverterTypeTrezorError, + + ) +async def trezor_connect(device_id: "str") -> "TrezorFeatures": + + """ + Connect to a Trezor device by its ID. + + For Bluetooth devices, this will use stored credentials if available, + or trigger pairing if needed. + """ + + _UniffiConverterString.check_lower(device_id) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_connect( + _UniffiConverterString.lower(device_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 + _UniffiConverterTypeTrezorFeatures.lift, + + # Error FFI converter +_UniffiConverterTypeTrezorError, + + ) +async def trezor_disconnect() -> None: + + """ + Disconnect from the currently connected Trezor device. + """ + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_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 +_UniffiConverterTypeTrezorError, + + ) +async def trezor_get_address(params: "TrezorGetAddressParams") -> "TrezorAddressResponse": + + """ + Get a Bitcoin address from the connected Trezor device. + """ + + _UniffiConverterTypeTrezorGetAddressParams.check_lower(params) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_address( + _UniffiConverterTypeTrezorGetAddressParams.lower(params)), + _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 + _UniffiConverterTypeTrezorAddressResponse.lift, + + # Error FFI converter +_UniffiConverterTypeTrezorError, + + ) +async def trezor_get_connected_device() -> "typing.Optional[TrezorDeviceInfo]": + + """ + Get information about the currently connected Trezor device. + """ + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_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 + _UniffiConverterOptionalTypeTrezorDeviceInfo.lift, + + # Error FFI converter + + None, + + ) +async def trezor_get_device_fingerprint() -> "str": + + """ + Get the device's master root fingerprint as an 8-character hex string. + + Returns the root fingerprint in the standard descriptor format (e.g., "73c5da0a"). + Requires a connected device. + """ + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_device_fingerprint(), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, @@ -15959,53 +15255,68 @@ async def regtest_close_channel(funding_tx_id: "str",vout: "int",force_close_aft _UniffiConverterString.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeTrezorError, ) -async def regtest_deposit(address: "str",amount_sat: "typing.Optional[int]") -> "str": +async def trezor_get_features() -> "typing.Optional[TrezorFeatures]": + + """ + Get the cached features of the currently connected Trezor device. + + Returns the features that were obtained during `trezor_connect()`, without + triggering any device interaction. Returns None if no device is connected. + """ - _UniffiConverterString.check_lower(address) - - _UniffiConverterOptionalUInt64.check_lower(amount_sat) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_regtest_deposit( - _UniffiConverterString.lower(address), - _UniffiConverterOptionalUInt64.lower(amount_sat)), + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_features(), _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, + _UniffiConverterOptionalTypeTrezorFeatures.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, + + None, ) -async def regtest_get_payment(payment_id: "str") -> "IBtBolt11Invoice": +async def trezor_get_public_key(params: "TrezorGetPublicKeyParams") -> "TrezorPublicKeyResponse": - _UniffiConverterString.check_lower(payment_id) + """ + Get a public key (xpub) from the connected Trezor device. + """ + + _UniffiConverterTypeTrezorGetPublicKeyParams.check_lower(params) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_regtest_get_payment( - _UniffiConverterString.lower(payment_id)), + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_public_key( + _UniffiConverterTypeTrezorGetPublicKeyParams.lower(params)), _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, + _UniffiConverterTypeTrezorPublicKeyResponse.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeTrezorError, ) -async def regtest_mine(count: "typing.Optional[int]") -> None: +async def trezor_initialize(credential_path: "typing.Optional[str]") -> None: - _UniffiConverterOptionalUInt32.check_lower(count) + """ + Initialize the Trezor manager with optional credential storage. + + The credential_path is used to persist Bluetooth pairing credentials, + allowing reconnection without re-pairing. + + NOTE: On Android, you must call the native initBle() function first! + """ + + _UniffiConverterOptionalString.check_lower(credential_path) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_regtest_mine( - _UniffiConverterOptionalUInt32.lower(count)), + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_initialize( + _UniffiConverterOptionalString.lower(credential_path)), _UniffiLib.ffi_bitkitcore_rust_future_poll_void, _UniffiLib.ffi_bitkitcore_rust_future_complete_void, _UniffiLib.ffi_bitkitcore_rust_future_free_void, @@ -16014,379 +15325,220 @@ async def regtest_mine(count: "typing.Optional[int]") -> None: # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeTrezorError, ) -async def regtest_pay(invoice: "str",amount_sat: "typing.Optional[int]") -> "str": - _UniffiConverterString.check_lower(invoice) - - _UniffiConverterOptionalUInt64.check_lower(amount_sat) - +def trezor_is_ble_available() -> "bool": + """ + Check if BLE has been initialized. + + On Android: Returns true if BluetoothInit.nativeInit() was called successfully. + On other platforms: Always returns true (BLE works natively). + """ + + return _UniffiConverterBool.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_ble_available,)) + +async def trezor_is_connected() -> "bool": + + """ + Check if a Trezor device is currently connected. + """ + return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_regtest_pay( - _UniffiConverterString.lower(invoice), - _UniffiConverterOptionalUInt64.lower(amount_sat)), - _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_trezor_is_connected(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_i8, + _UniffiLib.ffi_bitkitcore_rust_future_complete_i8, + _UniffiLib.ffi_bitkitcore_rust_future_free_i8, # lift function - _UniffiConverterString.lift, + _UniffiConverterBool.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, + + None, ) +async def trezor_is_initialized() -> "bool": -def remove_closed_channel_by_id(channel_id: "str") -> "bool": - _UniffiConverterString.check_lower(channel_id) - - return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_remove_closed_channel_by_id, - _UniffiConverterString.lower(channel_id))) + """ + Check if the Trezor manager is initialized. + """ + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_is_initialized(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_i8, + _UniffiLib.ffi_bitkitcore_rust_future_complete_i8, + _UniffiLib.ffi_bitkitcore_rust_future_free_i8, + # lift function + _UniffiConverterBool.lift, + + # Error FFI converter -def remove_pre_activity_metadata_tags(payment_id: "str",tags: "typing.List[str]") -> None: - _UniffiConverterString.check_lower(payment_id) - - _UniffiConverterSequenceString.check_lower(tags) - - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_remove_pre_activity_metadata_tags, - _UniffiConverterString.lower(payment_id), - _UniffiConverterSequenceString.lower(tags)) + None, + ) +async def trezor_list_devices() -> "typing.List[TrezorDeviceInfo]": -def remove_tags(activity_id: "str",tags: "typing.List[str]") -> None: - _UniffiConverterString.check_lower(activity_id) - - _UniffiConverterSequenceString.check_lower(tags) - - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_remove_tags, - _UniffiConverterString.lower(activity_id), - _UniffiConverterSequenceString.lower(tags)) + """ + List previously discovered devices without triggering a new scan. + """ + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_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 + _UniffiConverterSequenceTypeTrezorDeviceInfo.lift, + + # Error FFI converter +_UniffiConverterTypeTrezorError, + ) +async def trezor_scan() -> "typing.List[TrezorDeviceInfo]": -def reset_pre_activity_metadata_tags(payment_id: "str") -> None: - _UniffiConverterString.check_lower(payment_id) - - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags, - _UniffiConverterString.lower(payment_id)) + """ + Scan for available Trezor devices (USB + Bluetooth). -async def test_notification(device_token: "str",secret_message: "str",notification_type: "typing.Optional[str]",custom_url: "typing.Optional[str]") -> "str": + This performs an active Bluetooth scan and enumerates USB devices. + Returns a list of discovered devices. + """ - _UniffiConverterString.check_lower(device_token) - - _UniffiConverterString.check_lower(secret_message) - - _UniffiConverterOptionalString.check_lower(notification_type) - - _UniffiConverterOptionalString.check_lower(custom_url) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_test_notification( - _UniffiConverterString.lower(device_token), - _UniffiConverterString.lower(secret_message), - _UniffiConverterOptionalString.lower(notification_type), - _UniffiConverterOptionalString.lower(custom_url)), + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_scan(), _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, + _UniffiConverterSequenceTypeTrezorDeviceInfo.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeTrezorError, ) -def trezor_compose_transaction(outputs: "typing.List[ComposeOutput]",coin: "str",callback_url: "str",request_id: "typing.Optional[str]",trezor_environment: "typing.Optional[TrezorEnvironment]",push: "typing.Optional[bool]",sequence: "typing.Optional[int]",account: "typing.Optional[ComposeAccount]",fee_levels: "typing.Optional[typing.List[FeeLevel]]",skip_permutation: "typing.Optional[bool]",common: "typing.Optional[CommonParams]") -> "DeepLinkResult": - _UniffiConverterSequenceTypeComposeOutput.check_lower(outputs) - - _UniffiConverterString.check_lower(coin) - - _UniffiConverterString.check_lower(callback_url) - - _UniffiConverterOptionalString.check_lower(request_id) - - _UniffiConverterOptionalTypeTrezorEnvironment.check_lower(trezor_environment) - - _UniffiConverterOptionalBool.check_lower(push) - - _UniffiConverterOptionalUInt32.check_lower(sequence) - - _UniffiConverterOptionalTypeComposeAccount.check_lower(account) - - _UniffiConverterOptionalSequenceTypeFeeLevel.check_lower(fee_levels) - - _UniffiConverterOptionalBool.check_lower(skip_permutation) - - _UniffiConverterOptionalTypeCommonParams.check_lower(common) - - return _UniffiConverterTypeDeepLinkResult.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_compose_transaction, - _UniffiConverterSequenceTypeComposeOutput.lower(outputs), - _UniffiConverterString.lower(coin), - _UniffiConverterString.lower(callback_url), - _UniffiConverterOptionalString.lower(request_id), - _UniffiConverterOptionalTypeTrezorEnvironment.lower(trezor_environment), - _UniffiConverterOptionalBool.lower(push), - _UniffiConverterOptionalUInt32.lower(sequence), - _UniffiConverterOptionalTypeComposeAccount.lower(account), - _UniffiConverterOptionalSequenceTypeFeeLevel.lower(fee_levels), - _UniffiConverterOptionalBool.lower(skip_permutation), - _UniffiConverterOptionalTypeCommonParams.lower(common))) +def trezor_set_transport_callback(callback: "TrezorTransportCallback") -> None: + """ + Initialize the Trezor transport with a native callback implementation + This must be called before any Trezor scanning/connection operations. + The native layer (iOS/Android) must implement the TrezorTransportCallback interface. + """ -def trezor_get_account_info(coin: "str",callback_url: "str",request_id: "typing.Optional[str]",trezor_environment: "typing.Optional[TrezorEnvironment]",path: "typing.Optional[str]",descriptor: "typing.Optional[str]",details: "typing.Optional[AccountInfoDetails]",tokens: "typing.Optional[TokenFilter]",page: "typing.Optional[int]",page_size: "typing.Optional[int]",_from: "typing.Optional[int]",to: "typing.Optional[int]",gap: "typing.Optional[int]",contract_filter: "typing.Optional[str]",marker: "typing.Optional[XrpMarker]",default_account_type: "typing.Optional[DefaultAccountType]",suppress_backup_warning: "typing.Optional[bool]",common: "typing.Optional[CommonParams]") -> "DeepLinkResult": - _UniffiConverterString.check_lower(coin) - - _UniffiConverterString.check_lower(callback_url) - - _UniffiConverterOptionalString.check_lower(request_id) - - _UniffiConverterOptionalTypeTrezorEnvironment.check_lower(trezor_environment) - - _UniffiConverterOptionalString.check_lower(path) - - _UniffiConverterOptionalString.check_lower(descriptor) - - _UniffiConverterOptionalTypeAccountInfoDetails.check_lower(details) - - _UniffiConverterOptionalTypeTokenFilter.check_lower(tokens) + _UniffiConverterTypeTrezorTransportCallback.check_lower(callback) - _UniffiConverterOptionalUInt32.check_lower(page) - - _UniffiConverterOptionalUInt32.check_lower(page_size) - - _UniffiConverterOptionalUInt32.check_lower(_from) - - _UniffiConverterOptionalUInt32.check_lower(to) - - _UniffiConverterOptionalUInt32.check_lower(gap) - - _UniffiConverterOptionalString.check_lower(contract_filter) - - _UniffiConverterOptionalTypeXrpMarker.check_lower(marker) - - _UniffiConverterOptionalTypeDefaultAccountType.check_lower(default_account_type) - - _UniffiConverterOptionalBool.check_lower(suppress_backup_warning) - - _UniffiConverterOptionalTypeCommonParams.check_lower(common) - - return _UniffiConverterTypeDeepLinkResult.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_account_info, - _UniffiConverterString.lower(coin), - _UniffiConverterString.lower(callback_url), - _UniffiConverterOptionalString.lower(request_id), - _UniffiConverterOptionalTypeTrezorEnvironment.lower(trezor_environment), - _UniffiConverterOptionalString.lower(path), - _UniffiConverterOptionalString.lower(descriptor), - _UniffiConverterOptionalTypeAccountInfoDetails.lower(details), - _UniffiConverterOptionalTypeTokenFilter.lower(tokens), - _UniffiConverterOptionalUInt32.lower(page), - _UniffiConverterOptionalUInt32.lower(page_size), - _UniffiConverterOptionalUInt32.lower(_from), - _UniffiConverterOptionalUInt32.lower(to), - _UniffiConverterOptionalUInt32.lower(gap), - _UniffiConverterOptionalString.lower(contract_filter), - _UniffiConverterOptionalTypeXrpMarker.lower(marker), - _UniffiConverterOptionalTypeDefaultAccountType.lower(default_account_type), - _UniffiConverterOptionalBool.lower(suppress_backup_warning), - _UniffiConverterOptionalTypeCommonParams.lower(common))) + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_transport_callback, + _UniffiConverterTypeTrezorTransportCallback.lower(callback)) -def trezor_get_address(path: "str",callback_url: "str",request_id: "typing.Optional[str]",trezor_environment: "typing.Optional[TrezorEnvironment]",address: "typing.Optional[str]",show_on_trezor: "typing.Optional[bool]",chunkify: "typing.Optional[bool]",use_event_listener: "typing.Optional[bool]",coin: "typing.Optional[str]",cross_chain: "typing.Optional[bool]",multisig: "typing.Optional[MultisigRedeemScriptType]",script_type: "typing.Optional[str]",unlock_path: "typing.Optional[UnlockPath]",common: "typing.Optional[CommonParams]") -> "DeepLinkResult": - _UniffiConverterString.check_lower(path) - - _UniffiConverterString.check_lower(callback_url) - - _UniffiConverterOptionalString.check_lower(request_id) - - _UniffiConverterOptionalTypeTrezorEnvironment.check_lower(trezor_environment) - - _UniffiConverterOptionalString.check_lower(address) - - _UniffiConverterOptionalBool.check_lower(show_on_trezor) - - _UniffiConverterOptionalBool.check_lower(chunkify) - - _UniffiConverterOptionalBool.check_lower(use_event_listener) - - _UniffiConverterOptionalString.check_lower(coin) - - _UniffiConverterOptionalBool.check_lower(cross_chain) - - _UniffiConverterOptionalTypeMultisigRedeemScriptType.check_lower(multisig) - - _UniffiConverterOptionalString.check_lower(script_type) - - _UniffiConverterOptionalTypeUnlockPath.check_lower(unlock_path) - - _UniffiConverterOptionalTypeCommonParams.check_lower(common) - - return _UniffiConverterTypeDeepLinkResult.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_address, - _UniffiConverterString.lower(path), - _UniffiConverterString.lower(callback_url), - _UniffiConverterOptionalString.lower(request_id), - _UniffiConverterOptionalTypeTrezorEnvironment.lower(trezor_environment), - _UniffiConverterOptionalString.lower(address), - _UniffiConverterOptionalBool.lower(show_on_trezor), - _UniffiConverterOptionalBool.lower(chunkify), - _UniffiConverterOptionalBool.lower(use_event_listener), - _UniffiConverterOptionalString.lower(coin), - _UniffiConverterOptionalBool.lower(cross_chain), - _UniffiConverterOptionalTypeMultisigRedeemScriptType.lower(multisig), - _UniffiConverterOptionalString.lower(script_type), - _UniffiConverterOptionalTypeUnlockPath.lower(unlock_path), - _UniffiConverterOptionalTypeCommonParams.lower(common))) +def trezor_set_ui_callback(callback: "TrezorUiCallback") -> None: + """ + Set the UI callback for handling PIN and passphrase requests. + This should be called before connecting to a Trezor device if you want + the library to handle PIN/passphrase requests via your UI instead of + returning errors. + """ -def trezor_get_features(callback_url: "str",request_id: "typing.Optional[str]",trezor_environment: "typing.Optional[TrezorEnvironment]") -> "DeepLinkResult": - _UniffiConverterString.check_lower(callback_url) - - _UniffiConverterOptionalString.check_lower(request_id) + _UniffiConverterTypeTrezorUiCallback.check_lower(callback) - _UniffiConverterOptionalTypeTrezorEnvironment.check_lower(trezor_environment) - - return _UniffiConverterTypeDeepLinkResult.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_get_features, - _UniffiConverterString.lower(callback_url), - _UniffiConverterOptionalString.lower(request_id), - _UniffiConverterOptionalTypeTrezorEnvironment.lower(trezor_environment))) + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_trezor_set_ui_callback, + _UniffiConverterTypeTrezorUiCallback.lower(callback)) + +async def trezor_sign_message(params: "TrezorSignMessageParams") -> "TrezorSignedMessageResponse": + """ + Sign a message with the connected Trezor device. + """ -def trezor_handle_deep_link(callback_url: "str") -> "TrezorResponsePayload": - _UniffiConverterString.check_lower(callback_url) + _UniffiConverterTypeTrezorSignMessageParams.check_lower(params) - return _UniffiConverterTypeTrezorResponsePayload.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_handle_deep_link, - _UniffiConverterString.lower(callback_url))) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message( + _UniffiConverterTypeTrezorSignMessageParams.lower(params)), + _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 + _UniffiConverterTypeTrezorSignedMessageResponse.lift, + + # Error FFI converter +_UniffiConverterTypeTrezorError, + ) +async def trezor_sign_tx(params: "TrezorSignTxParams") -> "TrezorSignedTx": -def trezor_sign_message(path: "str",message: "str",callback_url: "str",request_id: "typing.Optional[str]",trezor_environment: "typing.Optional[TrezorEnvironment]",coin: "typing.Optional[str]",hex: "typing.Optional[bool]",no_script_type: "typing.Optional[bool]",common: "typing.Optional[CommonParams]") -> "DeepLinkResult": - _UniffiConverterString.check_lower(path) - - _UniffiConverterString.check_lower(message) - - _UniffiConverterString.check_lower(callback_url) - - _UniffiConverterOptionalString.check_lower(request_id) - - _UniffiConverterOptionalTypeTrezorEnvironment.check_lower(trezor_environment) - - _UniffiConverterOptionalString.check_lower(coin) - - _UniffiConverterOptionalBool.check_lower(hex) - - _UniffiConverterOptionalBool.check_lower(no_script_type) - - _UniffiConverterOptionalTypeCommonParams.check_lower(common) + """ + Sign a Bitcoin transaction with the connected Trezor device. + """ + + _UniffiConverterTypeTrezorSignTxParams.check_lower(params) - return _UniffiConverterTypeDeepLinkResult.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_message, - _UniffiConverterString.lower(path), - _UniffiConverterString.lower(message), - _UniffiConverterString.lower(callback_url), - _UniffiConverterOptionalString.lower(request_id), - _UniffiConverterOptionalTypeTrezorEnvironment.lower(trezor_environment), - _UniffiConverterOptionalString.lower(coin), - _UniffiConverterOptionalBool.lower(hex), - _UniffiConverterOptionalBool.lower(no_script_type), - _UniffiConverterOptionalTypeCommonParams.lower(common))) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx( + _UniffiConverterTypeTrezorSignTxParams.lower(params)), + _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 + _UniffiConverterTypeTrezorSignedTx.lift, + + # Error FFI converter +_UniffiConverterTypeTrezorError, + ) +async def trezor_sign_tx_from_psbt(psbt_base64: "str",network: "typing.Optional[TrezorCoinType]") -> "TrezorSignedTx": -def trezor_sign_transaction(coin: "str",inputs: "typing.List[TxInputType]",outputs: "typing.List[TxOutputType]",callback_url: "str",request_id: "typing.Optional[str]",trezor_environment: "typing.Optional[TrezorEnvironment]",ref_txs: "typing.Optional[typing.List[RefTransaction]]",payment_requests: "typing.Optional[typing.List[TxAckPaymentRequest]]",locktime: "typing.Optional[int]",version: "typing.Optional[int]",expiry: "typing.Optional[int]",version_group_id: "typing.Optional[int]",overwintered: "typing.Optional[bool]",timestamp: "typing.Optional[int]",branch_id: "typing.Optional[int]",push: "typing.Optional[bool]",amount_unit: "typing.Optional[AmountUnit]",unlock_path: "typing.Optional[UnlockPath]",serialize: "typing.Optional[bool]",chunkify: "typing.Optional[bool]",common: "typing.Optional[CommonParams]") -> "DeepLinkResult": - _UniffiConverterString.check_lower(coin) - - _UniffiConverterSequenceTypeTxInputType.check_lower(inputs) - - _UniffiConverterSequenceTypeTxOutputType.check_lower(outputs) - - _UniffiConverterString.check_lower(callback_url) - - _UniffiConverterOptionalString.check_lower(request_id) - - _UniffiConverterOptionalTypeTrezorEnvironment.check_lower(trezor_environment) - - _UniffiConverterOptionalSequenceTypeRefTransaction.check_lower(ref_txs) - - _UniffiConverterOptionalSequenceTypeTxAckPaymentRequest.check_lower(payment_requests) - - _UniffiConverterOptionalUInt32.check_lower(locktime) - - _UniffiConverterOptionalUInt32.check_lower(version) - - _UniffiConverterOptionalUInt32.check_lower(expiry) - - _UniffiConverterOptionalUInt32.check_lower(version_group_id) - - _UniffiConverterOptionalBool.check_lower(overwintered) - - _UniffiConverterOptionalUInt32.check_lower(timestamp) - - _UniffiConverterOptionalUInt32.check_lower(branch_id) - - _UniffiConverterOptionalBool.check_lower(push) - - _UniffiConverterOptionalTypeAmountUnit.check_lower(amount_unit) - - _UniffiConverterOptionalTypeUnlockPath.check_lower(unlock_path) - - _UniffiConverterOptionalBool.check_lower(serialize) - - _UniffiConverterOptionalBool.check_lower(chunkify) - - _UniffiConverterOptionalTypeCommonParams.check_lower(common) - - return _UniffiConverterTypeDeepLinkResult.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_transaction, - _UniffiConverterString.lower(coin), - _UniffiConverterSequenceTypeTxInputType.lower(inputs), - _UniffiConverterSequenceTypeTxOutputType.lower(outputs), - _UniffiConverterString.lower(callback_url), - _UniffiConverterOptionalString.lower(request_id), - _UniffiConverterOptionalTypeTrezorEnvironment.lower(trezor_environment), - _UniffiConverterOptionalSequenceTypeRefTransaction.lower(ref_txs), - _UniffiConverterOptionalSequenceTypeTxAckPaymentRequest.lower(payment_requests), - _UniffiConverterOptionalUInt32.lower(locktime), - _UniffiConverterOptionalUInt32.lower(version), - _UniffiConverterOptionalUInt32.lower(expiry), - _UniffiConverterOptionalUInt32.lower(version_group_id), - _UniffiConverterOptionalBool.lower(overwintered), - _UniffiConverterOptionalUInt32.lower(timestamp), - _UniffiConverterOptionalUInt32.lower(branch_id), - _UniffiConverterOptionalBool.lower(push), - _UniffiConverterOptionalTypeAmountUnit.lower(amount_unit), - _UniffiConverterOptionalTypeUnlockPath.lower(unlock_path), - _UniffiConverterOptionalBool.lower(serialize), - _UniffiConverterOptionalBool.lower(chunkify), - _UniffiConverterOptionalTypeCommonParams.lower(common))) + """ + Sign a Bitcoin transaction from a PSBT (base64-encoded). + Parses the PSBT, extracts inputs/outputs/prev_txs, signs via the connected + Trezor device, and returns the signed transaction. -def trezor_verify_message(address: "str",signature: "str",message: "str",coin: "str",callback_url: "str",request_id: "typing.Optional[str]",trezor_environment: "typing.Optional[TrezorEnvironment]",hex: "typing.Optional[bool]",common: "typing.Optional[CommonParams]") -> "DeepLinkResult": - _UniffiConverterString.check_lower(address) - - _UniffiConverterString.check_lower(signature) - - _UniffiConverterString.check_lower(message) - - _UniffiConverterString.check_lower(coin) - - _UniffiConverterString.check_lower(callback_url) - - _UniffiConverterOptionalString.check_lower(request_id) - - _UniffiConverterOptionalTypeTrezorEnvironment.check_lower(trezor_environment) + # Arguments + * `psbt_base64` - Base64-encoded PSBT data + * `network` - Bitcoin network type. Defaults to Bitcoin (mainnet) if None. + """ + + _UniffiConverterString.check_lower(psbt_base64) - _UniffiConverterOptionalBool.check_lower(hex) + _UniffiConverterOptionalTypeTrezorCoinType.check_lower(network) - _UniffiConverterOptionalTypeCommonParams.check_lower(common) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_sign_tx_from_psbt( + _UniffiConverterString.lower(psbt_base64), + _UniffiConverterOptionalTypeTrezorCoinType.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 + _UniffiConverterTypeTrezorSignedTx.lift, + + # Error FFI converter +_UniffiConverterTypeTrezorError, + + ) +async def trezor_verify_message(params: "TrezorVerifyMessageParams") -> "bool": + + """ + Verify a message signature with the connected Trezor device. + """ + + _UniffiConverterTypeTrezorVerifyMessageParams.check_lower(params) - return _UniffiConverterTypeDeepLinkResult.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeTrezorConnectError,_UniffiLib.uniffi_bitkitcore_fn_func_trezor_verify_message, - _UniffiConverterString.lower(address), - _UniffiConverterString.lower(signature), - _UniffiConverterString.lower(message), - _UniffiConverterString.lower(coin), - _UniffiConverterString.lower(callback_url), - _UniffiConverterOptionalString.lower(request_id), - _UniffiConverterOptionalTypeTrezorEnvironment.lower(trezor_environment), - _UniffiConverterOptionalBool.lower(hex), - _UniffiConverterOptionalTypeCommonParams.lower(common))) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_trezor_verify_message( + _UniffiConverterTypeTrezorVerifyMessageParams.lower(params)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_i8, + _UniffiLib.ffi_bitkitcore_rust_future_complete_i8, + _UniffiLib.ffi_bitkitcore_rust_future_free_i8, + # lift function + _UniffiConverterBool.lift, + + # Error FFI converter +_UniffiConverterTypeTrezorError, + ) def update_activity(activity_id: "str",activity: "Activity") -> None: _UniffiConverterString.check_lower(activity_id) @@ -16571,14 +15723,12 @@ def wipe_all_transaction_details() -> None: __all__ = [ "InternalError", - "AccountInfoDetails", "Activity", "ActivityError", "ActivityFilter", "ActivityType", "AddressError", "AddressType", - "AmountUnit", "BitcoinNetworkEnum", "BlocktankError", "BtBolt11InvoiceState", @@ -16589,12 +15739,8 @@ def wipe_all_transaction_details() -> None: "BtPaymentState", "BtPaymentState2", "CJitStateEnum", - "ComposeOutput", - "ComposeTransactionResponse", "DbError", "DecodingError", - "DefaultAccountType", - "HdNodeTypeOrString", "LnurlError", "ManualRefundStateEnum", "Network", @@ -16602,40 +15748,25 @@ def wipe_all_transaction_details() -> None: "PaymentState", "PaymentType", "Scanner", - "ScriptType", "SortDirection", "SweepError", - "TokenFilter", - "TrezorConnectError", - "TrezorEnvironment", - "TrezorResponsePayload", + "TrezorCoinType", + "TrezorError", + "TrezorScriptType", + "TrezorTransportType", "WordCount", - "AccountAddresses", - "AccountInfoResponse", - "AccountUtxo", "ActivityTags", - "AddressInfo", - "AddressResponse", "ChannelLiquidityOptions", "ChannelLiquidityParams", "ClosedChannelDetails", - "CoinPurchaseMemo", - "CommonParams", - "ComposeAccount", "CreateCjitOptions", "CreateOrderOptions", - "DeepLinkResult", "DefaultLspBalanceParams", - "DeviceParams", "ErrorData", - "FeatureResponse", - "FeeLevel", "FeeRates", "FundingTx", "GetAddressResponse", "GetAddressesResponse", - "HdNodePathType", - "HdNodeType", "IBt0ConfMinTxFeeWindow", "IBtBolt11Invoice", "IBtChannel", @@ -16668,36 +15799,37 @@ def wipe_all_transaction_details() -> None: "LnurlChannelData", "LnurlPayData", "LnurlWithdrawData", - "MessageSignatureResponse", - "MultisigRedeemScriptType", + "NativeDeviceInfo", "OnChainInvoice", "OnchainActivity", - "PaymentRequestMemo", "PreActivityMetadata", - "PrecomposedInput", - "PrecomposedOutput", - "PrecomposedTransaction", "PubkyAuth", - "PublicKeyResponse", - "RefTransaction", - "RefTxInput", - "RefTxOutput", - "RefundMemo", - "SignedTransactionResponse", "SweepResult", "SweepTransactionPreview", "SweepableBalances", - "TextMemo", "TransactionDetails", - "TxAckPaymentRequest", + "TrezorAddressResponse", + "TrezorCallMessageResult", + "TrezorDeviceInfo", + "TrezorFeatures", + "TrezorGetAddressParams", + "TrezorGetPublicKeyParams", + "TrezorPrevTx", + "TrezorPrevTxInput", + "TrezorPrevTxOutput", + "TrezorPublicKeyResponse", + "TrezorSignMessageParams", + "TrezorSignTxParams", + "TrezorSignedMessageResponse", + "TrezorSignedTx", + "TrezorTransportReadResult", + "TrezorTransportWriteResult", + "TrezorTxInput", + "TrezorTxOutput", + "TrezorVerifyMessageParams", "TxInput", - "TxInputType", "TxOutput", - "TxOutputType", - "UnlockPath", "ValidationResult", - "VerifyMessageResponse", - "XrpMarker", "activity_wipe_all", "add_pre_activity_metadata", "add_pre_activity_metadata_tags", @@ -16771,13 +15903,25 @@ def wipe_all_transaction_details() -> None: "remove_tags", "reset_pre_activity_metadata_tags", "test_notification", - "trezor_compose_transaction", - "trezor_get_account_info", + "trezor_clear_credentials", + "trezor_connect", + "trezor_disconnect", "trezor_get_address", + "trezor_get_connected_device", + "trezor_get_device_fingerprint", "trezor_get_features", - "trezor_handle_deep_link", + "trezor_get_public_key", + "trezor_initialize", + "trezor_is_ble_available", + "trezor_is_connected", + "trezor_is_initialized", + "trezor_list_devices", + "trezor_scan", + "trezor_set_transport_callback", + "trezor_set_ui_callback", "trezor_sign_message", - "trezor_sign_transaction", + "trezor_sign_tx", + "trezor_sign_tx_from_psbt", "trezor_verify_message", "update_activity", "update_blocktank_url", @@ -16798,5 +15942,7 @@ def wipe_all_transaction_details() -> None: "wipe_all_closed_channels", "wipe_all_databases", "wipe_all_transaction_details", + "TrezorTransportCallback", + "TrezorUiCallback", ] diff --git a/bindings/python/bitkitcore/libbitkitcore.dylib b/bindings/python/bitkitcore/libbitkitcore.dylib index def9f0f..a9e80b5 100755 Binary files a/bindings/python/bitkitcore/libbitkitcore.dylib and b/bindings/python/bitkitcore/libbitkitcore.dylib differ diff --git a/src/lib.rs b/src/lib.rs index 5fb68df..9701c77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,33 @@ uniffi::setup_scaffolding!(); +// Initialize Android logger so Rust log::info! calls appear in logcat +#[cfg(target_os = "android")] +fn init_android_logger() { + use std::sync::Once; + static INIT: Once = Once::new(); + INIT.call_once(|| { + android_logger::init_once( + android_logger::Config::default() + .with_max_level(log::LevelFilter::Debug) + .with_tag("BitkitRust"), + ); + log::info!("[BitkitRust] Android logger initialized"); + }); +} + mod modules; +use std::sync::Arc; use once_cell::sync::OnceCell; + +// Re-export Trezor callback types and traits so UniFFI discovers them at the crate root +pub use crate::modules::trezor::{ + TrezorTransportReadResult, TrezorTransportWriteResult, TrezorCallMessageResult, + NativeDeviceInfo, TrezorTransportCallback, + trezor_set_transport_callback, get_transport_callback, + trezor_is_ble_available, + TrezorUiCallback, trezor_set_ui_callback, +}; pub use modules::scanner::{ Scanner, DecodingError @@ -13,13 +38,12 @@ pub use modules::activity; use crate::activity::{ActivityError, ActivityDB, OnchainActivity, LightningActivity, Activity, ActivityFilter, SortDirection, PaymentType, DbError, ClosedChannelDetails, ActivityTags, PreActivityMetadata, TransactionDetails, TxInput, TxOutput}; use crate::modules::blocktank::{BlocktankDB, BlocktankError, IBtInfo, IBtOrder, CreateOrderOptions, BtOrderState2, IBt0ConfMinTxFeeWindow, IBtEstimateFeeResponse, IBtEstimateFeeResponse2, CreateCjitOptions, ICJitEntry, CJitStateEnum, IBtBolt11Invoice, IGift, ChannelLiquidityOptions, ChannelLiquidityParams, DefaultLspBalanceParams}; use crate::onchain::{AddressError, ValidationResult, GetAddressResponse, Network, GetAddressesResponse, SweepError, SweepResult, SweepTransactionPreview, SweepableBalances}; +use crate::modules::trezor::{TrezorError, TrezorDeviceInfo, TrezorTransportType, TrezorFeatures, TrezorGetAddressParams, TrezorAddressResponse, TrezorGetPublicKeyParams, TrezorPublicKeyResponse, TrezorScriptType, TrezorManager, TrezorSignMessageParams, TrezorSignedMessageResponse, TrezorVerifyMessageParams, TrezorSignTxParams, TrezorSignedTx, TrezorTxInput, TrezorTxOutput, TrezorCoinType}; pub use crate::onchain::WordCount; use std::sync::Mutex as StdMutex; use tokio::runtime::Runtime; use tokio::sync::Mutex as TokioMutex; -use crate::modules::trezor; -use crate::modules::trezor::{AccountInfoDetails, AmountUnit, CommonParams, ComposeAccount, ComposeOutput, ComposeTransactionParams, DeepLinkResult, DefaultAccountType, FeeLevel, GetAccountInfoParams, GetAddressParams, MultisigRedeemScriptType, RefTransaction, SignMessageParams, SignTransactionParams, TokenFilter, TrezorConnectError, TrezorEnvironment, TrezorResponsePayload, TxAckPaymentRequest, TxInputType, TxOutputType, UnlockPath, VerifyMessageParams, XrpMarker}; use bip39::Mnemonic; use bitcoin::bip32::Xpriv; use bitcoin::Network as BitcoinNetwork; @@ -36,6 +60,7 @@ pub struct AsyncDatabaseConnections { static DB: OnceCell> = OnceCell::new(); static ASYNC_DB: OnceCell> = OnceCell::new(); static RUNTIME: OnceCell = OnceCell::new(); +static TREZOR_MANAGER: OnceCell = OnceCell::new(); fn ensure_runtime() -> &'static Runtime { RUNTIME.get_or_init(|| { @@ -1204,288 +1229,6 @@ pub async fn regtest_close_channel( })) } -#[uniffi::export] -pub fn trezor_get_features( - callback_url: String, - request_id: Option, - trezor_environment: Option -) -> Result { - let trezor_environment = trezor_environment.unwrap_or(TrezorEnvironment::Production); - let trezor_client = match trezor::TrezorConnectClient::new(trezor_environment, callback_url) { - Ok(client) => client, - Err(e) => return Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - }; - match trezor_client.get_features(request_id) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - -#[uniffi::export] -pub fn trezor_get_address( - path: String, - callback_url: String, - request_id: Option, - trezor_environment: Option, - address: Option, - showOnTrezor: Option, - chunkify: Option, - useEventListener: Option, - coin: Option, - crossChain: Option, - multisig: Option, - scriptType: Option, - unlockPath: Option, - common: Option, -) -> Result { - let trezor_environment = trezor_environment.unwrap_or(TrezorEnvironment::Production); - let trezor_client = match trezor::TrezorConnectClient::new(trezor_environment, callback_url) { - Ok(client) => client, - Err(e) => return Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - }; - - let coin = Some(coin.unwrap_or_else(|| "btc".to_string())); - let params = GetAddressParams { - path, - address, - showOnTrezor, - chunkify, - useEventListener, - coin, - crossChain, - multisig, - scriptType, - unlockPath, - common, - }; - - match trezor_client.get_address(params, request_id) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - -#[uniffi::export] -pub fn trezor_get_account_info( - coin: String, - callback_url: String, - request_id: Option, - trezor_environment: Option, - path: Option, - descriptor: Option, - details: Option, - tokens: Option, - page: Option, - pageSize: Option, - from: Option, - to: Option, - gap: Option, - contractFilter: Option, - marker: Option, - defaultAccountType: Option, - suppressBackupWarning: Option, - common: Option, -) -> Result { - let trezor_environment = trezor_environment.unwrap_or(TrezorEnvironment::Production); - let trezor_client = match trezor::TrezorConnectClient::new(trezor_environment, callback_url) { - Ok(client) => client, - Err(e) => return Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - }; - - let params = GetAccountInfoParams { - path, - descriptor, - coin, - details, - tokens, - page, - pageSize, - from, - to, - gap, - contractFilter, - marker, - defaultAccountType, - suppressBackupWarning, - common, - }; - - match trezor_client.get_account_info(params, request_id) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - -#[uniffi::export] -pub fn trezor_handle_deep_link( - callback_url: String, -) -> Result { - match trezor::handle_deep_link(callback_url) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - -#[uniffi::export] -pub fn trezor_verify_message( - address: String, - signature: String, - message: String, - coin: String, - callback_url: String, - request_id: Option, - trezor_environment: Option, - hex: Option, - common: Option, -) -> Result { - let trezor_environment = trezor_environment.unwrap_or(TrezorEnvironment::Production); - let trezor_client = match trezor::TrezorConnectClient::new(trezor_environment, callback_url) { - Ok(client) => client, - Err(e) => return Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - }; - - let params = VerifyMessageParams { - address, - signature, - message, - coin, - hex, - common, - }; - - match trezor_client.verify_message(params, request_id) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - -#[uniffi::export] -pub fn trezor_sign_message( - path: String, - message: String, - callback_url: String, - request_id: Option, - trezor_environment: Option, - coin: Option, - hex: Option, - no_script_type: Option, - common: Option, -) -> Result { - let trezor_environment = trezor_environment.unwrap_or(TrezorEnvironment::Production); - let trezor_client = match trezor::TrezorConnectClient::new(trezor_environment, callback_url) { - Ok(client) => client, - Err(e) => return Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - }; - - let params = SignMessageParams { - path, - coin, - message, - hex, - no_script_type, - common, - }; - - match trezor_client.sign_message(params, request_id) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - -#[uniffi::export] -pub fn trezor_sign_transaction( - coin: String, - inputs: Vec, - outputs: Vec, - callback_url: String, - request_id: Option, - trezor_environment: Option, - ref_txs: Option>, - payment_requests: Option>, - locktime: Option, - version: Option, - expiry: Option, - version_group_id: Option, - overwintered: Option, - timestamp: Option, - branch_id: Option, - push: Option, - amount_unit: Option, - unlock_path: Option, - serialize: Option, - chunkify: Option, - common: Option, -) -> Result { - let trezor_environment = trezor_environment.unwrap_or(TrezorEnvironment::Production); - let trezor_client = match trezor::TrezorConnectClient::new(trezor_environment, callback_url) { - Ok(client) => client, - Err(e) => return Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - }; - - let params = SignTransactionParams { - coin, - inputs, - outputs, - refTxs: ref_txs, - paymentRequests: payment_requests, - locktime, - version, - expiry, - versionGroupId: version_group_id, - overwintered, - timestamp, - branchId: branch_id, - push, - amountUnit: amount_unit, - unlockPath: unlock_path, - serialize, - chunkify, - common, - }; - - match trezor_client.sign_transaction(params, request_id) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - -#[uniffi::export] -pub fn trezor_compose_transaction( - outputs: Vec, - coin: String, - callback_url: String, - request_id: Option, - trezor_environment: Option, - push: Option, - sequence: Option, - account: Option, - fee_levels: Option>, - skip_permutation: Option, - common: Option, -) -> Result { - let trezor_environment = trezor_environment.unwrap_or(TrezorEnvironment::Production); - let trezor_client = match trezor::TrezorConnectClient::new(trezor_environment, callback_url) { - Ok(client) => client, - Err(e) => return Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - }; - - let params = ComposeTransactionParams { - outputs, - coin, - push, - sequence, - account, - fee_levels, - skip_permutation, - common, - }; - - match trezor_client.compose_transaction(params, request_id) { - Ok(result) => Ok(result), - Err(e) => Err(TrezorConnectError::ClientError { error_details: e.to_string() }), - } -} - #[uniffi::export] pub fn activity_wipe_all() -> Result<(), ActivityError> { let mut guard = get_activity_db()?; @@ -1706,3 +1449,227 @@ pub fn calculate_channel_liquidity_options( pub fn get_default_lsp_balance(params: DefaultLspBalanceParams) -> u64 { crate::modules::blocktank::get_default_lsp_balance(params) } + +// ============================================================================ +// Trezor Hardware Wallet Functions +// ============================================================================ + +fn get_trezor_manager() -> &'static TrezorManager { + TREZOR_MANAGER.get_or_init(TrezorManager::new) +} + +// ============================================================================ +// Trezor / Bluetooth Functions +// ============================================================================ + +/// JNI function to initialize btleplug on Android. +/// This is called from Java via BluetoothInit.nativeInit(). +/// +/// The function name follows JNI naming convention: +/// Java_{package}_{class}_{method} where package dots become underscores +#[cfg(target_os = "android")] +#[no_mangle] +pub extern "system" fn Java_to_bitkit_services_BluetoothInit_nativeInit( + env: jni::JNIEnv, + _class: jni::objects::JClass, +) -> jni::sys::jboolean { + use crate::modules::trezor::{is_ble_initialized, set_ble_initialized}; + + // Already initialized + if is_ble_initialized() { + return jni::sys::JNI_TRUE; + } + + // Initialize btleplug with the JNI environment + match btleplug::platform::init(&env) { + Ok(()) => { + set_ble_initialized(true); + jni::sys::JNI_TRUE + } + Err(e) => { + // Log the error - this will be visible in logcat + eprintln!("Failed to initialize btleplug: {:?}", e); + jni::sys::JNI_FALSE + } + } +} + +/// Initialize the Trezor manager with optional credential storage. +/// +/// The credential_path is used to persist Bluetooth pairing credentials, +/// allowing reconnection without re-pairing. +/// +/// NOTE: On Android, you must call the native initBle() function first! +#[uniffi::export] +pub async fn trezor_initialize(credential_path: Option) -> Result<(), TrezorError> { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().initialize(credential_path).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Scan for available Trezor devices (USB + Bluetooth). +/// +/// This performs an active Bluetooth scan and enumerates USB devices. +/// Returns a list of discovered devices. +#[uniffi::export] +pub async fn trezor_scan() -> Result, TrezorError> { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().scan().await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// List previously discovered devices without triggering a new scan. +#[uniffi::export] +pub async fn trezor_list_devices() -> Result, TrezorError> { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().list_devices().await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Connect to a Trezor device by its ID. +/// +/// For Bluetooth devices, this will use stored credentials if available, +/// or trigger pairing if needed. +#[uniffi::export] +pub async fn trezor_connect(device_id: String) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().connect(&device_id).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Get a Bitcoin address from the connected Trezor device. +#[uniffi::export] +pub async fn trezor_get_address(params: TrezorGetAddressParams) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().get_address(params).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Get a public key (xpub) from the connected Trezor device. +#[uniffi::export] +pub async fn trezor_get_public_key(params: TrezorGetPublicKeyParams) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().get_public_key(params).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Disconnect from the currently connected Trezor device. +#[uniffi::export] +pub async fn trezor_disconnect() -> Result<(), TrezorError> { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().disconnect().await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Check if the Trezor manager is initialized. +#[uniffi::export] +pub async fn trezor_is_initialized() -> bool { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().is_initialized().await + }).await.unwrap_or(false) +} + +/// Check if a Trezor device is currently connected. +#[uniffi::export] +pub async fn trezor_is_connected() -> bool { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().is_connected().await + }).await.unwrap_or(false) +} + +/// Get information about the currently connected Trezor device. +#[uniffi::export] +pub async fn trezor_get_connected_device() -> Option { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().get_connected_device().await + }).await.unwrap_or(None) +} + +/// Get the cached features of the currently connected Trezor device. +/// +/// Returns the features that were obtained during `trezor_connect()`, without +/// triggering any device interaction. Returns None if no device is connected. +#[uniffi::export] +pub async fn trezor_get_features() -> Option { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().get_features().await + }).await.unwrap_or(None) +} + +/// Sign a message with the connected Trezor device. +#[uniffi::export] +pub async fn trezor_sign_message(params: TrezorSignMessageParams) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().sign_message(params).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Verify a message signature with the connected Trezor device. +#[uniffi::export] +pub async fn trezor_verify_message(params: TrezorVerifyMessageParams) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().verify_message(params).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Sign a Bitcoin transaction with the connected Trezor device. +#[uniffi::export] +pub async fn trezor_sign_tx(params: TrezorSignTxParams) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().sign_tx(params).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Get the device's master root fingerprint as an 8-character hex string. +/// +/// Returns the root fingerprint in the standard descriptor format (e.g., "73c5da0a"). +/// Requires a connected device. +#[uniffi::export] +pub async fn trezor_get_device_fingerprint() -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().get_device_fingerprint().await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Sign a Bitcoin transaction from a PSBT (base64-encoded). +/// +/// Parses the PSBT, extracts inputs/outputs/prev_txs, signs via the connected +/// Trezor device, and returns the signed transaction. +/// +/// # Arguments +/// * `psbt_base64` - Base64-encoded PSBT data +/// * `network` - Bitcoin network type. Defaults to Bitcoin (mainnet) if None. +#[uniffi::export] +pub async fn trezor_sign_tx_from_psbt(psbt_base64: String, network: Option) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().sign_tx_from_psbt(psbt_base64, network).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} + +/// Clear stored Bluetooth pairing credentials for a specific Trezor device. +/// +/// This removes any stored credentials, requiring re-pairing on the next connection. +/// Useful when a device has been reset or credentials have become stale. +#[uniffi::export] +pub async fn trezor_clear_credentials(device_id: String) -> Result<(), TrezorError> { + let rt = ensure_runtime(); + rt.spawn(async move { + get_trezor_manager().clear_credentials(&device_id).await + }).await.unwrap_or_else(|e| Err(TrezorError::IoError { error_details: format!("Runtime error: {}", e) })) +} diff --git a/src/modules/trezor/README.md b/src/modules/trezor/README.md index 6c9b50b..0aefe4a 100644 --- a/src/modules/trezor/README.md +++ b/src/modules/trezor/README.md @@ -1,765 +1,396 @@ -# Trezor Module - -The Trezor module enables integration with Trezor hardware wallets through deep linking according to the Trezor Suite Lite specification. It supports generating deep links for various Trezor operations and handling callback responses. - -## Features -- Environment Support - - Development environment - - Local environment - - Production environment (currently marked as unavailable) -- Deep Link Operations - - Get device features and capabilities - - Derive addresses for specified paths - - Retrieve account information with various query options - - Sign Bitcoin transactions with full parameter support - - Sign messages using BIP32 derived private keys - - Verify message signatures using address and signature - - Handle callback responses from Trezor -- Comprehensive Parameter Support - - Multiple address types and derivation paths - - Support for multisig configurations - - Various display options (show on device, chunkify, etc.) - - Cross-chain functionality - - Reference transactions (refTxs) for transaction signing - - Payment requests (SLIP-24) - - Various script types and amount units -- Error Handling - - Serialization/deserialization errors - - URL parsing errors - - Environment errors - - Client creation errors - -## Usage Examples - -### iOS (Swift) -```swift -import BitkitCore - -func interactWithTrezor() async { - do { - // Get device features - let featuresResult = try trezorGetFeatures( - callbackUrl: "myapp://trezor/callback", - requestId: nil, - trezorEnvironment: .local - ) - print("Features deep link: \(featuresResult.url)") - print("Request ID: \(featuresResult.requestId)") - - // Get an address - let addressResult = try trezorGetAddress( - path: "m/84'/0'/0'/0/0", - callbackUrl: "myapp://trezor/callback", - requestId: nil, - trezorEnvironment: .local, - address: nil, - showOnTrezor: true, - chunkify: false, - useEventListener: nil, - coin: "btc", - crossChain: nil, - multisig: nil, - scriptType: nil, - unlockPath: nil, - common: nil - ) - print("Address deep link: \(addressResult.url)") - print("Request ID: \(addressResult.requestId)") - - // Get account info - let accountResult = try trezorGetAccountInfo( - coin: "btc", - callbackUrl: "myapp://trezor/callback", - requestId: nil, - trezorEnvironment: .local, - path: "m/84'/0'/0'", - descriptor: nil, - details: .basic, - tokens: nil, - page: nil, - pageSize: nil, - from: nil, - to: nil, - gap: nil, - contractFilter: nil, - marker: nil, - defaultAccountType: nil, - suppressBackupWarning: nil, - common: nil - ) - print("Account info deep link: \(accountResult.url)") - print("Request ID: \(accountResult.requestId)") - - // Verify a message - let verifyMessageResult = try trezorVerifyMessage( - address: "3BD8TL6iShVzizQzvo789SuynEKGpLTms9", - signature: "JO7vL3tOB1qQyfSeIVLvdEw9G1tCvL+lNj78XDAVM4t6UptADs3kXDTO2+2ZeEOLFL4/+wm+BBdSpo3kb3Cnsas=", - message: "example message", - coin: "btc", - callbackUrl: "myapp://trezor/callback", - requestId: nil, - trezorEnvironment: .local, - hex: false, - common: nil - ) - print("Verify message deep link: \(verifyMessageResult.url)") - print("Request ID: \(verifyMessageResult.requestId)") - - // Verify a message - val verifyMessageResult = trezorVerifyMessage( - address = "3BD8TL6iShVzizQzvo789SuynEKGpLTms9", - signature = "JO7vL3tOB1qQyfSeIVLvdEw9G1tCvL+lNj78XDAVM4t6UptADs3kXDTO2+2ZeEOLFL4/+wm+BBdSpo3kb3Cnsas=", - message = "example message", - coin = "btc", - callbackUrl = "myapp://trezor/callback", - requestId = null, - trezorEnvironment = TrezorEnvironment.LOCAL, - hex = false, - common = null - ) - println("Verify message deep link: ${verifyMessageResult.url}") - println("Request ID: ${verifyMessageResult.requestId}") - - // Sign a message - let signMessageResult = try trezorSignMessage( - path: "m/44'/0'/0'", - message: "Hello World!", - callbackUrl: "myapp://trezor/callback", - requestId: nil, - trezorEnvironment: .local, - coin: "btc", - hex: false, - noScriptType: false, - common: nil - ) - print("Sign message deep link: \(signMessageResult.url)") - print("Request ID: \(signMessageResult.requestId)") - - // Sign a message - val signMessageResult = trezorSignMessage( - path = "m/44'/0'/0'", - message = "Hello World!", - callbackUrl = "myapp://trezor/callback", - requestId = null, - trezorEnvironment = TrezorEnvironment.LOCAL, - coin = "btc", - hex = false, - noScriptType = false, - common = null - ) - println("Sign message deep link: ${signMessageResult.url}") - println("Request ID: ${signMessageResult.requestId}") - - // Sign a transaction - let inputs = [ - TxInputType( - prevHash: "b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac", - prevIndex: 0, - amount: 3431747, - sequence: nil, - addressN: [ - (44 | 0x80000000), - (0 | 0x80000000), - (2 | 0x80000000), - 1, - 0 - ], - scriptType: .spendAddress, - multisig: nil, - scriptPubkey: nil, - scriptSig: nil, - witness: nil, - ownershipProof: nil, - commitmentData: nil, - origHash: nil, - origIndex: nil, - coinjoinFlags: nil - ) - ] - - let outputs = [ - TxOutputType( - address: nil, - addressN: [ - (44 | 0x80000000), - (0 | 0x80000000), - (2 | 0x80000000), - 1, - 1 - ], - amount: 3181747, - scriptType: .payToAddress, - multisig: nil, - opReturnData: nil, - origHash: nil, - origIndex: nil, - paymentReqIndex: nil - ), - TxOutputType( - address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2", - addressN: nil, - amount: 200000, - scriptType: .payToAddress, - multisig: nil, - opReturnData: nil, - origHash: nil, - origIndex: nil, - paymentReqIndex: nil - ) - ] - - let signResult = try trezorSignTransaction( - coin: "btc", - inputs: inputs, - outputs: outputs, - callbackUrl: "myapp://trezor/callback", - requestId: nil, - trezorEnvironment: .local, - refTxs: nil, - paymentRequests: nil, - locktime: nil, - version: nil, - expiry: nil, - versionGroupId: nil, - overwintered: nil, - timestamp: nil, - branchId: nil, - push: false, - amountUnit: nil, - unlockPath: nil, - serialize: nil, - chunkify: nil, - common: nil - ) - print("Sign transaction deep link: \(signResult.url)") - print("Request ID: \(signResult.requestId)") - - // Handle a callback from Trezor when received - let callbackUrl = "myapp://trezor/callback?id=abc123&response={...}" - let response = try trezorHandleDeepLink(callbackUrl: callbackUrl) - - switch response { - case .features(let features): - print("Received Features:") - print("Device: \(features.vendor) \(features.majorVersion).\(features.minorVersion).\(features.patchVersion)") - print("Device ID: \(features.deviceId)") - - case .address(let address): - print("Received Address:") - print("Address: \(address.address)") - print("Path: \(address.serializedPath)") - - case .publicKey(let publicKey): - print("Received Public Key:") - print("XPUB: \(publicKey.xpub)") - print("Path: \(publicKey.serializedPath)") - - case .accountInfo(let accountInfo): - print("Received Account Info:") - print("Account ID: \(accountInfo.id)") - print("Descriptor: \(accountInfo.descriptor)") - print("Balance: \(accountInfo.balance)") - - case .verifyMessage(let verifyMessage): - print("Received Verify Message Result:") - print("Result: \(verifyMessage.message)") - - case .messageSignature(let messageSignature): - print("Received Message Signature:") - print("Address: \(messageSignature.address)") - print("Signature: \(messageSignature.signature)") - - case .signedTransaction(let signedTx): - print("Received Signed Transaction:") - print("Signatures: \(signedTx.signatures)") - print("Serialized TX: \(signedTx.serializedTx)") - if let txid = signedTx.txid { - print("Transaction ID: \(txid)") - } - } - - } catch let error as TrezorConnectError { - switch error { - case .serdeError(let details): - print("Serialization error: \(details)") - case .urlError(let details): - print("URL error: \(details)") - case .environmentError(let details): - print("Environment error: \(details)") - case .clientError(let details): - print("Client error: \(details)") - case .other(let details): - print("Other error: \(details)") - } - } +# Trezor Module - Technical Overview + +This module provides Trezor hardware wallet integration for bitkit-core, supporting both USB and Bluetooth (BLE) connections on mobile (Android/iOS) and desktop platforms. + +## Architecture + +``` +┌─────────────────────────────────────────────────────────────────────────────┐ +│ bitkit-android │ +├─────────────────────────────────────────────────────────────────────────────┤ +│ TrezorTestView.kt TrezorViewModel.kt TrezorRepo.kt TrezorService.kt│ +│ (UI) (State) (State Mgmt) (FFI Bridge) │ +└──────────────────────────────────┬──────────────────────────────────────────┘ + │ UniFFI +┌──────────────────────────────────▼──────────────────────────────────────────┐ +│ bitkit-core │ +├─────────────────────────────────────────────────────────────────────────────┤ +│ lib.rs (exports) ←→ TrezorManager ←→ TrezorTransportCallback (trait) │ +│ │ ▲ │ +│ │ │ implemented by │ +│ ▼ │ native layer │ +│ ConnectedDevice │ │ +└──────────────────────────────┬────────────────────────┼─────────────────────┘ + │ │ +┌──────────────────────────────▼────────────────────────┼─────────────────────┐ +│ trezor-connect-rs │ +├─────────────────────────────────────────────────────────────────────────────┤ +│ CallbackTransport ←→ THP Protocol ←→ TransportCallback (trait) │ +│ │ │ │ +│ │ ┌──────┴──────┐ │ +│ │ │ Handshake │ │ +│ │ │ Pairing │ │ +│ │ │ Encryption │ │ +│ │ └─────────────┘ │ +│ ▼ │ +│ Protocol V1 (USB) / THP (BLE) │ +└─────────────────────────────────────────────────────────────────────────────┘ + │ +┌──────────────────────────────▼──────────────────────────────────────────────┐ +│ Native Layer (Kotlin/Swift) │ +├─────────────────────────────────────────────────────────────────────────────┤ +│ TrezorTransport.kt implements TrezorTransportCallback │ +│ │ │ +│ ├── USB: Android USB Host API │ +│ └── BLE: Android Bluetooth API (CoreBluetooth on iOS) │ +└─────────────────────────────────────────────────────────────────────────────┘ +``` + +## Key Components + +### bitkit-core (`src/modules/trezor/`) + +#### `types.rs` +FFI-compatible types exposed via UniFFI: +- `TrezorDeviceInfo` - Device metadata (id, transport type, name, model) +- `TrezorFeatures` - Device capabilities and state +- `TrezorGetAddressParams` / `TrezorAddressResponse` - Address derivation +- `TrezorSignMessageParams` / `TrezorSignedMessageResponse` - Message signing +- `TrezorVerifyMessageParams` - Signature verification +- `TrezorScriptType` - Bitcoin script types (P2PKH, P2SH-P2WPKH, P2WPKH, P2TR) + +#### `errors.rs` +Error types with UniFFI support: +- `TrezorError` - Main error enum with variants for transport, connection, device errors + +#### `implementation.rs` +Core `TrezorManager` struct: +- Manages device lifecycle (scan, connect, disconnect) +- Stores connected `ConnectedDevice` for session reuse +- Bridges between UniFFI callbacks and trezor-connect-rs library + +### lib.rs Exports + +```rust +// Callback trait - implemented by native layer +#[uniffi::export(with_foreign)] +pub trait TrezorTransportCallback: Send + Sync { + fn enumerate_devices(&self) -> Vec; + fn open_device(&self, path: String) -> TrezorTransportWriteResult; + fn close_device(&self, path: String) -> TrezorTransportWriteResult; + fn read_chunk(&self, path: String) -> TrezorTransportReadResult; + fn write_chunk(&self, path: String, data: Vec) -> TrezorTransportWriteResult; + fn get_chunk_size(&self, path: String) -> u32; + fn get_pairing_code(&self) -> String; + fn save_thp_credential(&self, device_id: String, credential_json: String) -> bool; + fn load_thp_credential(&self, device_id: String) -> Option; } + +// Main API functions +pub async fn trezor_initialize(credential_path: Option) -> Result<(), TrezorError>; +pub async fn trezor_scan() -> Result, TrezorError>; +pub async fn trezor_connect(device_id: String) -> Result; +pub async fn trezor_get_address(params: TrezorGetAddressParams) -> Result; +pub async fn trezor_sign_message(params: TrezorSignMessageParams) -> Result; +pub async fn trezor_verify_message(params: TrezorVerifyMessageParams) -> Result; +pub async fn trezor_disconnect() -> Result<(), TrezorError>; +``` + +## Connection Flow + +### 1. Initialization +``` +App Start + │ + ▼ +trezor_set_transport_callback(callback) ← Native layer provides I/O implementation + │ + ▼ +trezor_initialize(credential_path) ← Validates callback is set ``` -### Android (Kotlin) +### 2. Device Discovery +``` +trezor_scan() + │ + ▼ +callback.enumerate_devices() ← Native scans USB + BLE + │ + ▼ +Returns Vec ← Device list with transport type +``` + +### 3. Connection (Critical Path) +``` +trezor_connect(device_id) + │ + ▼ +callback.open_device(path) ← Native opens USB/BLE connection + │ + ▼ +CallbackTransport::new(adapter) ← Create transport wrapper + │ + ▼ +transport.acquire(path, None) ← Acquire session + │ │ + │ ┌──────────────────┴──────────────────┐ + │ │ USB Path │ + │ │ Protocol V1 (unencrypted chunks) │ + │ └─────────────────────────────────────┘ + │ │ + │ ┌──────────────────┴──────────────────┐ + │ │ BLE Path │ + │ │ │ + │ │ 1. Channel Allocation │ + │ │ 2. THP Handshake │ + │ │ - Load stored credentials? │ + │ │ - If yes: try_to_unlock=true │ + │ │ - If no: fresh pairing │ + │ │ 3. Pairing (if needed) │ + │ │ - callback.get_pairing_code() │ + │ │ - User enters 6-digit code │ + │ │ 4. Save credentials │ + │ │ - callback.save_thp_credential() │ + │ │ 5. Encrypted channel established │ + │ └─────────────────────────────────────┘ + │ + ▼ +ConnectedDevice::new(info, transport, session) + │ + ▼ +device.initialize() ← Get device features + │ + ▼ +Store in TrezorManager.connected_device ← REUSED for all operations +``` + +### 4. Operations (Reuse Connected Device) +``` +trezor_get_address(params) + │ + ▼ +TrezorManager.connected_device.lock() ← Get stored device + │ + ▼ +device.get_address(params) ← Uses existing encrypted channel + │ + ▼ +Return address ← No new handshake needed! +``` + +**Important:** The `ConnectedDevice` is stored and reused for all operations. This is critical for BLE - creating a new transport for each operation would trigger a fresh THP handshake and pairing prompt every time. + +### 5. Disconnection +``` +trezor_disconnect() + │ + ▼ +device.disconnect() ← Release session + │ + ▼ +callback.close_device(path) ← Native closes connection + │ + ▼ +Clear TrezorManager.connected_device ← Ready for new connection +``` + +## THP Protocol (Bluetooth) + +Trezor Host Protocol provides encrypted communication over BLE: + +### Handshake Flow +``` +Host Trezor + │ │ + │──── Channel Allocation Request ───────▶│ + │◀─── Channel Allocation Response ───────│ + │ │ + │──── Handshake Init (ephemeral key) ───▶│ + │◀─── Handshake Init Response ───────────│ + │ │ + │──── Handshake Completion ─────────────▶│ + │◀─── Handshake Completion Response ─────│ + │ │ + │ [If pairing needed] │ + │◀─── Pairing Request (code on screen) ──│ + │──── Pairing Code (user enters) ───────▶│ + │◀─── Credential Response ───────────────│ + │ │ + │ [Encrypted channel ready] │ + │◀════ Encrypted Messages ══════════════▶│ +``` + +### Credential Persistence +After successful pairing, credentials are saved: +```json +{ + "host_static_key": "hex-encoded-32-bytes", + "trezor_static_public_key": "hex-encoded-32-bytes", + "credential": "hex-encoded-credential-token" +} +``` + +On reconnection: +1. `load_thp_credential(device_id)` retrieves stored JSON +2. Handshake uses `try_to_unlock=true` with stored credential +3. If valid, pairing dialog is skipped + +## Android Implementation (bitkit-android) + +### TrezorTransport.kt +Implements `TrezorTransportCallback`: + +```kotlin +@Singleton +class TrezorTransport @Inject constructor( + private val context: Context, + private val bleManager: TrezorBleManager, + private val usbManager: TrezorUsbManager, +) : TrezorTransportCallback { + + // Device enumeration + override fun enumerateDevices(): List + + // Connection management + override fun openDevice(path: String): TrezorTransportWriteResult + override fun closeDevice(path: String): TrezorTransportWriteResult + + // Raw I/O (64-byte USB chunks, 244-byte BLE chunks) + override fun readChunk(path: String): TrezorTransportReadResult + override fun writeChunk(path: String, data: ByteArray): TrezorTransportWriteResult + override fun getChunkSize(path: String): UInt + + // Pairing UI + override fun getPairingCode(): String // Blocks, shows dialog, returns code + + // Credential storage + override fun saveThpCredential(deviceId: String, credentialJson: String): Boolean + override fun loadThpCredential(deviceId: String): String? +} +``` + +### TrezorService.kt +Suspending wrapper for FFI calls: ```kotlin -import com.synonym.bitkitcore.* - -fun interactWithTrezor() { - try { - // Get device features - val featuresResult = trezorGetFeatures( - callbackUrl = "myapp://trezor/callback", - requestId = null, - trezorEnvironment = TrezorEnvironment.LOCAL - ) - println("Features deep link: ${featuresResult.url}") - println("Request ID: ${featuresResult.requestId}") - - // Get an address - val addressResult = trezorGetAddress( - path = "m/84'/0'/0'/0/0", - callbackUrl = "myapp://trezor/callback", - requestId = null, - trezorEnvironment = TrezorEnvironment.LOCAL, - address = null, - showOnTrezor = true, - chunkify = false, - useEventListener = null, - coin = "btc", - crossChain = null, - multisig = null, - scriptType = null, - unlockPath = null, - common = null - ) - println("Address deep link: ${addressResult.url}") - println("Request ID: ${addressResult.requestId}") - - // Get account info - val accountResult = trezorGetAccountInfo( - coin = "btc", - callbackUrl = "myapp://trezor/callback", - requestId = null, - trezorEnvironment = TrezorEnvironment.LOCAL, - path = "m/84'/0'/0'", - descriptor = null, - details = AccountInfoDetails.BASIC, - tokens = null, - page = null, - pageSize = null, - from = null, - to = null, - gap = null, - contractFilter = null, - marker = null, - defaultAccountType = null, - suppressBackupWarning = null, - common = null - ) - println("Account info deep link: ${accountResult.url}") - println("Request ID: ${accountResult.requestId}") - - // Sign a transaction - val inputs = listOf( - TxInputType( - prevHash = "b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac", - prevIndex = 0u, - amount = 3431747u, - sequence = null, - addressN = listOf( - (44 or 0x80000000).toUInt(), - (0 or 0x80000000).toUInt(), - (2 or 0x80000000).toUInt(), - 1u, - 0u - ), - scriptType = ScriptType.SPEND_ADDRESS, - multisig = null, - scriptPubkey = null, - scriptSig = null, - witness = null, - ownershipProof = null, - commitmentData = null, - origHash = null, - origIndex = null, - coinjoinFlags = null - ) - ) - - val outputs = listOf( - TxOutputType( - address = null, - addressN = listOf( - (44 or 0x80000000).toUInt(), - (0 or 0x80000000).toUInt(), - (2 or 0x80000000).toUInt(), - 1u, - 1u - ), - amount = 3181747u, - scriptType = ScriptType.PAY_TO_ADDRESS, - multisig = null, - opReturnData = null, - origHash = null, - origIndex = null, - paymentReqIndex = null - ), - TxOutputType( - address = "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2", - addressN = null, - amount = 200000u, - scriptType = ScriptType.PAY_TO_ADDRESS, - multisig = null, - opReturnData = null, - origHash = null, - origIndex = null, - paymentReqIndex = null - ) - ) - - val signResult = trezorSignTransaction( - coin = "btc", - inputs = inputs, - outputs = outputs, - callbackUrl = "myapp://trezor/callback", - requestId = null, - trezorEnvironment = TrezorEnvironment.LOCAL, - refTxs = null, - paymentRequests = null, - locktime = null, - version = null, - expiry = null, - versionGroupId = null, - overwintered = null, - timestamp = null, - branchId = null, - push = false, - amountUnit = null, - unlockPath = null, - serialize = null, - chunkify = null, - common = null - ) - println("Sign transaction deep link: ${signResult.url}") - println("Request ID: ${signResult.requestId}") - - // Handle a callback from Trezor when received - val callbackUrl = "myapp://trezor/callback?id=abc123&response={...}" - val response = trezorHandleDeepLink(callbackUrl = callbackUrl) - - when (response) { - is TrezorResponsePayload.Features -> { - println("Received Features:") - println("Device: ${response.vendor} ${response.majorVersion}.${response.minorVersion}.${response.patchVersion}") - println("Device ID: ${response.deviceId}") - } - is TrezorResponsePayload.Address -> { - println("Received Address:") - println("Address: ${response.address}") - println("Path: ${response.serializedPath}") - } - is TrezorResponsePayload.PublicKey -> { - println("Received Public Key:") - println("XPUB: ${response.xpub}") - println("Path: ${response.serializedPath}") - } - is TrezorResponsePayload.AccountInfo -> { - println("Received Account Info:") - println("Account ID: ${response.id}") - println("Descriptor: ${response.descriptor}") - println("Balance: ${response.balance}") - } - is TrezorResponsePayload.VerifyMessage -> { - println("Received Verify Message Result:") - println("Result: ${response.message}") - } - is TrezorResponsePayload.MessageSignature -> { - println("Received Message Signature:") - println("Address: ${response.address}") - println("Signature: ${response.signature}") - } - is TrezorResponsePayload.SignedTransaction -> { - println("Received Signed Transaction:") - println("Signatures: ${response.signatures}") - println("Serialized TX: ${response.serializedTx}") - response.txid?.let { txid -> - println("Transaction ID: $txid") - } - } - } - - } catch (e: TrezorConnectError) { - when (e) { - is TrezorConnectError.SerdeError -> println("Serialization error: ${e.errorDetails}") - is TrezorConnectError.UrlError -> println("URL error: ${e.errorDetails}") - is TrezorConnectError.EnvironmentError -> println("Environment error: ${e.errorDetails}") - is TrezorConnectError.ClientError -> println("Client error: ${e.errorDetails}") - is TrezorConnectError.Other -> println("Other error: ${e.errorDetails}") - } - } +@Singleton +class TrezorService @Inject constructor(private val transport: TrezorTransport) { + suspend fun initialize(credentialPath: String?) = ServiceQueue.CORE.background { ... } + suspend fun scan(): List = ServiceQueue.CORE.background { ... } + suspend fun connect(deviceId: String): TrezorFeatures = ServiceQueue.CORE.background { ... } + suspend fun getAddress(...): TrezorAddressResponse = ServiceQueue.CORE.background { ... } + suspend fun signMessage(...): TrezorSignedMessageResponse = ServiceQueue.CORE.background { ... } + suspend fun verifyMessage(...): Boolean = ServiceQueue.CORE.background { ... } + suspend fun disconnect() = ServiceQueue.CORE.background { ... } } ``` -### Python -```python -from bitkitcore import ( - trezor_get_features, trezor_get_address, trezor_get_account_info, - trezor_sign_message, trezor_verify_message, trezor_sign_transaction, trezor_handle_deep_link, - TrezorEnvironment, TrezorConnectError, AccountInfoDetails, - TxInputType, TxOutputType, ScriptType +### TrezorRepo.kt +State management with Kotlin Flow: +```kotlin +data class TrezorState( + val isInitialized: Boolean = false, + val isScanning: Boolean = false, + val isConnecting: Boolean = false, + val devices: List = emptyList(), + val connectedDevice: TrezorFeatures? = null, + val lastAddress: TrezorAddressResponse? = null, + val error: String? = null, ) -try: - # Get device features - features_result = trezor_get_features( - callback_url="myapp://trezor/callback", - request_id=None, - trezor_environment=TrezorEnvironment.LOCAL - ) - print(f"Features deep link: {features_result.url}") - print(f"Request ID: {features_result.request_id}") - - # Get an address - address_result = trezor_get_address( - path="m/84'/0'/0'/0/0", - callback_url="myapp://trezor/callback", - request_id=None, - trezor_environment=TrezorEnvironment.LOCAL, - address=None, - show_on_trezor=True, - chunkify=False, - use_event_listener=None, - coin="btc", - cross_chain=None, - multisig=None, - script_type=None, - unlock_path=None, - common=None - ) - print(f"Address deep link: {address_result.url}") - print(f"Request ID: {address_result.request_id}") - - # Get account info - account_result = trezor_get_account_info( - coin="btc", - callback_url="myapp://trezor/callback", - request_id=None, - trezor_environment=TrezorEnvironment.LOCAL, - path="m/84'/0'/0'", - descriptor=None, - details=AccountInfoDetails.BASIC, - tokens=None, - page=None, - page_size=None, - from_block=None, - to_block=None, - gap=None, - contract_filter=None, - marker=None, - default_account_type=None, - suppress_backup_warning=None, - common=None - ) - print(f"Account info deep link: {account_result.url}") - print(f"Request ID: {account_result.request_id}") - - # Verify a message - verify_message_result = trezor_verify_message( - address="3BD8TL6iShVzizQzvo789SuynEKGpLTms9", - signature="JO7vL3tOB1qQyfSeIVLvdEw9G1tCvL+lNj78XDAVM4t6UptADs3kXDTO2+2ZeEOLFL4/+wm+BBdSpo3kb3Cnsas=", - message="example message", - coin="btc", - callback_url="myapp://trezor/callback", - request_id=None, - trezor_environment=TrezorEnvironment.LOCAL, - hex=False, - common=None - ) - print(f"Verify message deep link: {verify_message_result.url}") - print(f"Request ID: {verify_message_result.request_id}") - - # Sign a message - sign_message_result = trezor_sign_message( - path="m/44'/0'/0'", - message="Hello World!", - callback_url="myapp://trezor/callback", - request_id=None, - trezor_environment=TrezorEnvironment.LOCAL, - coin="btc", - hex=False, - no_script_type=False, - common=None - ) - print(f"Sign message deep link: {sign_message_result.url}") - print(f"Request ID: {sign_message_result.request_id}") - - # Sign a transaction - inputs = [ - TxInputType( - prev_hash="b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac", - prev_index=0, - amount=3431747, - sequence=None, - address_n=[ - 44 | 0x80000000, - 0 | 0x80000000, - 2 | 0x80000000, - 1, - 0 - ], - script_type=ScriptType.SPEND_ADDRESS, - multisig=None, - script_pubkey=None, - script_sig=None, - witness=None, - ownership_proof=None, - commitment_data=None, - orig_hash=None, - orig_index=None, - coinjoin_flags=None - ) - ] - - outputs = [ - TxOutputType( - address=None, - address_n=[ - 44 | 0x80000000, - 0 | 0x80000000, - 2 | 0x80000000, - 1, - 1 - ], - amount=3181747, - script_type=ScriptType.PAY_TO_ADDRESS, - multisig=None, - op_return_data=None, - orig_hash=None, - orig_index=None, - payment_req_index=None - ), - TxOutputType( - address="18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2", - address_n=None, - amount=200000, - script_type=ScriptType.PAY_TO_ADDRESS, - multisig=None, - op_return_data=None, - orig_hash=None, - orig_index=None, - payment_req_index=None - ) - ] - - sign_result = trezor_sign_transaction( - coin="btc", - inputs=inputs, - outputs=outputs, - callback_url="myapp://trezor/callback", - request_id=None, - trezor_environment=TrezorEnvironment.LOCAL, - ref_txs=None, - payment_requests=None, - locktime=None, - version=None, - expiry=None, - version_group_id=None, - overwintered=None, - timestamp=None, - branch_id=None, - push=False, - amount_unit=None, - unlock_path=None, - serialize=None, - chunkify=None, - common=None - ) - print(f"Sign transaction deep link: {sign_result.url}") - print(f"Request ID: {sign_result.request_id}") - - # Handle a callback from Trezor when received - callback_url = "myapp://trezor/callback?id=abc123&response={...}" - response = trezor_handle_deep_link(callback_url=callback_url) - - if isinstance(response, TrezorResponsePayload.Features): - print("Received Features:") - print(f"Device: {response.vendor} {response.major_version}.{response.minor_version}.{response.patch_version}") - print(f"Device ID: {response.device_id}") - elif isinstance(response, TrezorResponsePayload.Address): - print("Received Address:") - print(f"Address: {response.address}") - print(f"Path: {response.serialized_path}") - elif isinstance(response, TrezorResponsePayload.PublicKey): - print("Received Public Key:") - print(f"XPUB: {response.xpub}") - print(f"Path: {response.serialized_path}") - elif isinstance(response, TrezorResponsePayload.AccountInfo): - print("Received Account Info:") - print(f"Account ID: {response.id}") - print(f"Descriptor: {response.descriptor}") - print(f"Balance: {response.balance}") - elif isinstance(response, TrezorResponsePayload.VerifyMessage): - print("Received Verify Message Result:") - print(f"Result: {response.message}") - elif isinstance(response, TrezorResponsePayload.MessageSignature): - print("Received Message Signature:") - print(f"Address: {response.address}") - print(f"Signature: {response.signature}") - elif isinstance(response, TrezorResponsePayload.SignedTransaction): - print("Received Signed Transaction:") - print(f"Signatures: {response.signatures}") - print(f"Serialized TX: {response.serialized_tx}") - if response.txid: - print(f"Transaction ID: {response.txid}") - -except TrezorConnectError as e: - if isinstance(e, TrezorConnectError.SerdeError): - print(f"Serialization error: {e.error_details}") - elif isinstance(e, TrezorConnectError.UrlError): - print(f"URL error: {e.error_details}") - elif isinstance(e, TrezorConnectError.EnvironmentError): - print(f"Environment error: {e.error_details}") - elif isinstance(e, TrezorConnectError.ClientError): - print(f"Client error: {e.error_details}") - elif isinstance(e, TrezorConnectError.Other): - print(f"Other error: {e.error_details}") +@Singleton +class TrezorRepo @Inject constructor(...) { + private val _state = MutableStateFlow(TrezorState()) + val state = _state.asStateFlow() + + val needsPairingCode = trezorTransport.needsPairingCode // For UI dialog + + suspend fun initialize(): Result + suspend fun scan(): Result> + suspend fun connect(deviceId: String): Result + suspend fun getAddress(...): Result + // ... +} +``` + +### TrezorViewModel.kt +UI state and actions: +```kotlin +@HiltViewModel +class TrezorViewModel @Inject constructor( + private val trezorRepo: TrezorRepo, +) : ViewModel() { + val trezorState = trezorRepo.state.stateIn(...) + val needsPairingCode = trezorRepo.needsPairingCode.stateIn(...) + + fun initialize() { ... } + fun scan() { ... } + fun connect() { ... } + fun getAddress(showOnTrezor: Boolean) { ... } + fun signMessage() { ... } + fun verifyMessage() { ... } + fun disconnect() { ... } + + fun submitPairingCode(code: String) { ... } + fun cancelPairingCode() { ... } +} ``` -## Implementation Details +## BLE Characteristics (Trezor Safe 3/5) + +``` +Service UUID: 8c000001-a59b-4d58-a9ad-073df69fa1b1 +Read Characteristic: 8c000002-a59b-4d58-a9ad-073df69fa1b1 +Write Characteristic: 8c000003-a59b-4d58-a9ad-073df69fa1b1 +Chunk Size: 244 bytes +``` -The module uses deep linking to communicate with Trezor devices via the Trezor Suite Lite. The workflow involves: +## Common Issues -1. Generating a deep link with the requested operation parameters -2. Opening the deep link, which launches Trezor Suite Lite -3. User interacts with their Trezor device through Trezor Suite Lite -4. After completion, Trezor Suite Lite calls the provided callback URL -5. The application handles the callback and processes the response +### 1. Pairing Code Requested Every Time +**Cause:** Creating new `CallbackTransport` for each operation instead of reusing `ConnectedDevice`. +**Fix:** Store `ConnectedDevice` after `connect()` and reuse for all operations. -### Message Signing and Verification +### 2. BLE Read Timeout +**Cause:** Multi-chunk responses not fully received. +**Fix:** Loop reading until complete message assembled (check continuation bit in THP header). -The module supports both message signing and verification: +### 3. Credential Persistence Not Working +**Cause:** Credentials not saved after pairing or not loaded before handshake. +**Fix:** Ensure `save_thp_credential` called after successful pairing, `load_thp_credential` called before handshake. -- **Message Signing** (`signMessage`): Signs a message using a private key derived from a BIP32 path -- **Message Verification** (`verifyMessage`): Verifies a signature against a message and signer address +## Building -Both operations support: -- **Text Messages**: Plain text messages -- **Hex Messages**: Messages encoded in hexadecimal format -- **Coin Support**: Specify the coin type for network-specific behavior -- **Address Types**: Support for all Bitcoin address types (Legacy, SegWit, Native SegWit) +### Build for Android +```bash +cd bitkit-core +./build_android.sh +cd ../bitkit-android +JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home ./gradlew assembleDevDebug +``` -### Transaction Signing +### Regenerate Kotlin Bindings Only +```bash +cd bitkit-core +cargo build +cargo run --bin uniffi-bindgen generate \ + --library target/debug/libbitkitcore.dylib \ + --language kotlin \ + --out-dir bindings/android/lib/src/main/kotlin +``` -The `signTransaction` method supports: -- **Multiple Script Types**: SpendAddress, SpendMultisig, SpendWitness, SpendP2SHWitness, SpendTaproot, etc. -- **Reference Transactions**: Include `refTxs` for providing transaction history when using custom backends -- **Payment Requests**: Support for SLIP-24 payment requests -- **Various Coins**: Bitcoin, Testnet, and other supported cryptocurrencies -- **Advanced Features**: RBF (Replace-by-Fee), Coinjoin, Multisig transactions -- **Display Options**: Amount units, address chunking, transaction broadcasting +## Testing -## Error Handling +Use `TrezorTestView.kt` in the app (dev builds only) to test: +1. Initialize - Sets up transport callback +2. Scan - Discovers USB and BLE devices +3. Connect - Opens connection, triggers pairing for BLE +4. Get Address - Derives Bitcoin address +5. Sign Message - Signs with device confirmation +6. Verify Message - Verifies signature on device +7. Disconnect - Closes connection -### TrezorConnectError -- `SerdeError`: Serialization/deserialization errors with JSON data -- `UrlError`: URL parsing or formatting errors -- `EnvironmentError`: Environment-related errors (e.g., unavailable environment) -- `ClientError`: Failed to create the client or client operation errors -- `Other`: General errors not covered by other categories +## References -Each error includes detailed information about what went wrong in the `error_details` field. \ No newline at end of file +- [Trezor Documentation](https://docs.trezor.io/) +- [THP Protocol Specification](https://github.com/trezor/trezor-firmware/blob/main/docs/common/communication/thp.md) +- [UniFFI Documentation](https://mozilla.github.io/uniffi-rs/) diff --git a/src/modules/trezor/callbacks.rs b/src/modules/trezor/callbacks.rs new file mode 100644 index 0000000..2ca94ea --- /dev/null +++ b/src/modules/trezor/callbacks.rs @@ -0,0 +1,276 @@ +//! Trezor callback infrastructure for native transport and UI operations. +//! +//! These types and traits bridge the Rust trezor-connect-rs library with +//! native iOS/Android implementations via UniFFI callback interfaces. + +use std::sync::Arc; +use once_cell::sync::OnceCell; + +// ============================================================================ +// Transport callback types +// ============================================================================ + +/// Result from a transport read operation +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorTransportReadResult { + /// Whether the read succeeded + pub success: bool, + /// Data read (empty on failure) + pub data: Vec, + /// Error message (empty on success) + pub error: String, +} + +/// Result from a transport write or open operation +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorTransportWriteResult { + /// Whether the operation succeeded + pub success: bool, + /// Error message (empty on success) + pub error: String, +} + +/// Result from a high-level message call (for BLE/THP devices) +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorCallMessageResult { + /// Whether the call succeeded + pub success: bool, + /// Response message type + pub message_type: u16, + /// Response protobuf data + pub data: Vec, + /// Error message (empty on success) + pub error: String, +} + +/// Native device information returned from enumeration +#[derive(Debug, Clone, uniffi::Record)] +pub struct NativeDeviceInfo { + /// Unique path/identifier for this device + pub path: String, + /// Transport type: "usb" or "bluetooth" + pub transport_type: String, + /// Optional device name (from BLE advertisement or USB descriptor) + pub name: Option, + /// USB Vendor ID (for USB devices) + pub vendor_id: Option, + /// USB Product ID (for USB devices) + pub product_id: Option, +} + +// ============================================================================ +// Callback traits +// ============================================================================ + +/// Callback interface for native Trezor transport operations +/// +/// 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. +#[uniffi::export(with_foreign)] +pub trait TrezorTransportCallback: Send + Sync { + /// Enumerate all connected Trezor devices + fn enumerate_devices(&self) -> Vec; + + /// Open a connection to a device + fn open_device(&self, path: String) -> TrezorTransportWriteResult; + + /// Close the connection to a device + fn close_device(&self, path: String) -> TrezorTransportWriteResult; + + /// Read a chunk of data from the device + fn read_chunk(&self, path: String) -> TrezorTransportReadResult; + + /// Write a chunk of data to the device + fn write_chunk(&self, path: String, data: Vec) -> TrezorTransportWriteResult; + + /// Get the chunk size for a device (64 for USB, 244 for Bluetooth) + fn get_chunk_size(&self, path: String) -> u32; + + /// 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 + fn call_message(&self, path: String, message_type: u16, data: Vec) -> Option; + + /// 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. + fn get_pairing_code(&self) -> 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. + fn save_thp_credential(&self, device_id: String, credential_json: 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. + fn load_thp_credential(&self, device_id: String) -> Option; + + /// 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 + fn log_debug(&self, tag: String, message: String); +} + +// ============================================================================ +// UI callback trait +// ============================================================================ + +/// 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. +/// +/// Methods return `String`: +/// - Empty string (`""`) = cancel the request +/// - Non-empty string = the user's input (PIN or passphrase) +/// +/// This matches the existing `get_pairing_code` pattern used in `TrezorTransportCallback`. +#[uniffi::export(with_foreign)] +pub trait TrezorUiCallback: Send + Sync { + /// Called when the device requests a PIN. + /// + /// Show a PIN matrix UI and return the matrix-encoded PIN string. + /// Return empty string to cancel. + fn on_pin_request(&self) -> String; + + /// Called when the device requests a passphrase. + /// + /// If `on_device` is true, the user should enter on the Trezor itself — + /// return any non-empty string (e.g., "ok") to acknowledge. + /// + /// If `on_device` is false, show a passphrase input UI and return the value. + /// Return empty string to cancel. + fn on_passphrase_request(&self, on_device: bool) -> String; +} + +// ============================================================================ +// Global callback holders +// ============================================================================ + +/// Global transport callback holder +static TRANSPORT_CALLBACK: OnceCell> = OnceCell::new(); + +/// Global UI callback holder +static UI_CALLBACK: OnceCell> = OnceCell::new(); + +/// Initialize the Trezor transport with a native callback implementation +/// +/// This must be called before any Trezor scanning/connection operations. +/// The native layer (iOS/Android) must implement the TrezorTransportCallback interface. +#[uniffi::export] +pub fn trezor_set_transport_callback(callback: Arc) { + #[cfg(target_os = "android")] + crate::init_android_logger(); + let _ = TRANSPORT_CALLBACK.set(callback); +} + +/// Get the transport callback (internal use) +pub fn get_transport_callback() -> Option<&'static Arc> { + TRANSPORT_CALLBACK.get() +} + +/// Set the UI callback for handling PIN and passphrase requests. +/// +/// This should be called before connecting to a Trezor device if you want +/// the library to handle PIN/passphrase requests via your UI instead of +/// returning errors. +#[uniffi::export] +pub fn trezor_set_ui_callback(callback: Arc) { + let _ = UI_CALLBACK.set(callback); +} + +/// Get the UI callback (internal use) +pub fn get_ui_callback() -> Option<&'static Arc> { + UI_CALLBACK.get() +} + +// ============================================================================ +// BLE initialization +// ============================================================================ + +/// Track if BLE has been initialized on Android +#[cfg(target_os = "android")] +static BLE_INITIALIZED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); + +/// Check if BLE has been initialized. +/// +/// On Android: Returns true if BluetoothInit.nativeInit() was called successfully. +/// On other platforms: Always returns true (BLE works natively). +#[uniffi::export] +pub fn trezor_is_ble_available() -> bool { + #[cfg(target_os = "android")] + { + use std::sync::atomic::Ordering; + BLE_INITIALIZED.load(Ordering::SeqCst) + } + #[cfg(not(target_os = "android"))] + { + true + } +} + +/// Mark BLE as initialized (called from JNI on Android) +#[cfg(target_os = "android")] +pub fn set_ble_initialized(value: bool) { + use std::sync::atomic::Ordering; + BLE_INITIALIZED.store(value, Ordering::SeqCst); +} + +/// Check if BLE is initialized (used by JNI function in lib.rs) +#[cfg(target_os = "android")] +pub fn is_ble_initialized() -> bool { + use std::sync::atomic::Ordering; + BLE_INITIALIZED.load(Ordering::SeqCst) +} diff --git a/src/modules/trezor/errors.rs b/src/modules/trezor/errors.rs index 30b5704..9b04ac6 100644 --- a/src/modules/trezor/errors.rs +++ b/src/modules/trezor/errors.rs @@ -1,51 +1,285 @@ use thiserror::Error; -/// Error types for Trezor Connect operations +/// Trezor-related errors exposed via FFI. #[derive(uniffi::Error, Debug, Error)] #[non_exhaustive] -pub enum TrezorConnectError { - #[error("Serialization error: {error_details}")] - /// Error during serialization/deserialization - SerdeError { - error_details: String, - }, - - #[error("URL error: {error_details}")] - /// Error with URL parsing or formatting - UrlError { - error_details: String, - }, - - #[error("Environment error: {error_details}")] - /// Environment-related errors - EnvironmentError { - error_details: String, - }, - - #[error("Error: {error_details}")] - /// General errors - Other { - error_details: String, - }, - - #[error("Unable to create client: {error_details}")] - ClientError { - error_details: String, - }, -} +pub enum TrezorError { + /// Transport layer error (USB/Bluetooth communication) + #[error("Transport error: {error_details}")] + TransportError { error_details: String }, -impl From for TrezorConnectError { - fn from(error: serde_json::Error) -> Self { - Self::SerdeError { - error_details: error.to_string(), - } - } + /// No Trezor device found + #[error("No Trezor device found")] + DeviceNotFound, + + /// Device disconnected during operation + #[error("Device disconnected during operation")] + DeviceDisconnected, + + /// Connection error + #[error("Connection error: {error_details}")] + ConnectionError { error_details: String }, + + /// Protocol error (encoding/decoding) + #[error("Protocol error: {error_details}")] + ProtocolError { error_details: String }, + + /// Pairing required for Bluetooth connection + #[error("Pairing required")] + PairingRequired, + + /// Pairing failed + #[error("Pairing failed: {error_details}")] + PairingFailed { error_details: String }, + + /// PIN is required + #[error("PIN is required")] + PinRequired, + + /// PIN entry cancelled + #[error("PIN entry cancelled")] + PinCancelled, + + /// Invalid PIN entered + #[error("Invalid PIN")] + InvalidPin, + + /// Passphrase is required + #[error("Passphrase is required")] + PassphraseRequired, + + /// Action cancelled by user on device + #[error("Action cancelled by user")] + UserCancelled, + + /// Operation timed out + #[error("Operation timed out")] + Timeout, + + /// Invalid derivation path + #[error("Invalid path: {error_details}")] + InvalidPath { error_details: String }, + + /// Device returned an error + #[error("Device error: {error_details}")] + DeviceError { error_details: String }, + + /// Trezor manager not initialized + #[error("Trezor not initialized. Call trezor_initialize first.")] + NotInitialized, + + /// No device connected + #[error("No device connected. Call trezor_connect first.")] + NotConnected, + + /// Session error + #[error("Session error: {error_details}")] + SessionError { error_details: String }, + + /// IO error + #[error("IO error: {error_details}")] + IoError { error_details: String }, } -impl From for TrezorConnectError { - fn from(error: url::ParseError) -> Self { - Self::UrlError { - error_details: error.to_string(), +impl From for TrezorError { + fn from(err: trezor_connect_rs::TrezorError) -> Self { + use trezor_connect_rs::error::{ + BitcoinError, DeviceError as TcDeviceError, ProtocolError as TcProtocolError, + SessionError as TcSessionError, ThpError, TransportError as TcTransportError, + }; + use trezor_connect_rs::TrezorError as TE; + + match err { + // Top-level errors + TE::Cancelled => TrezorError::UserCancelled, + TE::Timeout => TrezorError::Timeout, + TE::IoError(msg) => TrezorError::IoError { + error_details: msg, + }, + + // Transport errors + TE::Transport(transport_err) => match transport_err { + TcTransportError::DeviceNotFound => TrezorError::DeviceNotFound, + TcTransportError::DeviceDisconnected => TrezorError::DeviceDisconnected, + TcTransportError::DeviceBusy => TrezorError::ConnectionError { + error_details: "Device is busy".to_string(), + }, + TcTransportError::UnableToOpen(msg) => TrezorError::TransportError { + error_details: format!("Unable to open device: {}", msg), + }, + TcTransportError::UnableToClose(msg) => TrezorError::TransportError { + error_details: format!("Unable to close device: {}", msg), + }, + TcTransportError::DataTransfer(msg) => TrezorError::TransportError { + error_details: format!("Data transfer error: {}", msg), + }, + TcTransportError::PermissionDenied(msg) => TrezorError::TransportError { + error_details: format!("Permission denied: {}", msg), + }, + #[cfg(feature = "usb")] + TcTransportError::Usb(msg) => TrezorError::TransportError { + error_details: format!("USB error: {}", msg), + }, + #[cfg(feature = "bluetooth")] + TcTransportError::Bluetooth(msg) => TrezorError::TransportError { + error_details: format!("Bluetooth error: {}", msg), + }, + #[allow(unreachable_patterns)] + _ => TrezorError::TransportError { + error_details: transport_err.to_string(), + }, + }, + + // Protocol errors + TE::Protocol(protocol_err) => match protocol_err { + TcProtocolError::Malformed(msg) => TrezorError::ProtocolError { + error_details: format!("Malformed message: {}", msg), + }, + TcProtocolError::InvalidMessageType(mt) => TrezorError::ProtocolError { + error_details: format!("Invalid message type: {}", mt), + }, + TcProtocolError::MessageTooShort { expected, actual } => { + TrezorError::ProtocolError { + error_details: format!( + "Message too short: expected {}, got {}", + expected, actual + ), + } + } + TcProtocolError::InvalidHeader => TrezorError::ProtocolError { + error_details: "Invalid header".to_string(), + }, + TcProtocolError::ChunkHeaderMismatch => TrezorError::ProtocolError { + error_details: "Chunk header mismatch".to_string(), + }, + TcProtocolError::ProtobufEncode(msg) => TrezorError::ProtocolError { + error_details: format!("Protobuf encode error: {}", msg), + }, + TcProtocolError::ProtobufDecode(msg) => TrezorError::ProtocolError { + error_details: format!("Protobuf decode error: {}", msg), + }, + TcProtocolError::UnexpectedResponse { expected, actual } => { + TrezorError::ProtocolError { + error_details: format!( + "Unexpected response: expected {}, got {}", + expected, actual + ), + } + } + }, + + // Device errors + TE::Device(device_err) => match device_err { + TcDeviceError::NotConnected => TrezorError::NotConnected, + TcDeviceError::ActionCancelled => TrezorError::UserCancelled, + TcDeviceError::PinRequired => TrezorError::PinRequired, + TcDeviceError::InvalidPin => TrezorError::InvalidPin, + TcDeviceError::PinCancelled => TrezorError::PinCancelled, + TcDeviceError::PassphraseRequired => TrezorError::PassphraseRequired, + TcDeviceError::NotInitialized => TrezorError::DeviceError { + error_details: "Device is not initialized".to_string(), + }, + TcDeviceError::FirmwareUpdateRequired => TrezorError::DeviceError { + error_details: "Firmware update required".to_string(), + }, + TcDeviceError::SeedNotBackedUp => TrezorError::DeviceError { + error_details: "Seed is not backed up".to_string(), + }, + TcDeviceError::NotSupported(msg) => TrezorError::DeviceError { + error_details: format!("Feature not supported: {}", msg), + }, + TcDeviceError::Failure { code, message } => TrezorError::DeviceError { + error_details: format!("Device failure (code {:?}): {}", code, message), + }, + TcDeviceError::DeviceError { code, message } => TrezorError::DeviceError { + error_details: format!("Device error (code {}): {}", code, message), + }, + TcDeviceError::ButtonRequest(msg) => TrezorError::DeviceError { + error_details: format!("Button request: {}", msg), + }, + TcDeviceError::ProtobufDecode(msg) => TrezorError::ProtocolError { + error_details: format!("Protobuf decode error: {}", msg), + }, + TcDeviceError::InvalidInput(msg) => TrezorError::DeviceError { + error_details: format!("Invalid input: {}", msg), + }, + }, + + // THP (Trezor Host Protocol) errors + TE::Thp(thp_err) => match thp_err { + ThpError::PairingRequired => TrezorError::PairingRequired, + ThpError::PairingFailed(msg) => TrezorError::PairingFailed { + error_details: msg, + }, + ThpError::InvalidCredentials => TrezorError::PairingFailed { + error_details: "Invalid credentials".to_string(), + }, + ThpError::ChannelAllocationFailed => TrezorError::ConnectionError { + error_details: "THP channel allocation failed".to_string(), + }, + ThpError::HandshakeFailed(msg) => TrezorError::ConnectionError { + error_details: format!("THP handshake failed: {}", msg), + }, + ThpError::EncryptionError(msg) => TrezorError::ProtocolError { + error_details: format!("THP encryption error: {}", msg), + }, + ThpError::DecryptionError(msg) => TrezorError::ProtocolError { + error_details: format!("THP decryption error: {}", msg), + }, + ThpError::AckNotReceived => TrezorError::ProtocolError { + error_details: "THP ACK not received".to_string(), + }, + ThpError::InvalidSyncBit => TrezorError::ProtocolError { + error_details: "THP invalid sync bit".to_string(), + }, + ThpError::StateMissing => TrezorError::SessionError { + error_details: "THP state missing".to_string(), + }, + ThpError::SessionError(msg) => TrezorError::SessionError { + error_details: format!("THP session error: {}", msg), + }, + }, + + // Session errors + TE::Session(session_err) => match session_err { + TcSessionError::NotFound => TrezorError::SessionError { + error_details: "Session not found".to_string(), + }, + TcSessionError::WrongPrevious => TrezorError::SessionError { + error_details: "Wrong previous session".to_string(), + }, + TcSessionError::AlreadyAcquired => TrezorError::SessionError { + error_details: "Session already acquired by another client".to_string(), + }, + TcSessionError::Expired => TrezorError::SessionError { + error_details: "Session expired".to_string(), + }, + }, + + // Bitcoin errors + TE::Bitcoin(bitcoin_err) => match bitcoin_err { + BitcoinError::InvalidPath(msg) => TrezorError::InvalidPath { + error_details: msg, + }, + BitcoinError::InvalidAddress(msg) => TrezorError::DeviceError { + error_details: format!("Invalid address: {}", msg), + }, + BitcoinError::InvalidTransaction(msg) => TrezorError::DeviceError { + error_details: format!("Invalid transaction: {}", msg), + }, + BitcoinError::InsufficientFunds => TrezorError::DeviceError { + error_details: "Insufficient funds".to_string(), + }, + BitcoinError::InvalidSignature => TrezorError::DeviceError { + error_details: "Invalid signature".to_string(), + }, + BitcoinError::NetworkMismatch { expected, actual } => TrezorError::DeviceError { + error_details: format!( + "Network mismatch: expected {}, got {}", + expected, actual + ), + }, + }, } } } diff --git a/src/modules/trezor/implementation.rs b/src/modules/trezor/implementation.rs index 33bf388..b6edda4 100644 --- a/src/modules/trezor/implementation.rs +++ b/src/modules/trezor/implementation.rs @@ -1,259 +1,927 @@ -//! # trezor-connect-rs +//! Trezor manager implementation. //! -//! A Rust library for generating Trezor Connect deep links according to the -//! Trezor Suite Lite deep linking specification. - -use serde::{Serialize}; -use serde_json; -use url::Url; -use uuid::Uuid; -use crate::modules::trezor::{AccountInfoResponse, AddressResponse, ComposeTransactionParams, ComposeTransactionResponse, DeepLinkResult, FeatureResponse, GetAccountInfoParams, GetAddressParams, GetPublicKeyParams, MessageSignatureResponse, PublicKeyResponse, SignedTransactionResponse, SignMessageParams, SignTransactionParams, TrezorConnectClient, TrezorConnectError, TrezorConnectResult, TrezorResponse, TrezorResponsePayload, VerifyMessageParams, VerifyMessageResponse}; -use crate::modules::trezor::types::{TrezorEnvironment, Empty}; - -impl TrezorEnvironment { - /// Get the base URL for the selected environment - pub fn base_url(&self) -> Result { - match self { - TrezorEnvironment::Production => { - Err(TrezorConnectError::EnvironmentError { error_details: "Production environment is not available".to_string() }) - }, - TrezorEnvironment::Development => { - Url::parse("https://dev.suite.sldev.cz/connect/develop/deeplink/1/") - .map_err(|e| TrezorConnectError::UrlError { error_details: e.to_string() }) - }, - TrezorEnvironment::Local => { - Url::parse("trezorsuitelite://connect/1/") - .map_err(|e| TrezorConnectError::UrlError { error_details: e.to_string() }) +//! On desktop platforms, this uses the trezor-connect-rs library directly. +//! On Android/iOS, this uses a callback-based transport implemented natively. + +use std::sync::Arc; +use tokio::sync::Mutex; +use base64::{engine::general_purpose, Engine as _}; + +use crate::modules::trezor::{ + TrezorAddressResponse, TrezorDeviceInfo, TrezorError, TrezorFeatures, + TrezorGetAddressParams, TrezorGetPublicKeyParams, TrezorPublicKeyResponse, + TrezorSignMessageParams, TrezorSignedMessageResponse, TrezorVerifyMessageParams, + TrezorSignTxParams, TrezorSignedTx, + TrezorTransportType, TrezorCoinType, +}; + +// Desktop: use full trezor-connect-rs +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use trezor_connect_rs::{ + ConnectedDevice, DeviceInfo, GetAddressParams, GetPublicKeyParams, + SignMessageParams, SignTxParams, VerifyMessageParams, Trezor, +}; + +// Mobile: use callback transport from trezor-connect-rs +#[cfg(any(target_os = "android", target_os = "ios"))] +use trezor_connect_rs::{ + CallbackTransport, CallbackDeviceInfo, CallbackReadResult, CallbackResult, + CallbackMessageResult, ConnectedDevice, GetAddressParams, GetPublicKeyParams, + SignMessageParams, SignTxParams, VerifyMessageParams, Transport, TransportCallback, +}; + +#[cfg(any(target_os = "android", target_os = "ios"))] +use trezor_connect_rs::device_info::{DeviceInfo, TransportType}; + +/// Validate a BIP32 derivation path. +/// +/// Valid paths must: +/// - Start with "m/" +/// - Contain only numeric indices (with optional ' or h for hardened) +/// - Have a known purpose for Bitcoin (44, 49, 84, 86) +/// +/// # Examples +/// - `m/84'/0'/0'/0/0` - valid native SegWit path +/// - `m/44'/0'/0'/0/0` - valid legacy path +/// - `m/49'/0'/0'/0/0` - valid nested SegWit path +/// - `m/86'/0'/0'/0/0` - valid Taproot path +pub(crate) fn validate_derivation_path(path: &str) -> Result<(), TrezorError> { + // Must start with "m/" + if !path.starts_with("m/") { + return Err(TrezorError::InvalidPath { + error_details: format!("Path must start with 'm/': {}", path), + }); + } + + let path_part = &path[2..]; // Skip "m/" + if path_part.is_empty() { + return Err(TrezorError::InvalidPath { + error_details: "Path cannot be empty after 'm/'".to_string(), + }); + } + + let components: Vec<&str> = path_part.split('/').collect(); + + // Validate each component + for (i, component) in components.iter().enumerate() { + if component.is_empty() { + return Err(TrezorError::InvalidPath { + error_details: format!("Empty path component at index {}", i), + }); + } + + // Check if it's hardened (ends with ' or h) + let num_str = if component.ends_with('\'') || component.ends_with('h') { + &component[..component.len() - 1] + } else { + *component + }; + + // Must be a valid number + if num_str.parse::().is_err() { + return Err(TrezorError::InvalidPath { + error_details: format!( + "Invalid path component '{}' at index {}: must be a number", + component, i + ), + }); + } + } + + // Note: We intentionally don't reject unknown purposes (like 48 for multisig) + // to maintain flexibility for advanced use cases. The device itself will + // validate if the path is appropriate for the requested operation. + + Ok(()) +} + +/// Validate sign transaction parameters before sending to the device. +/// +/// Checks input paths, script types, output structure, and change output paths. +/// Used by both `sign_tx` and `sign_tx_from_psbt` to ensure consistent validation. +fn validate_sign_tx_params(params: &SignTxParams) -> Result<(), TrezorError> { + // Validate all input paths + for (i, input) in params.inputs.iter().enumerate() { + validate_derivation_path(&input.path).map_err(|e| match e { + TrezorError::InvalidPath { error_details } => TrezorError::InvalidPath { + error_details: format!("Input {}: {}", i, error_details), }, + other => other, + })?; + } + + // Reject unsupported input script types + for (i, input) in params.inputs.iter().enumerate() { + match input.script_type { + trezor_connect_rs::ScriptType::SpendMultisig => return Err(TrezorError::DeviceError { + error_details: format!("Input {}: Multisig inputs are not currently supported.", i), + }), + trezor_connect_rs::ScriptType::External => return Err(TrezorError::DeviceError { + error_details: format!("Input {}: External inputs are not currently supported.", i), + }), + _ => {} + } + } + + // Validate at least 1 input and 1 output + if params.inputs.is_empty() { + return Err(TrezorError::DeviceError { + error_details: "Transaction must have at least one input.".to_string(), + }); + } + if params.outputs.is_empty() { + return Err(TrezorError::DeviceError { + error_details: "Transaction must have at least one output.".to_string(), + }); + } + + // Validate each output is exactly one mode: External, Change, or OpReturn + for (i, output) in params.outputs.iter().enumerate() { + let has_address = output.address.is_some(); + let has_path = output.path.is_some(); + let has_op_return = output.op_return_data.is_some(); + + match (has_address, has_path, has_op_return) { + (true, false, false) => { + // External output - valid + } + (false, true, false) => { + // Change output - must have script_type + if output.script_type.is_none() { + return Err(TrezorError::DeviceError { + error_details: format!("Output {}: change output must specify script_type.", i), + }); + } + } + (false, false, true) => { + // OP_RETURN output - amount must be 0 + if output.amount != 0 { + return Err(TrezorError::DeviceError { + error_details: format!("Output {}: OP_RETURN output must have amount 0.", i), + }); + } + } + _ => { + return Err(TrezorError::DeviceError { + error_details: format!( + "Output {}: must be exactly one of: external (address only), change (path only), or OP_RETURN (op_return_data only).", + i + ), + }); + } } } + + // Validate change output paths + for (i, output) in params.outputs.iter().enumerate() { + if let Some(ref path) = output.path { + validate_derivation_path(path).map_err(|e| match e { + TrezorError::InvalidPath { error_details } => TrezorError::InvalidPath { + error_details: format!("Output {} (change): {}", i, error_details), + }, + other => other, + })?; + } + } + + Ok(()) } -impl TrezorConnectClient { - /// Create a new TrezorConnectClient - pub fn new(environment: TrezorEnvironment, callback_base: impl AsRef) -> Result { - let callback_base = Url::parse(callback_base.as_ref())?; +/// Cached native device info for callback-based transport +#[derive(Clone, Debug)] +pub(crate) struct CachedNativeDevice { + pub(crate) path: String, + pub(crate) transport_type: TrezorTransportType, + pub(crate) name: Option, +} - Ok(Self { - environment, - callback_base, - }) +/// Adapter that implements trezor_connect_rs::TransportCallback using the UniFFI callback. +/// This bridges the trezor-connect-rs library with the native Kotlin/Swift callback. +#[cfg(any(target_os = "android", target_os = "ios"))] +struct CallbackAdapter { + callback: Arc, +} + +#[cfg(any(target_os = "android", target_os = "ios"))] +impl TransportCallback for CallbackAdapter { + fn enumerate_devices(&self) -> Vec { + let devices = self.callback.enumerate_devices(); + devices + .into_iter() + .map(|d| CallbackDeviceInfo { + path: d.path, + transport_type: d.transport_type, + name: d.name, + vendor_id: d.vendor_id, + product_id: d.product_id, + }) + .collect() } - /// Generate a deep link for a Trezor Connect method with a specific request ID - fn generate_deep_link(&self, method: &str, params: T, request_id: Option) -> TrezorConnectResult { - // Serialize params to JSON - let params_json = serde_json::to_string(¶ms)?; + fn open_device(&self, path: &str) -> CallbackResult { + let result = self.callback.open_device(path.to_string()); + CallbackResult { + success: result.success, + error: result.error, + } + } - // Get base URL directly without re-parsing - let mut url = self.environment.base_url()?; + fn close_device(&self, path: &str) -> CallbackResult { + let result = self.callback.close_device(path.to_string()); + CallbackResult { + success: result.success, + error: result.error, + } + } - // Generate a UUID if request_id is None - let id = request_id.map(|s| s.to_string()).unwrap_or_else(|| Uuid::new_v4().to_string()); + fn read_chunk(&self, path: &str) -> CallbackReadResult { + let result = self.callback.read_chunk(path.to_string()); + CallbackReadResult { + success: result.success, + data: result.data, + error: result.error, + } + } - // Create callback URL with the request ID, preserving existing query params - let mut callback_url = self.callback_base.clone(); - callback_url.query_pairs_mut().append_pair("id", &id); + fn write_chunk(&self, path: &str, data: &[u8]) -> CallbackResult { + let result = self.callback.write_chunk(path.to_string(), data.to_vec()); + CallbackResult { + success: result.success, + error: result.error, + } + } - // Add query parameters - url.query_pairs_mut() - .append_pair("method", method) - .append_pair("params", ¶ms_json) - .append_pair("callback", &callback_url.to_string()); + fn get_chunk_size(&self, path: &str) -> u32 { + self.callback.get_chunk_size(path.to_string()) + } - Ok(DeepLinkResult { - url: url.to_string(), - request_id: id, + fn call_message(&self, path: &str, message_type: u16, data: &[u8]) -> Option { + // Call the native layer's call_message implementation + let result = self.callback.call_message( + path.to_string(), + message_type, + data.to_vec(), + ); + + // Convert from TrezorCallMessageResult to CallbackMessageResult + result.map(|r| CallbackMessageResult { + success: r.success, + message_type: r.message_type, + data: r.data, + error: r.error, }) } - /// Get device features - pub fn get_features(&self, request_id: Option) -> TrezorConnectResult { - self.generate_deep_link("getFeatures", Empty {}, request_id) + fn get_pairing_code(&self) -> String { + // Call the native layer to get the pairing code from the user + self.callback.get_pairing_code() + } + + fn save_thp_credential(&self, device_id: &str, credential_json: &str) -> bool { + self.callback.save_thp_credential(device_id.to_string(), credential_json.to_string()) + } + + fn load_thp_credential(&self, device_id: &str) -> Option { + self.callback.load_thp_credential(device_id.to_string()) + } + + fn log_debug(&self, tag: &str, message: &str) { + self.callback.log_debug(tag.to_string(), message.to_string()); } +} - /// Get address for the specified path - pub fn get_address(&self, params: GetAddressParams, request_id: Option) -> TrezorConnectResult { - self.generate_deep_link("getAddress", params, request_id) +/// Adapter bridging bitkit-core's `TrezorUiCallback` (String-based, UniFFI compatible) +/// to trezor-connect-rs's `TrezorUiCallback` (Option-based). +/// +/// Conversion: empty string → `None` (cancel), non-empty → `Some(value)` (user input). +struct UiCallbackAdapter { + callback: Arc, +} + +impl trezor_connect_rs::TrezorUiCallback for UiCallbackAdapter { + fn on_pin_request(&self) -> Option { + let result = self.callback.on_pin_request(); + if result.is_empty() { None } else { Some(result) } } - /// Get public key for the specified path - pub fn get_public_key(&self, params: GetPublicKeyParams, request_id: Option) -> TrezorConnectResult { - self.generate_deep_link("getPublicKey", params, request_id) + fn on_passphrase_request(&self, on_device: bool) -> Option { + let result = self.callback.on_passphrase_request(on_device); + if result.is_empty() { None } else { Some(result) } } +} + +/// Main Trezor manager. +/// +/// On desktop: uses trezor-connect-rs library for USB/Bluetooth. +/// On mobile: uses native callbacks for USB/Bluetooth I/O. +pub struct TrezorManager { + /// The underlying trezor-connect-rs manager (desktop only) + #[cfg(not(any(target_os = "android", target_os = "ios")))] + inner: Mutex>, + + /// Currently connected device (desktop only) + #[cfg(not(any(target_os = "android", target_os = "ios")))] + connected_device: Mutex>, + + /// Cached device list from last scan (desktop only) + #[cfg(not(any(target_os = "android", target_os = "ios")))] + device_list: Mutex>, + + /// Cached native device list (mobile only) + #[cfg(any(target_os = "android", target_os = "ios"))] + native_device_list: Mutex>, + + /// Currently connected device path (mobile only) + #[cfg(any(target_os = "android", target_os = "ios"))] + connected_path: Mutex>, + + /// Currently connected device (mobile only) - reused for all operations + #[cfg(any(target_os = "android", target_os = "ios"))] + connected_device: Mutex>, - /// Get account info for the specified parameters + /// Initialization state + initialized: Mutex, +} + +impl TrezorManager { + /// Create a new TrezorManager instance. + pub fn new() -> Self { + Self { + #[cfg(not(any(target_os = "android", target_os = "ios")))] + inner: Mutex::new(None), + #[cfg(not(any(target_os = "android", target_os = "ios")))] + connected_device: Mutex::new(None), + #[cfg(not(any(target_os = "android", target_os = "ios")))] + device_list: Mutex::new(Vec::new()), + #[cfg(any(target_os = "android", target_os = "ios"))] + native_device_list: Mutex::new(Vec::new()), + #[cfg(any(target_os = "android", target_os = "ios"))] + connected_path: Mutex::new(None), + #[cfg(any(target_os = "android", target_os = "ios"))] + connected_device: Mutex::new(None), + initialized: Mutex::new(false), + } + } + + /// Initialize the Trezor manager. /// - /// This method supports three modes of operation: - /// 1. Using path - provide path and coin - /// 2. Using descriptor - provide descriptor (public key or address) and coin - /// 3. Using discovery - provide only coin, BIP-0044 account discovery is performed - pub fn get_account_info(&self, params: GetAccountInfoParams, request_id: Option) -> TrezorConnectResult { - // Validate that at least one valid configuration is present - if params.path.is_none() && params.descriptor.is_none() { - // This is discovery mode - just need the coin which is already required - } else if params.path.is_some() && params.descriptor.is_some() { - // This is ambiguous - both path and descriptor provided - return Err(TrezorConnectError::Other { - error_details: "Both path and descriptor provided. Use either path-based or descriptor-based parameters, not both.".to_string() - }); + /// On mobile: Verifies that the transport callback is set. + /// On desktop: Initializes trezor-connect-rs library. + pub async fn initialize(&self, _credential_path: Option) -> Result<(), TrezorError> { + // Mobile: Just verify callback is set + #[cfg(any(target_os = "android", target_os = "ios"))] + { + use crate::get_transport_callback; + if get_transport_callback().is_none() { + return Err(TrezorError::NotInitialized); + } + let mut initialized = self.initialized.lock().await; + *initialized = true; + Ok(()) } - self.generate_deep_link("getAccountInfo", params, request_id) + // Desktop: Initialize trezor-connect-rs + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + let mut builder = Trezor::new() + .with_app_identity("Bitkit", "Bitkit"); + + if let Some(ref path) = _credential_path { + builder = builder.with_credential_store(path); + } + + let trezor = builder.build().await.map_err(TrezorError::from)?; + + let mut inner = self.inner.lock().await; + *inner = Some(trezor); + + let mut initialized = self.initialized.lock().await; + *initialized = true; + + Ok(()) + } } - /// Compose transaction for Bitcoin and Bitcoin-like coins + /// Check if the manager is initialized. + pub async fn is_initialized(&self) -> bool { + *self.initialized.lock().await + } + + /// Scan for available Trezor devices (USB + Bluetooth). /// - /// This method works in two modes: - /// 1. Payment mode: Requests payment to outputs with account discovery and fee selection - /// 2. Precompose mode: Prepares transaction variants with provided account and fee levels - pub fn compose_transaction(&self, params: ComposeTransactionParams, request_id: Option) -> TrezorConnectResult { - self.generate_deep_link("composeTransaction", params, request_id) + /// On mobile: Uses native callback to enumerate devices. + /// On desktop: Uses trezor-connect-rs library. + pub async fn scan(&self) -> Result, TrezorError> { + if !*self.initialized.lock().await { + return Err(TrezorError::NotInitialized); + } + + // Mobile: Use callback-based enumeration + #[cfg(any(target_os = "android", target_os = "ios"))] + { + use crate::get_transport_callback; + + let callback = get_transport_callback() + .ok_or(TrezorError::NotInitialized)?; + + let native_devices = callback.enumerate_devices(); + + // Cache the device list + let mut device_list = self.native_device_list.lock().await; + device_list.clear(); + + let result: Vec = native_devices + .into_iter() + .map(|d| { + let transport_type = if d.transport_type == "bluetooth" { + TrezorTransportType::Bluetooth + } else { + TrezorTransportType::Usb + }; + + // Cache for later connection + device_list.push(CachedNativeDevice { + path: d.path.clone(), + transport_type: transport_type.clone(), + name: d.name.clone(), + }); + + TrezorDeviceInfo { + id: d.path.clone(), + transport_type, + name: d.name, + path: d.path, + label: None, + model: None, + is_bootloader: false, + } + }) + .collect(); + + Ok(result) + } + + // Desktop: Use trezor-connect-rs + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + let mut inner = self.inner.lock().await; + let trezor = inner.as_mut().ok_or(TrezorError::NotInitialized)?; + + let devices = trezor.scan().await.map_err(TrezorError::from)?; + + // Cache the device list for later connection + let mut device_list = self.device_list.lock().await; + *device_list = devices.clone(); + + Ok(devices.into_iter().map(TrezorDeviceInfo::from).collect()) + } + } + + /// List previously discovered devices without triggering a new scan. + pub async fn list_devices(&self) -> Result, TrezorError> { + if !*self.initialized.lock().await { + return Err(TrezorError::NotInitialized); + } + + // Mobile: Return cached devices + #[cfg(any(target_os = "android", target_os = "ios"))] + { + let device_list = self.native_device_list.lock().await; + Ok(device_list + .iter() + .map(|d| TrezorDeviceInfo { + id: d.path.clone(), + transport_type: d.transport_type.clone(), + name: d.name.clone(), + path: d.path.clone(), + label: None, + model: None, + is_bootloader: false, + }) + .collect()) + } + + // Desktop: Use trezor-connect-rs + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + let inner = self.inner.lock().await; + let trezor = inner.as_ref().ok_or(TrezorError::NotInitialized)?; + + let devices = trezor.list_devices().await.map_err(TrezorError::from)?; + + Ok(devices.into_iter().map(TrezorDeviceInfo::from).collect()) + } } - /// Verify message using the signer address and signature + /// Connect to a device by its ID. /// - /// This method asks the device to verify a message using the provided signer address and signature. - /// The device will verify that the signature was created by the private key corresponding to the given address. - pub fn verify_message(&self, params: VerifyMessageParams, request_id: Option) -> TrezorConnectResult { - self.generate_deep_link("verifyMessage", params, request_id) + /// On mobile: Opens device connection via native callback. + /// On desktop: Uses trezor-connect-rs library. + pub async fn connect(&self, device_id: &str) -> Result { + if !*self.initialized.lock().await { + return Err(TrezorError::NotInitialized); + } + + // Mobile: Use callback-based connection + #[cfg(any(target_os = "android", target_os = "ios"))] + { + use crate::get_transport_callback; + + let callback = get_transport_callback() + .ok_or(TrezorError::NotInitialized)?; + + // Find the device in cached list + let device = { + let device_list = self.native_device_list.lock().await; + device_list + .iter() + .find(|d| d.path == device_id) + .cloned() + .ok_or(TrezorError::DeviceNotFound)? + }; + + // Create transport and connect - this will be reused for all operations + let adapter = Arc::new(CallbackAdapter { callback: callback.clone() }); + let mut transport = CallbackTransport::new(adapter) + .with_app_identity("Bitkit", "Bitkit"); + transport.init().await.map_err(TrezorError::from)?; + + // Acquire a session (this triggers THP handshake for BLE) + let session = transport.acquire(&device.path, None).await.map_err(TrezorError::from)?; + + // Store connected path + { + let mut connected_path = self.connected_path.lock().await; + *connected_path = Some(device.path.clone()); + } + + // Determine transport type from cached device info + let transport_type = match device.transport_type { + TrezorTransportType::Bluetooth => TransportType::Bluetooth, + TrezorTransportType::Usb => TransportType::Usb, + }; + + // Create device info + let device_info = DeviceInfo { + id: device.path.clone(), + transport_type, + name: device.name.clone(), + path: device.path.clone(), + label: None, + model: None, + is_bootloader: false, + }; + + // Create connected device and initialize it + let mut connected = ConnectedDevice::new(device_info, Box::new(transport), session); + + // Wire UI callback if set + if let Some(ui_cb) = crate::modules::trezor::get_ui_callback() { + let adapter = Arc::new(UiCallbackAdapter { callback: ui_cb.clone() }); + connected.set_ui_callback(adapter); + } + + let features = connected.initialize().await.map_err(TrezorError::from)?; + + // Store the connected device for reuse + { + let mut stored_device = self.connected_device.lock().await; + *stored_device = Some(connected); + } + + Ok(TrezorFeatures::from(features)) + } + + // Desktop: Use trezor-connect-rs + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + // Find the device in the cached list + let device = { + let device_list = self.device_list.lock().await; + device_list + .iter() + .find(|d| d.id == device_id) + .cloned() + .ok_or(TrezorError::DeviceNotFound)? + }; + + // Connect to the device + let mut inner = self.inner.lock().await; + let trezor = inner.as_mut().ok_or(TrezorError::NotInitialized)?; + + let mut connected = trezor.connect(&device).await.map_err(TrezorError::from)?; + + // Wire UI callback if set + if let Some(ui_cb) = crate::modules::trezor::get_ui_callback() { + let adapter = Arc::new(UiCallbackAdapter { callback: ui_cb.clone() }); + connected.set_ui_callback(adapter); + } + + // Initialize the device and get features + let features = connected.initialize().await.map_err(TrezorError::from)?; + + // Store the connected device + let mut connected_device = self.connected_device.lock().await; + *connected_device = Some(connected); + + Ok(TrezorFeatures::from(features)) + } } - /// Sign message using the private key derived by given BIP32 path + /// Check if a device is currently connected. + pub async fn is_connected(&self) -> bool { + self.connected_device.lock().await.is_some() + } + + /// Get a Bitcoin address from the connected device. /// - /// This method asks the device to sign a message using the private key derived by the given BIP32 path. - /// The user is asked to confirm the message signing on the Trezor device. - pub fn sign_message(&self, params: SignMessageParams, request_id: Option) -> TrezorConnectResult { - self.generate_deep_link("signMessage", params, request_id) + /// # Arguments + /// * `params` - Address parameters including BIP32 path and display options + pub async fn get_address( + &self, + params: TrezorGetAddressParams, + ) -> Result { + // Validate the derivation path + validate_derivation_path(¶ms.path)?; + + // Both mobile and desktop: use stored connected device + let mut connected_device = self.connected_device.lock().await; + let device = connected_device + .as_mut() + .ok_or(TrezorError::NotConnected)?; + + let tc_params: GetAddressParams = params.into(); + let response = device.get_address(tc_params).await.map_err(TrezorError::from)?; + + Ok(TrezorAddressResponse::from(response)) } - /// Sign transaction with the specified parameters + /// Get a public key (xpub) from the connected device. /// - /// This method asks the device to sign given inputs and outputs of a pre-composed transaction. - /// The user is asked to confirm all transaction details on the Trezor device. - pub fn sign_transaction(&self, params: SignTransactionParams, request_id: Option) -> TrezorConnectResult { - self.generate_deep_link("signTransaction", params, request_id) + /// # Arguments + /// * `params` - Public key parameters including BIP32 path + pub async fn get_public_key( + &self, + params: TrezorGetPublicKeyParams, + ) -> Result { + // Validate the derivation path + validate_derivation_path(¶ms.path)?; + + // Both mobile and desktop: use stored connected device + let mut connected_device = self.connected_device.lock().await; + let device = connected_device + .as_mut() + .ok_or(TrezorError::NotConnected)?; + + let tc_params: GetPublicKeyParams = params.into(); + let response = device.get_public_key(tc_params).await.map_err(TrezorError::from)?; + + Ok(TrezorPublicKeyResponse::from(response)) } -} -/// Handle a callback URL from Trezor -/// -/// This method should be called when your application receives a callback from Trezor, -/// typically from your app's deep link handler. -/// -/// # Arguments -/// * `callback_url` - The callback URL that was opened by Trezor -/// -/// # Returns -/// * `TrezorConnectResult` - The parsed response from Trezor -pub fn handle_deep_link>(callback_url: S) -> TrezorConnectResult { - // Parse the URL - let parsed_url = Url::parse(callback_url.as_ref()) - .map_err(|e| TrezorConnectError::UrlError { - error_details: format!("Failed to parse callback URL: {}", e) - })?; + /// Sign a message with the connected device. + /// + /// # Arguments + /// * `params` - Sign message parameters including BIP32 path and message + pub async fn sign_message( + &self, + params: TrezorSignMessageParams, + ) -> Result { + // Validate the derivation path + validate_derivation_path(¶ms.path)?; - // Extract the request ID from the query parameters - let id = parsed_url.query_pairs() - .find(|(key, _)| key == "id") - .map(|(_, value)| value.to_string()) - .ok_or_else(|| TrezorConnectError::Other { - error_details: "Missing 'id' parameter in callback URL".to_string() - })?; + // Both mobile and desktop: use stored connected device + let mut connected_device = self.connected_device.lock().await; + let device = connected_device + .as_mut() + .ok_or(TrezorError::NotConnected)?; - // Extract the response parameter - let response_param = parsed_url.query_pairs() - .find(|(key, _)| key == "response") - .map(|(_, value)| value.to_string()) - .ok_or_else(|| TrezorConnectError::Other { - error_details: "Missing 'response' parameter in callback URL".to_string() - })?; + let tc_params: SignMessageParams = params.into(); + let response = device.sign_message(tc_params).await.map_err(TrezorError::from)?; + + Ok(TrezorSignedMessageResponse::from(response)) + } + + /// Verify a message signature with the connected device. + /// + /// # Arguments + /// * `params` - Verify message parameters including address, signature, and message + pub async fn verify_message( + &self, + params: TrezorVerifyMessageParams, + ) -> Result { + // Both mobile and desktop: use stored connected device + let mut connected_device = self.connected_device.lock().await; + let device = connected_device + .as_mut() + .ok_or(TrezorError::NotConnected)?; + + let tc_params: VerifyMessageParams = params.into(); + device.verify_message(tc_params).await.map_err(TrezorError::from) + } + + /// Sign a Bitcoin transaction with the connected device. + /// + /// # Arguments + /// * `params` - Transaction parameters including inputs, outputs, and options + pub async fn sign_tx( + &self, + params: TrezorSignTxParams, + ) -> Result { + let tc_params: SignTxParams = params.into(); + validate_sign_tx_params(&tc_params)?; + + // Both mobile and desktop: use stored connected device + let mut connected_device = self.connected_device.lock().await; + let device = connected_device + .as_mut() + .ok_or(TrezorError::NotConnected)?; + + let response = device.sign_transaction(tc_params).await.map_err(TrezorError::from)?; + + Ok(TrezorSignedTx::from(response)) + } - // Parse the response JSON - let response: TrezorResponse = serde_json::from_str(&response_param) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse response JSON: {}", e) + /// Sign a Bitcoin transaction from a base64-encoded PSBT. + /// + /// Parses the PSBT, extracts inputs/outputs/prev_txs, and signs via the + /// connected Trezor device. + /// + /// # Arguments + /// * `psbt_base64` - Base64-encoded PSBT data + /// * `network` - Bitcoin network type. Defaults to Bitcoin (mainnet) if None. + pub async fn sign_tx_from_psbt( + &self, + psbt_base64: String, + network: Option, + ) -> Result { + let btc_network = match network { + Some(TrezorCoinType::Testnet) => bitcoin::Network::Testnet, + Some(TrezorCoinType::Signet) => bitcoin::Network::Signet, + Some(TrezorCoinType::Regtest) => bitcoin::Network::Regtest, + _ => bitcoin::Network::Bitcoin, + }; + + let psbt_bytes = general_purpose::STANDARD.decode(&psbt_base64).map_err(|e| TrezorError::DeviceError { + error_details: format!("Invalid PSBT base64: {}", e), })?; + let sign_params = trezor_connect_rs::psbt::psbt_to_sign_tx_params(&psbt_bytes, btc_network) + .map_err(|e| TrezorError::DeviceError { + error_details: format!("PSBT conversion error: {}", e), + })?; - // Check if there was an error - if !response.success { - return Err(TrezorConnectError::Other { - error_details: response.error.unwrap_or_else(|| "Unknown error from Trezor".to_string()) - }); + validate_sign_tx_params(&sign_params)?; + + let mut connected_device = self.connected_device.lock().await; + let device = connected_device + .as_mut() + .ok_or(TrezorError::NotConnected)?; + + let response = device.sign_transaction(sign_params).await.map_err(TrezorError::from)?; + Ok(TrezorSignedTx::from(response)) } - // Get the payload or return an error - let payload = response.payload.ok_or_else(|| TrezorConnectError::Other { - error_details: "Success response but no payload".to_string() - })?; - - // Extract the method from the URL parameters to help with deserialization - let method = parsed_url.query_pairs() - .find(|(key, _)| key == "method") - .map(|(_, value)| value.to_string()); - - // Try to deserialize into the appropriate type based on the method - match method.as_deref() { - Some("getFeatures") => { - let features: FeatureResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse Features response: {}", e) - })?; - Ok(TrezorResponsePayload::Features(features)) - }, - Some("getAddress") => { - let address: AddressResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse Address response: {}", e) - })?; - Ok(TrezorResponsePayload::Address(address)) - }, - Some("getPublicKey") => { - let public_key: PublicKeyResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse PublicKey response: {}", e) - })?; - Ok(TrezorResponsePayload::PublicKey(public_key)) - }, - Some("getAccountInfo") => { - let account_info: AccountInfoResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse AccountInfo response: {}", e) - })?; - Ok(TrezorResponsePayload::AccountInfo(account_info)) - }, - Some("composeTransaction") => { - let compose_tx: ComposeTransactionResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse ComposeTransaction response: {}", e) - })?; - Ok(TrezorResponsePayload::ComposeTransaction(compose_tx)) - }, - Some("verifyMessage") => { - let verify_message: VerifyMessageResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse VerifyMessage response: {}", e) - })?; - Ok(TrezorResponsePayload::VerifyMessage(verify_message)) - }, - Some("signMessage") => { - let message_signature: MessageSignatureResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse MessageSignature response: {}", e) - })?; - Ok(TrezorResponsePayload::MessageSignature(message_signature)) - }, - Some("signTransaction") => { - let signed_tx: SignedTransactionResponse = serde_json::from_value(payload) - .map_err(|e| TrezorConnectError::SerdeError { - error_details: format!("Failed to parse SignedTransaction response: {}", e) - })?; - Ok(TrezorResponsePayload::SignedTransaction(signed_tx)) - }, - _ => { - Err(TrezorConnectError::Other { - error_details: format!("Unknown or unsupported method: {:?}", method).to_string() - }) + /// Disconnect from the currently connected device. + pub async fn disconnect(&self) -> Result<(), TrezorError> { + // Clear stored connected device (both mobile and desktop) + { + let mut connected_device = self.connected_device.lock().await; + if let Some(mut device) = connected_device.take() { + device.disconnect().await.map_err(TrezorError::from)?; + } } + + // Mobile: Also clear connected path and close native device + #[cfg(any(target_os = "android", target_os = "ios"))] + { + use crate::get_transport_callback; + + let mut connected_path = self.connected_path.lock().await; + if let Some(path) = connected_path.take() { + if let Some(callback) = get_transport_callback() { + let result = callback.close_device(path); + if !result.success { + return Err(TrezorError::ConnectionError { + error_details: result.error, + }); + } + } + } + } + + Ok(()) } -} \ No newline at end of file + + /// Get the currently connected device info. + pub async fn get_connected_device(&self) -> Option { + // Mobile: Return cached device info + #[cfg(any(target_os = "android", target_os = "ios"))] + { + let connected_path = self.connected_path.lock().await; + if let Some(ref path) = *connected_path { + let device_list = self.native_device_list.lock().await; + device_list + .iter() + .find(|d| &d.path == path) + .map(|d| TrezorDeviceInfo { + id: d.path.clone(), + transport_type: d.transport_type.clone(), + name: d.name.clone(), + path: d.path.clone(), + label: None, + model: None, + is_bootloader: false, + }) + } else { + None + } + } + + // Desktop: Use trezor-connect-rs + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + let connected_device = self.connected_device.lock().await; + connected_device + .as_ref() + .map(|d| TrezorDeviceInfo::from(d.info().clone())) + } + } + + /// Get the cached features of the currently connected Trezor device. + /// + /// Returns the features that were obtained during `connect()`, without + /// triggering any device interaction. Returns None if no device is connected. + pub async fn get_features(&self) -> Option { + let connected_device = self.connected_device.lock().await; + connected_device + .as_ref() + .and_then(|device| device.features()) + .map(|f| TrezorFeatures::from(f.clone())) + } + + /// Get the device's master root fingerprint as an 8-character hex string. + /// + /// This is a convenience wrapper around `get_public_key()` that returns + /// the root fingerprint in the standard format used in output descriptors + /// (4 bytes, 8 hex chars, e.g., "73c5da0a"). + /// + /// Internally calls `get_public_key` with `m/84'/0'/0'` and + /// `show_on_trezor: false`. + pub async fn get_device_fingerprint(&self) -> Result { + let params = TrezorGetPublicKeyParams { + path: "m/84'/0'/0'".to_string(), + show_on_trezor: false, + coin: None, + }; + let response = self.get_public_key(params).await?; + let fingerprint = response.root_fingerprint.ok_or(TrezorError::DeviceError { + error_details: "Device did not return root fingerprint".to_string(), + })?; + Ok(format!("{:08x}", fingerprint)) + } + + /// Clear stored credentials for a device. + /// + /// This removes any stored Bluetooth pairing credentials for the specified device, + /// requiring re-pairing on the next connection. + /// + /// # Arguments + /// * `device_id` - The device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + pub async fn clear_credentials(&self, device_id: &str) -> Result<(), TrezorError> { + // Mobile: Use the transport callback to clear credentials + #[cfg(any(target_os = "android", target_os = "ios"))] + { + use crate::get_transport_callback; + + let callback = get_transport_callback() + .ok_or(TrezorError::NotInitialized)?; + + // The native layer's save_thp_credential with empty string can be used + // to clear, or we can define a new method. For now, we'll save empty + // credentials which the native layer should interpret as deletion. + // Alternatively, the native layer can implement a dedicated delete method. + let success = callback.save_thp_credential(device_id.to_string(), "".to_string()); + if !success { + return Err(TrezorError::IoError { + error_details: format!("Failed to clear credentials for device: {}", device_id), + }); + } + Ok(()) + } + + // Desktop: Clear credentials from the credential store + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + let mut inner = self.inner.lock().await; + let trezor = inner.as_mut().ok_or(TrezorError::NotInitialized)?; + + trezor.clear_credentials(device_id).await.map_err(TrezorError::from) + } + } +} + +impl Default for TrezorManager { + fn default() -> Self { + Self::new() + } +} diff --git a/src/modules/trezor/mod.rs b/src/modules/trezor/mod.rs index f84e903..80c3786 100644 --- a/src/modules/trezor/mod.rs +++ b/src/modules/trezor/mod.rs @@ -1,9 +1,16 @@ +//! Trezor hardware wallet integration module. +//! +//! This module provides FFI-compatible interfaces for interacting with +//! Trezor hardware wallets via USB and Bluetooth connections. + mod errors; mod types; mod implementation; +mod callbacks; #[cfg(test)] mod tests; pub use errors::*; pub use types::*; -pub use implementation::*; \ No newline at end of file +pub use implementation::*; +pub use callbacks::*; diff --git a/src/modules/trezor/tests.rs b/src/modules/trezor/tests.rs index dd8fae7..6562c62 100644 --- a/src/modules/trezor/tests.rs +++ b/src/modules/trezor/tests.rs @@ -1,1385 +1,583 @@ +//! Tests for the Trezor module. + #[cfg(test)] mod tests { - use serde_json::json; - use crate::modules::trezor::{handle_deep_link, AccountAddresses, AccountInfoDetails, AccountUtxo, AddressInfo, ComposeAccount, ComposeOutput, ComposeTransactionParams, ComposeTransactionResponse, DefaultAccountType, FeeLevel, GetAccountInfoParams, GetAddressParams, GetPublicKeyParams, RefTransaction, RefTxInput, RefTxOutput, ScriptType, SignMessageParams, SignTransactionParams, TokenFilter, TrezorConnectClient, TrezorConnectError, TrezorEnvironment, TrezorResponsePayload, TxInputType, TxOutputType, VerifyMessageParams}; - use super::*; + use crate::modules::trezor::{ + TrezorDeviceInfo, TrezorError, TrezorFeatures, TrezorScriptType, TrezorTransportType, + TrezorTxInput, TrezorTxOutput, TrezorSignTxParams, TrezorSignedTx, TrezorCoinType, + }; - #[test] - fn test_get_features_with_id() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let result = client.get_features(Some("123".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getFeatures")); - // The ID is now in the callback URL, not the main URL query params - assert!(result.url.contains("callback=exampleapp")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3D123")); - assert_eq!(result.request_id, "123"); - } + // ======================================================================== + // Error Conversion Tests + // ======================================================================== #[test] - fn test_get_features_auto_id() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let result = client.get_features(None).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getFeatures")); - assert!(result.url.contains("callback=exampleapp")); - // The ID is now in the callback URL, and we just check it contains a callback with id param - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3D")); - assert!(!result.request_id.is_empty()); - // UUID validation (ensuring it's in the proper format) - assert_eq!(result.request_id.len(), 36); - } + fn test_error_conversion_device_not_found() { + use trezor_connect_rs::error::TransportError; + use trezor_connect_rs::TrezorError as TcError; - #[test] - fn test_get_address() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = GetAddressParams { - path: "m/44'/0'/0'/0/0".to_string(), - address: None, - showOnTrezor: Some(true), - chunkify: None, - useEventListener: None, - coin: Some("btc".to_string()), - crossChain: None, - multisig: None, - scriptType: None, - unlockPath: None, - common: None, - }; + let tc_err = TcError::Transport(TransportError::DeviceNotFound); + let err: TrezorError = tc_err.into(); - let result = client.get_address(params, Some("456".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getAddress")); - assert!(result.url.contains("path")); - // Check for encoded callback URL with ID - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3D456")); - assert_eq!(result.request_id, "456"); + assert!(matches!(err, TrezorError::DeviceNotFound)); } #[test] - fn test_get_public_key() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = GetPublicKeyParams { - path: "m/49'/0'/0'".to_string(), - showOnTrezor: Some(true), - suppressBackupWarning: None, - chunkify: None, - coin: Some("btc".to_string()), - crossChain: None, - scriptType: None, - ignoreXpubMagic: None, - ecdsaCurveName: None, - unlockPath: None, - common: None, - }; + fn test_error_conversion_device_disconnected() { + use trezor_connect_rs::error::TransportError; + use trezor_connect_rs::TrezorError as TcError; - let result = client.get_public_key(params, Some("789".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getPublicKey")); - assert!(result.url.contains("path")); - // Check for encoded callback URL with ID - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3D789")); - assert_eq!(result.request_id, "789"); + let tc_err = TcError::Transport(TransportError::DeviceDisconnected); + let err: TrezorError = tc_err.into(); + + assert!(matches!(err, TrezorError::DeviceDisconnected)); } #[test] - fn test_get_account_info_with_path() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = GetAccountInfoParams { - path: Some("m/49'/0'/0'".to_string()), - descriptor: None, - coin: "btc".to_string(), - details: None, - tokens: None, - page: None, - pageSize: None, - from: None, - to: None, - gap: None, - contractFilter: None, - marker: None, - defaultAccountType: None, - suppressBackupWarning: None, - common: None, - }; + fn test_error_conversion_timeout() { + use trezor_connect_rs::TrezorError as TcError; - let result = client.get_account_info(params, Some("account1".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getAccountInfo")); - assert!(result.url.contains("path")); - assert!(result.url.contains("coin")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Daccount1")); - assert_eq!(result.request_id, "account1"); + let tc_err = TcError::Timeout; + let err: TrezorError = tc_err.into(); + + assert!(matches!(err, TrezorError::Timeout)); } #[test] - fn test_get_account_info_with_descriptor() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); + fn test_error_conversion_cancelled() { + use trezor_connect_rs::TrezorError as TcError; - let params = GetAccountInfoParams { - path: None, - descriptor: Some("xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx".to_string()), - coin: "btc".to_string(), - details: None, - tokens: None, - page: None, - pageSize: None, - from: None, - to: None, - gap: None, - contractFilter: None, - marker: None, - defaultAccountType: None, - suppressBackupWarning: None, - common: None, - }; + let tc_err = TcError::Cancelled; + let err: TrezorError = tc_err.into(); - let result = client.get_account_info(params, Some("account2".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getAccountInfo")); - assert!(result.url.contains("descriptor")); - assert!(result.url.contains("coin")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Daccount2")); - assert_eq!(result.request_id, "account2"); + assert!(matches!(err, TrezorError::UserCancelled)); } #[test] - fn test_get_account_info_discovery() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); + fn test_error_conversion_pin_required() { + use trezor_connect_rs::error::DeviceError; + use trezor_connect_rs::TrezorError as TcError; - let params = GetAccountInfoParams { - path: None, - descriptor: None, - coin: "btc".to_string(), - details: None, - tokens: None, - page: None, - pageSize: None, - from: None, - to: None, - gap: None, - contractFilter: None, - marker: None, - defaultAccountType: Some(DefaultAccountType::Segwit), - suppressBackupWarning: Some(true), - common: None, - }; + let tc_err = TcError::Device(DeviceError::PinRequired); + let err: TrezorError = tc_err.into(); - let result = client.get_account_info(params, Some("account3".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getAccountInfo")); - assert!(!result.url.contains("path")); - assert!(!result.url.contains("descriptor")); - assert!(result.url.contains("coin")); - assert!(result.url.contains("defaultAccountType")); - assert!(result.url.contains("suppressBackupWarning")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Daccount3")); - assert_eq!(result.request_id, "account3"); + assert!(matches!(err, TrezorError::PinRequired)); } #[test] - fn test_get_account_info_with_details() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = GetAccountInfoParams { - path: Some("m/49'/0'/0'".to_string()), - descriptor: None, - coin: "btc".to_string(), - details: Some(AccountInfoDetails::Txs), - tokens: Some(TokenFilter::Used), - page: Some(1), - pageSize: Some(25), - from: Some(650000), - to: Some(670000), - gap: Some(20), - contractFilter: None, - marker: None, - defaultAccountType: None, - suppressBackupWarning: None, - common: None, - }; + fn test_error_conversion_invalid_pin() { + use trezor_connect_rs::error::DeviceError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Device(DeviceError::InvalidPin); + let err: TrezorError = tc_err.into(); - let result = client.get_account_info(params, Some("account4".to_string())).unwrap(); - println!("Debug URL: {}", result.url); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=getAccountInfo")); - assert!(result.url.contains("%22details%22%3A%22txs%22")); - assert!(result.url.contains("%22tokens%22%3A%22used%22")); - assert!(result.url.contains("%22page%22%3A1")); - assert!(result.url.contains("%22pageSize%22%3A25")); - assert!(result.url.contains("%22from%22%3A650000")); - assert!(result.url.contains("%22to%22%3A670000")); - assert!(result.url.contains("%22gap%22%3A20")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Daccount4")); - assert_eq!(result.request_id, "account4"); + assert!(matches!(err, TrezorError::InvalidPin)); } #[test] - fn test_get_account_info_invalid_params() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - // Both path and descriptor provided (invalid) - let params = GetAccountInfoParams { - path: Some("m/49'/0'/0'".to_string()), - descriptor: Some("xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx".to_string()), - coin: "btc".to_string(), - details: None, - tokens: None, - page: None, - pageSize: None, - from: None, - to: None, - gap: None, - contractFilter: None, - marker: None, - defaultAccountType: None, - suppressBackupWarning: None, - common: None, - }; + fn test_error_conversion_pin_cancelled() { + use trezor_connect_rs::error::DeviceError; + use trezor_connect_rs::TrezorError as TcError; - let result = client.get_account_info(params, Some("account_invalid".to_string())); - assert!(result.is_err()); - if let Err(TrezorConnectError::Other { error_details }) = result { - assert!(error_details.contains("Both path and descriptor provided")); - } else { - panic!("Expected TrezorConnectError::Other but got something else"); - } + let tc_err = TcError::Device(DeviceError::PinCancelled); + let err: TrezorError = tc_err.into(); + + assert!(matches!(err, TrezorError::PinCancelled)); } #[test] - fn test_preserves_existing_query() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback?foo=bar" - ).unwrap(); - - let result = client.get_features(Some("xyz".to_string())).unwrap(); - // The callback URL should contain both the original foo=bar and the id - assert!(result.url.contains("callback=exampleapp")); - // URL encoded version of ?foo=bar&id=xyz - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Ffoo%3Dbar%26id%3Dxyz")); - assert_eq!(result.request_id, "xyz"); + fn test_error_conversion_passphrase_required() { + use trezor_connect_rs::error::DeviceError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Device(DeviceError::PassphraseRequired); + let err: TrezorError = tc_err.into(); + + assert!(matches!(err, TrezorError::PassphraseRequired)); } #[test] - fn test_environment_urls() { - // Test Local environment - let local_url = TrezorEnvironment::Local.base_url().unwrap(); - assert_eq!(local_url.as_str(), "trezorsuitelite://connect/1/"); - - // Test Development environment - let dev_url = TrezorEnvironment::Development.base_url().unwrap(); - assert_eq!(dev_url.as_str(), "https://dev.suite.sldev.cz/connect/develop/deeplink/1/"); - - // Test Production environment (should return an error) - let prod_result = TrezorEnvironment::Production.base_url(); - assert!(prod_result.is_err()); - if let Err(TrezorConnectError::EnvironmentError { error_details }) = prod_result { - assert_eq!(error_details, "Production environment is not available"); - } else { - panic!("Expected EnvironmentError but got something else"); - } + fn test_error_conversion_action_cancelled() { + use trezor_connect_rs::error::DeviceError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Device(DeviceError::ActionCancelled); + let err: TrezorError = tc_err.into(); + + assert!(matches!(err, TrezorError::UserCancelled)); } #[test] - fn test_client_creation_error() { - // Test with invalid URL - let result = TrezorConnectClient::new( - TrezorEnvironment::Local, - "invalid-url" - ); - assert!(result.is_err()); + fn test_error_conversion_not_connected() { + use trezor_connect_rs::error::DeviceError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Device(DeviceError::NotConnected); + let err: TrezorError = tc_err.into(); + + assert!(matches!(err, TrezorError::NotConnected)); } #[test] - fn test_handle_deep_link_features() { - // Create a mock response URL that would come from a getFeatures call - let features_json = json!({ - "vendor": "trezor.io", - "major_version": 2, - "minor_version": 7, - "patch_version": 0, - "device_id": "DEVICE12345", - "capabilities": ["Capability_Bitcoin", "Capability_Ethereum"] - }); - - let response_json = json!({ - "success": true, - "payload": features_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=test123&method=getFeatures&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::Features(features) => { - assert_eq!(features.vendor, "trezor.io"); - assert_eq!(features.major_version, 2); - assert_eq!(features.minor_version, 7); - assert_eq!(features.patch_version, 0); - assert_eq!(features.device_id, "DEVICE12345"); - assert!(features.capabilities.is_some()); - assert_eq!(features.capabilities.unwrap().len(), 2); - }, - _ => panic!("Expected Features payload, but got something else"), - } + fn test_error_conversion_pairing_required() { + use trezor_connect_rs::error::ThpError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Thp(ThpError::PairingRequired); + let err: TrezorError = tc_err.into(); + + assert!(matches!(err, TrezorError::PairingRequired)); } #[test] - fn test_handle_deep_link_address() { - // Create a mock response URL that would come from a getAddress call - let address_json = json!({ - "address": "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH", - "path": [44, 0, 0, 0, 0], - "serializedPath": "m/44'/0'/0'/0/0" - }); - - let response_json = json!({ - "success": true, - "payload": address_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=addr123&method=getAddress&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::Address(address) => { - assert_eq!(address.address, "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH"); - assert_eq!(address.path, vec![44, 0, 0, 0, 0]); - assert_eq!(address.serializedPath, "m/44'/0'/0'/0/0"); - }, - _ => panic!("Expected Address payload, but got something else"), + fn test_error_conversion_pairing_failed() { + use trezor_connect_rs::error::ThpError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Thp(ThpError::PairingFailed("code mismatch".to_string())); + let err: TrezorError = tc_err.into(); + + match err { + TrezorError::PairingFailed { error_details } => { + assert!(error_details.contains("code mismatch")); + } + _ => panic!("Expected PairingFailed error"), } } #[test] - fn test_handle_deep_link_public_key() { - // Create a mock response URL that would come from a getPublicKey call - let pubkey_json = json!({ - "path": [49, 0, 0], - "serializedPath": "m/49'/0'/0'", - "xpub": "xpub6BosfCnifzxcFwrSzQiqu2DBVTshkCXacvNsWGYJVVhhawA7d4R5WSWGFNbi8Aw6ZRc1brxMyWMzG3DSSSSoekkudhUd9yLb6qx39T9nMdj", - "chainCode": "1f66e8e24ed26a59bdd7c586b14e9f3d2114506a03114f62f766d42701c091e1", - "childNum": 0, - "publicKey": "03a1af804ac108a8a51782198c2d034b28bf90c8803f5a53f76276fa69a4eae77f", - // Fixed fingerprint value to be within i32 range - "fingerprint": 2147483647, - "depth": 3 - }); - - let response_json = json!({ - "success": true, - "payload": pubkey_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=pubkey123&method=getPublicKey&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::PublicKey(pubkey) => { - assert_eq!(pubkey.path, vec![49, 0, 0]); - assert_eq!(pubkey.serializedPath, "m/49'/0'/0'"); - assert_eq!(pubkey.xpub, "xpub6BosfCnifzxcFwrSzQiqu2DBVTshkCXacvNsWGYJVVhhawA7d4R5WSWGFNbi8Aw6ZRc1brxMyWMzG3DSSSSoekkudhUd9yLb6qx39T9nMdj"); - assert_eq!(pubkey.chainCode, "1f66e8e24ed26a59bdd7c586b14e9f3d2114506a03114f62f766d42701c091e1"); - assert_eq!(pubkey.childNum, 0); - assert_eq!(pubkey.publicKey, "03a1af804ac108a8a51782198c2d034b28bf90c8803f5a53f76276fa69a4eae77f"); - assert_eq!(pubkey.fingerprint, 2147483647); // Max i32 value - assert_eq!(pubkey.depth, 3); - }, - _ => panic!("Expected PublicKey payload, but got something else"), + fn test_error_conversion_invalid_path() { + use trezor_connect_rs::error::BitcoinError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Bitcoin(BitcoinError::InvalidPath("bad path format".to_string())); + let err: TrezorError = tc_err.into(); + + match err { + TrezorError::InvalidPath { error_details } => { + assert!(error_details.contains("bad path format")); + } + _ => panic!("Expected InvalidPath error"), } } #[test] - fn test_handle_deep_link_account_info() { - // Create a mock response URL that would come from a getAccountInfo call - let account_json = json!({ - "id": 0, - "path": "m/49'/0'/0'", - "descriptor": "xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx", - "balance": "12500000", - "availableBalance": "12500000" - }); - - let response_json = json!({ - "success": true, - "payload": account_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=account123&method=getAccountInfo&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::AccountInfo(account) => { - assert_eq!(account.id, 0); - assert_eq!(account.path, "m/49'/0'/0'"); - assert_eq!(account.descriptor, "xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx"); - assert_eq!(account.balance, "12500000"); - assert_eq!(account.availableBalance, "12500000"); - }, - _ => panic!("Expected AccountInfo payload, but got something else"), + fn test_error_conversion_protocol_error() { + use trezor_connect_rs::error::ProtocolError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Protocol(ProtocolError::InvalidHeader); + let err: TrezorError = tc_err.into(); + + match err { + TrezorError::ProtocolError { error_details } => { + assert!(error_details.contains("Invalid header")); + } + _ => panic!("Expected ProtocolError"), } } #[test] - fn test_handle_deep_link_error_response() { - // Create a mock error response - let response_json = json!({ - "success": false, - "error": "Device disconnected" - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=error123&method=getFeatures&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url); - assert!(result.is_err()); - match result { - Err(TrezorConnectError::Other { error_details }) => { - assert_eq!(error_details, "Device disconnected"); - }, - _ => panic!("Expected TrezorConnectError::Other but got something else"), + fn test_error_conversion_session_expired() { + use trezor_connect_rs::error::SessionError; + use trezor_connect_rs::TrezorError as TcError; + + let tc_err = TcError::Session(SessionError::Expired); + let err: TrezorError = tc_err.into(); + + match err { + TrezorError::SessionError { error_details } => { + assert!(error_details.contains("expired")); + } + _ => panic!("Expected SessionError"), } } #[test] - fn test_handle_deep_link_invalid_url() { - // Use a clearly invalid URL format that will trigger a URL parsing error - let result = handle_deep_link("not a valid url with spaces and special chars: @#$%^&*()"); + fn test_error_conversion_io_error() { + use trezor_connect_rs::TrezorError as TcError; - assert!(result.is_err()); - // Check that it's the right error type or message - match result { - Err(TrezorConnectError::UrlError { error_details }) => { - // We're just checking for the error type here, not the specific message - assert!(error_details.contains("Failed to parse callback URL")); - }, - Err(other) => { - panic!("Expected UrlError, but got {:?}", other); - }, - Ok(_) => { - panic!("Expected error, but got Ok result"); + let tc_err = TcError::IoError("file not found".to_string()); + let err: TrezorError = tc_err.into(); + + match err { + TrezorError::IoError { error_details } => { + assert!(error_details.contains("file not found")); } + _ => panic!("Expected IoError"), } } + // ======================================================================== + // Type Conversion Tests + // ======================================================================== + #[test] - fn test_handle_deep_link_missing_id() { - // Create a response URL missing the ID parameter - let response_json = json!({ - "success": true, - "payload": { "data": "some data" } - }); - - let callback_url = format!( - "exampleapp://trezor-callback?method=getFeatures&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url); - assert!(result.is_err()); - match result { - Err(TrezorConnectError::Other { error_details }) => { - assert!(error_details.contains("Missing 'id' parameter")); - }, - _ => panic!("Expected Other error, but got something else"), - } + fn test_script_type_conversion_spend_address() { + let trezor_type = TrezorScriptType::SpendAddress; + let tc_type: trezor_connect_rs::ScriptType = trezor_type.into(); + assert!(matches!(tc_type, trezor_connect_rs::ScriptType::SpendAddress)); } #[test] - fn test_handle_deep_link_missing_response() { - // Create a response URL missing the response parameter - let callback_url = "exampleapp://trezor-callback?id=test123&method=getFeatures"; + fn test_script_type_conversion_spend_p2sh_witness() { + let trezor_type = TrezorScriptType::SpendP2shWitness; + let tc_type: trezor_connect_rs::ScriptType = trezor_type.into(); + assert!(matches!(tc_type, trezor_connect_rs::ScriptType::SpendP2SHWitness)); + } - let result = handle_deep_link(callback_url); - assert!(result.is_err()); - match result { - Err(TrezorConnectError::Other { error_details }) => { - assert!(error_details.contains("Missing 'response' parameter")); - }, - _ => panic!("Expected Other error, but got something else"), - } + #[test] + fn test_script_type_conversion_spend_witness() { + let trezor_type = TrezorScriptType::SpendWitness; + let tc_type: trezor_connect_rs::ScriptType = trezor_type.into(); + assert!(matches!(tc_type, trezor_connect_rs::ScriptType::SpendWitness)); } - // New tests to cover TrezorConnectError functionality + #[test] + fn test_script_type_conversion_spend_taproot() { + let trezor_type = TrezorScriptType::SpendTaproot; + let tc_type: trezor_connect_rs::ScriptType = trezor_type.into(); + assert!(matches!(tc_type, trezor_connect_rs::ScriptType::SpendTaproot)); + } #[test] - fn test_serde_error_conversion() { - // Create a serde_json::Error - let json_error = serde_json::from_str::("invalid json").unwrap_err(); - - // Convert to TrezorConnectError - let trezor_error: TrezorConnectError = json_error.into(); - - // Check the error is correctly converted - match trezor_error { - TrezorConnectError::SerdeError { error_details } => { - assert!(error_details.contains("expected value")); - }, - _ => panic!("Expected SerdeError but got something else"), - } + fn test_script_type_conversion_external() { + let trezor_type = TrezorScriptType::External; + let tc_type: trezor_connect_rs::ScriptType = trezor_type.into(); + assert!(matches!(tc_type, trezor_connect_rs::ScriptType::External)); } #[test] - fn test_url_error_conversion() { - // Create a url::ParseError - let url_error = url::Url::parse("invalid url").unwrap_err(); - - // Convert to TrezorConnectError - let trezor_error: TrezorConnectError = url_error.into(); - - // Check the error is correctly converted - match trezor_error { - TrezorConnectError::UrlError { error_details } => { - // The actual error message may vary but should mention the URL was relative without a base - assert!(error_details.contains("relative URL without a base")); - }, - _ => panic!("Expected UrlError but got something else"), - } + fn test_transport_type_from_trezor_connect() { + use trezor_connect_rs::TransportType; + + let usb_type = TransportType::Usb; + let result: TrezorTransportType = usb_type.into(); + assert!(matches!(result, TrezorTransportType::Usb)); + + let bt_type = TransportType::Bluetooth; + let result: TrezorTransportType = bt_type.into(); + assert!(matches!(result, TrezorTransportType::Bluetooth)); } #[test] - fn test_error_display() { - // Test the display implementation for TrezorConnectError - let error = TrezorConnectError::SerdeError { - error_details: "test serde error".to_string() + fn test_tx_input_conversion() { + let input = TrezorTxInput { + prev_hash: "abcd1234".to_string(), + prev_index: 0, + path: "m/84'/0'/0'/0/0".to_string(), + amount: 100000, + script_type: TrezorScriptType::SpendWitness, + sequence: Some(0xFFFFFFFD), + orig_hash: None, + orig_index: None, }; - assert_eq!(format!("{}", error), "Serialization error: test serde error"); - let error = TrezorConnectError::UrlError { - error_details: "test url error".to_string() - }; - assert_eq!(format!("{}", error), "URL error: test url error"); + let tc_input: trezor_connect_rs::SignTxInput = input.into(); - let error = TrezorConnectError::EnvironmentError { - error_details: "test environment error".to_string() - }; - assert_eq!(format!("{}", error), "Environment error: test environment error"); + assert_eq!(tc_input.prev_hash, "abcd1234"); + assert_eq!(tc_input.prev_index, 0); + assert_eq!(tc_input.path, "m/84'/0'/0'/0/0"); + assert_eq!(tc_input.amount, 100000); + assert!(matches!(tc_input.script_type, trezor_connect_rs::ScriptType::SpendWitness)); + assert_eq!(tc_input.sequence, Some(0xFFFFFFFD)); + } - let error = TrezorConnectError::Other { - error_details: "test other error".to_string() + #[test] + fn test_tx_output_external_conversion() { + let output = TrezorTxOutput { + address: Some("bc1qtest...".to_string()), + path: None, + amount: 90000, + script_type: None, + op_return_data: None, + orig_hash: None, + orig_index: None, }; - assert_eq!(format!("{}", error), "Error: test other error"); - let error = TrezorConnectError::ClientError { - error_details: "test client error".to_string() - }; - assert_eq!(format!("{}", error), "Unable to create client: test client error"); + let tc_output: trezor_connect_rs::SignTxOutput = output.into(); + + assert_eq!(tc_output.address, Some("bc1qtest...".to_string())); + assert!(tc_output.path.is_none()); + assert_eq!(tc_output.amount, 90000); } #[test] - fn test_chained_error_conversion() { - // Test that we can chain error conversions - let url_error = url::Url::parse("invalid url").unwrap_err(); - let error_str = format!("URL parsing failed: {}", url_error); - let trezor_error = TrezorConnectError::ClientError { - error_details: error_str + fn test_tx_output_change_conversion() { + let output = TrezorTxOutput { + address: None, + path: Some("m/84'/0'/0'/1/0".to_string()), + amount: 5000, + script_type: Some(TrezorScriptType::SpendWitness), + op_return_data: None, + orig_hash: None, + orig_index: None, }; - // Check that the error message contains the expected fragments - assert!(format!("{}", trezor_error).contains("URL parsing failed")); - assert!(format!("{}", trezor_error).contains("relative URL without a base")); + let tc_output: trezor_connect_rs::SignTxOutput = output.into(); + + assert!(tc_output.address.is_none()); + assert_eq!(tc_output.path, Some("m/84'/0'/0'/1/0".to_string())); + assert_eq!(tc_output.amount, 5000); + assert!(matches!(tc_output.script_type, Some(trezor_connect_rs::ScriptType::SpendWitness))); } #[test] - fn test_sign_transaction_basic() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let inputs = vec![ - TxInputType { - prev_hash: "b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac".to_string(), - prev_index: 0, - amount: 3431747, - sequence: None, - address_n: Some(vec![ - 44 | 0x80000000u32, - 0 | 0x80000000u32, - 2 | 0x80000000u32, - 1, - 0, - ]), - script_type: Some(ScriptType::SpendAddress), - multisig: None, - script_pubkey: None, - script_sig: None, - witness: None, - ownership_proof: None, - commitment_data: None, - orig_hash: None, - orig_index: None, - coinjoin_flags: None, - } - ]; - - let outputs = vec![ - TxOutputType { - address: None, - address_n: Some(vec![ - 44 | 0x80000000u32, - 0 | 0x80000000u32, - 2 | 0x80000000u32, - 1, - 1, - ]), - amount: 3181747, - script_type: ScriptType::PayToAddress, - multisig: None, - op_return_data: None, - orig_hash: None, - orig_index: None, - payment_req_index: None, - }, - TxOutputType { - address: Some("18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2".to_string()), - address_n: None, - amount: 200000, - script_type: ScriptType::PayToAddress, - multisig: None, - op_return_data: None, - orig_hash: None, - orig_index: None, - payment_req_index: None, - } - ]; - - let params = SignTransactionParams { - coin: "btc".to_string(), - inputs, - outputs, - refTxs: None, - paymentRequests: None, - locktime: None, - version: None, - expiry: None, - versionGroupId: None, - overwintered: None, - timestamp: None, - branchId: None, - push: None, - amountUnit: None, - unlockPath: None, - serialize: None, - chunkify: None, - common: None, + fn test_tx_output_op_return_conversion() { + let output = TrezorTxOutput { + address: None, + path: None, + amount: 0, + script_type: None, + op_return_data: Some("deadbeef".to_string()), + orig_hash: None, + orig_index: None, }; - let result = client.sign_transaction(params, Some("sign123".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=signTransaction")); - assert!(result.url.contains("coin")); - assert!(result.url.contains("inputs")); - assert!(result.url.contains("outputs")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dsign123")); - assert_eq!(result.request_id, "sign123"); + let tc_output: trezor_connect_rs::SignTxOutput = output.into(); + + assert!(tc_output.address.is_none()); + assert!(tc_output.path.is_none()); + assert_eq!(tc_output.amount, 0); + assert_eq!(tc_output.op_return_data, Some("deadbeef".to_string())); } #[test] - fn test_sign_transaction_with_reftxs() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let inputs = vec![ - TxInputType { - prev_hash: "b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac".to_string(), + fn test_sign_tx_params_conversion() { + let params = TrezorSignTxParams { + inputs: vec![TrezorTxInput { + prev_hash: "abcd".to_string(), prev_index: 0, - amount: 3431747, + path: "m/84'/0'/0'/0/0".to_string(), + amount: 100000, + script_type: TrezorScriptType::SpendWitness, sequence: None, - address_n: Some(vec![ - 44 | 0x80000000u32, - 0 | 0x80000000u32, - 2 | 0x80000000u32, - 1, - 0, - ]), - script_type: Some(ScriptType::SpendAddress), - multisig: None, - script_pubkey: None, - script_sig: None, - witness: None, - ownership_proof: None, - commitment_data: None, orig_hash: None, orig_index: None, - coinjoin_flags: None, - } - ]; - - let outputs = vec![ - TxOutputType { - address: Some("18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2".to_string()), - address_n: None, - amount: 200000, - script_type: ScriptType::PayToAddress, - multisig: None, + }], + outputs: vec![TrezorTxOutput { + address: Some("bc1q...".to_string()), + path: None, + amount: 90000, + script_type: None, op_return_data: None, orig_hash: None, orig_index: None, - payment_req_index: None, - } - ]; - - let ref_txs = vec![ - RefTransaction { - hash: "b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac".to_string(), - version: Some(1), - inputs: vec![ - RefTxInput { - prev_hash: "448946a44f1ef514601ccf9b22cc3e638c69ea3900b67b87517ea673eb0293dc".to_string(), - prev_index: 0, - script_sig: "47304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022012103f66bbe3c721f119bb4b8a1e6c1832b98f2cf625d9f59242008411dd92aab8d94".to_string(), - sequence: 4294967295, - } - ], - bin_outputs: vec![ - RefTxOutput { - amount: 3431747, - script_pubkey: "76a91441352a84436847a7b660d5e76518f6ebb718dedc88ac".to_string(), - }, - RefTxOutput { - amount: 10000, - script_pubkey: "76a9141403b451c79d34e6a7f6e36806683308085467ac88ac".to_string(), - } - ], - lock_time: Some(0), - expiry: None, - version_group_id: None, - overwintered: None, - timestamp: None, - branch_id: None, - extra_data: None, - } - ]; - - let params = SignTransactionParams { - coin: "btc".to_string(), - inputs, - outputs, - refTxs: Some(ref_txs), - paymentRequests: None, - locktime: None, - version: None, - expiry: None, - versionGroupId: None, - overwintered: None, - timestamp: None, - branchId: None, - push: None, - amountUnit: None, - unlockPath: None, - serialize: None, - chunkify: None, - common: None, + }], + coin: Some(TrezorCoinType::Bitcoin), + lock_time: Some(0), + version: Some(2), + prev_txs: vec![], }; - let result = client.sign_transaction(params, Some("sign456".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=signTransaction")); - assert!(result.url.contains("refTxs")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dsign456")); - assert_eq!(result.request_id, "sign456"); - } + let tc_params: trezor_connect_rs::SignTxParams = params.into(); - #[test] - fn test_handle_deep_link_signed_transaction() { - // Create a mock response URL that would come from a signTransaction call - let signed_tx_json = json!({ - "signatures": [ - "304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022" - ], - "serializedTx": "0100000001ac99193d764bf0f3acdd037cc522a8168169316963d553c51357ce43459dd835b0000000006a47304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022012103f66bbe3c721f119bb4b8a1e6c1832b98f2cf625d9f59242008411dd92aab8d94ffffffff02b3893000000000001976a91441352a84436847a7b660d5e76518f6ebb718dedc88ac400d030000000000a914b7536c788d8cfbac33b0d3fb0b9cb4b34bb2bb1087000000" - }); - - let response_json = json!({ - "success": true, - "payload": signed_tx_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=sign123&method=signTransaction&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::SignedTransaction(signed_tx) => { - assert_eq!(signed_tx.signatures.len(), 1); - assert_eq!(signed_tx.signatures[0], "304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022"); - assert!(signed_tx.serializedTx.starts_with("0100000001")); - assert!(signed_tx.txid.is_none()); // No txid since push was not true - }, - _ => panic!("Expected SignedTransaction payload, but got something else"), - } + assert_eq!(tc_params.inputs.len(), 1); + assert_eq!(tc_params.outputs.len(), 1); + assert_eq!(tc_params.coin, Some(trezor_connect_rs::Network::Bitcoin)); + assert_eq!(tc_params.lock_time, Some(0)); + assert_eq!(tc_params.version, Some(2)); } #[test] - fn test_handle_deep_link_signed_transaction_with_txid() { - // Create a mock response URL with txid (when push=true) - let signed_tx_json = json!({ - "signatures": [ - "304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022" - ], - "serializedTx": "0100000001ac99193d764bf0f3acdd037cc522a8168169316963d553c51357ce43459dd835b0000000006a47304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022012103f66bbe3c721f119bb4b8a1e6c1832b98f2cf625d9f59242008411dd92aab8d94ffffffff02b3893000000000001976a91441352a84436847a7b660d5e76518f6ebb718dedc88ac400d030000000000a914b7536c788d8cfbac33b0d3fb0b9cb4b34bb2bb1087000000", - "txid": "a1b2c3d4e5f6789012345678901234567890123456789012345678901234567890" - }); - - let response_json = json!({ - "success": true, - "payload": signed_tx_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=sign456&method=signTransaction&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::SignedTransaction(signed_tx) => { - assert_eq!(signed_tx.signatures.len(), 1); - assert!(signed_tx.serializedTx.starts_with("0100000001")); - assert!(signed_tx.txid.is_some()); - assert_eq!(signed_tx.txid.unwrap(), "a1b2c3d4e5f6789012345678901234567890123456789012345678901234567890"); - }, - _ => panic!("Expected SignedTransaction payload, but got something else"), - } - } - #[test] - fn test_sign_message_basic() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = SignMessageParams { - path: "m/44'/0'/0'".to_string(), - coin: None, - message: "Hello World!".to_string(), - hex: None, - no_script_type: None, - common: None, + fn test_signed_tx_response_conversion() { + let response = trezor_connect_rs::SignedTxResponse { + signatures: vec!["sig1".to_string(), "sig2".to_string()], + serialized_tx: "rawtx".to_string(), }; - let result = client.sign_message(params, Some("message123".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=signMessage")); - assert!(result.url.contains("path")); - assert!(result.url.contains("message")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dmessage123")); - assert_eq!(result.request_id, "message123"); + let result: TrezorSignedTx = response.into(); + + assert_eq!(result.signatures, vec!["sig1", "sig2"]); + assert_eq!(result.serialized_tx, "rawtx"); } + // ======================================================================== + // Device Info Conversion Tests + // ======================================================================== + #[test] - fn test_sign_message_with_coin() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = SignMessageParams { - path: "m/44'/0'/0'".to_string(), - coin: Some("btc".to_string()), - message: "Example message".to_string(), - hex: Some(false), - no_script_type: Some(false), - common: None, + fn test_device_info_from_trezor_connect() { + use trezor_connect_rs::{DeviceInfo, TransportType}; + + let tc_info = DeviceInfo { + id: "device123".to_string(), + transport_type: TransportType::Usb, + name: Some("Trezor Safe 5".to_string()), + path: "/dev/trezor0".to_string(), + label: Some("My Trezor".to_string()), + model: Some("Safe 5".to_string()), + is_bootloader: false, }; - let result = client.sign_message(params, Some("message456".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=signMessage")); - assert!(result.url.contains("coin")); - assert!(result.url.contains("hex")); - assert!(result.url.contains("no_script_type")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dmessage456")); - assert_eq!(result.request_id, "message456"); + let result: TrezorDeviceInfo = tc_info.into(); + + assert_eq!(result.id, "device123"); + assert!(matches!(result.transport_type, TrezorTransportType::Usb)); + assert_eq!(result.name, Some("Trezor Safe 5".to_string())); + assert_eq!(result.path, "/dev/trezor0"); + assert_eq!(result.label, Some("My Trezor".to_string())); + assert_eq!(result.model, Some("Safe 5".to_string())); + assert!(!result.is_bootloader); + } + + #[test] + fn test_features_from_trezor_connect() { + use trezor_connect_rs::device::Features; + + let tc_features = Features { + vendor: Some("trezor.io".to_string()), + model: Some("Safe 5".to_string()), + label: Some("My Wallet".to_string()), + device_id: Some("ABC123".to_string()), + major_version: Some(2), + minor_version: Some(8), + patch_version: Some(0), + pin_protection: Some(true), + passphrase_protection: Some(false), + initialized: Some(true), + needs_backup: Some(false), + ..Default::default() + }; + + let result: TrezorFeatures = tc_features.into(); + + assert_eq!(result.vendor, Some("trezor.io".to_string())); + assert_eq!(result.model, Some("Safe 5".to_string())); + assert_eq!(result.label, Some("My Wallet".to_string())); + assert_eq!(result.device_id, Some("ABC123".to_string())); + assert_eq!(result.major_version, Some(2)); + assert_eq!(result.minor_version, Some(8)); + assert_eq!(result.patch_version, Some(0)); + assert_eq!(result.pin_protection, Some(true)); + assert_eq!(result.passphrase_protection, Some(false)); + assert_eq!(result.initialized, Some(true)); + assert_eq!(result.needs_backup, Some(false)); } + // ======================================================================== + // Path Validation Tests + // ======================================================================== + #[test] - fn test_sign_message_hex() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = SignMessageParams { - path: "m/44'/0'/0'".to_string(), - coin: Some("btc".to_string()), - message: "48656c6c6f20576f726c6421".to_string(), // "Hello World!" in hex - hex: Some(true), - no_script_type: None, - common: None, - }; + fn test_valid_bip84_path() { + use crate::modules::trezor::implementation::validate_derivation_path; - let result = client.sign_message(params, Some("hex789".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=signMessage")); - assert!(result.url.contains("hex")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dhex789")); - assert_eq!(result.request_id, "hex789"); + assert!(validate_derivation_path("m/84'/0'/0'/0/0").is_ok()); + assert!(validate_derivation_path("m/84'/0'/0'/1/0").is_ok()); + assert!(validate_derivation_path("m/84'/0'/0'").is_ok()); } #[test] - fn test_handle_deep_link_message_signature() { - // Create a mock response URL that would come from a signMessage call - let message_signature_json = json!({ - "address": "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH", - "signature": "IDKn5wGhOsGWWkOJ1gD4nXR14VJ/2Rg3A6P9XwRPjZQWjCYJvFNFKKQ5CLjy8oLKlhVIzF7UWNEqVx7lp5Rrffw=" - }); - - let response_json = json!({ - "success": true, - "payload": message_signature_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=message123&method=signMessage&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::MessageSignature(msg_sig) => { - assert_eq!(msg_sig.address, "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH"); - assert_eq!(msg_sig.signature, "IDKn5wGhOsGWWkOJ1gD4nXR14VJ/2Rg3A6P9XwRPjZQWjCYJvFNFKKQ5CLjy8oLKlhVIzF7UWNEqVx7lp5Rrffw="); - }, - _ => panic!("Expected MessageSignature payload, but got something else"), - } + fn test_valid_bip44_path() { + use crate::modules::trezor::implementation::validate_derivation_path; + + assert!(validate_derivation_path("m/44'/0'/0'/0/0").is_ok()); + assert!(validate_derivation_path("m/44'/0'/0'/1/0").is_ok()); } + #[test] - fn test_verify_message_basic() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = VerifyMessageParams { - address: "3BD8TL6iShVzizQzvo789SuynEKGpLTms9".to_string(), - signature: "JO7vL3tOB1qQyfSeIVLvdEw9G1tCvL+lNj78XDAVM4t6UptADs3kXDTO2+2ZeEOLFL4/+wm+BBdSpo3kb3Cnsas=".to_string(), - message: "example message".to_string(), - coin: "btc".to_string(), - hex: None, - common: None, - }; + fn test_valid_bip49_path() { + use crate::modules::trezor::implementation::validate_derivation_path; - let result = client.verify_message(params, Some("verify123".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=verifyMessage")); - assert!(result.url.contains("address")); - assert!(result.url.contains("signature")); - assert!(result.url.contains("message")); - assert!(result.url.contains("coin")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dverify123")); - assert_eq!(result.request_id, "verify123"); + assert!(validate_derivation_path("m/49'/0'/0'/0/0").is_ok()); } #[test] - fn test_verify_message_with_hex() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let params = VerifyMessageParams { - address: "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH".to_string(), - signature: "IDKn5wGhOsGWWkOJ1gD4nXR14VJ/2Rg3A6P9XwRPjZQWjCYJvFNFKKQ5CLjy8oLKlhVIzF7UWNEqVx7lp5Rrffw=".to_string(), - message: "48656c6c6f20576f726c6421".to_string(), // "Hello World!" in hex - coin: "btc".to_string(), - hex: Some(true), - common: None, - }; + fn test_valid_bip86_path() { + use crate::modules::trezor::implementation::validate_derivation_path; - let result = client.verify_message(params, Some("verify456".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=verifyMessage")); - assert!(result.url.contains("hex")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dverify456")); - assert_eq!(result.request_id, "verify456"); + assert!(validate_derivation_path("m/86'/0'/0'/0/0").is_ok()); } #[test] - fn test_handle_deep_link_verify_message() { - // Create a mock response URL that would come from a verifyMessage call - let verify_message_json = json!({ - "message": "Message verified" - }); - - let response_json = json!({ - "success": true, - "payload": verify_message_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=verify123&method=verifyMessage&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::VerifyMessage(verify_msg) => { - assert_eq!(verify_msg.message, "Message verified"); - }, - _ => panic!("Expected VerifyMessage payload, but got something else"), - } + fn test_valid_bip84_path_h_notation() { + use crate::modules::trezor::implementation::validate_derivation_path; + + assert!(validate_derivation_path("m/84h/0h/0h/0/0").is_ok()); + assert!(validate_derivation_path("m/84h/0h/0h/1/0").is_ok()); + assert!(validate_derivation_path("m/84h/0h/0h").is_ok()); } #[test] - fn test_handle_deep_link_verify_message_error() { - // Create a mock error response URL from verifyMessage call - let response_json = json!({ - "success": false, - "error": "Invalid signature" - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=verify456&method=verifyMessage&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url); + fn test_invalid_path_missing_m() { + use crate::modules::trezor::implementation::validate_derivation_path; + + let result = validate_derivation_path("84'/0'/0'/0/0"); assert!(result.is_err()); match result { - Err(TrezorConnectError::Other { error_details }) => { - assert_eq!(error_details, "Invalid signature"); - }, - _ => panic!("Expected TrezorConnectError::Other but got something else"), - } - } - #[test] - fn test_compose_transaction_payment() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let outputs = vec![ - ComposeOutput::Regular { - amount: "200000".to_string(), - address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2".to_string(), + Err(TrezorError::InvalidPath { error_details }) => { + assert!(error_details.contains("must start with 'm/'")); } - ]; - - let params = ComposeTransactionParams { - outputs, - coin: "btc".to_string(), - push: Some(true), - sequence: None, - account: None, - fee_levels: None, - skip_permutation: None, - common: None, - }; - - let result = client.compose_transaction(params, Some("compose123".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=composeTransaction")); - assert!(result.url.contains("coin")); - assert!(result.url.contains("outputs")); - assert!(result.url.contains("push")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dcompose123")); - assert_eq!(result.request_id, "compose123"); + _ => panic!("Expected InvalidPath error"), + } } #[test] - fn test_compose_transaction_precompose() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let outputs = vec![ - ComposeOutput::Regular { - amount: "200000".to_string(), - address: "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu".to_string(), - } - ]; - - let account = ComposeAccount { - path: "m/84'/0'/0'".to_string(), - addresses: AccountAddresses { - used: vec![AddressInfo { - address: "bc1qannfxke2tfd4l7vhepehpvt05y83v3qsf6nfkk".to_string(), - path: "m/84'/0'/0'/0/0".to_string(), - transfers: 1, - }], - unused: vec![AddressInfo { - address: "".to_string(), - path: "m/84'/0'/0'/0/1".to_string(), - transfers: 0, - }], - change: vec![AddressInfo { - address: "bc1qktmhrsmsenepnnfst8x6j27l0uqv7ggrg8x38q".to_string(), - path: "m/84'/0'/0'/1/0".to_string(), - transfers: 0, - }], - }, - utxo: vec![AccountUtxo { - txid: "86a6e02943dcd057cfbe349f2c2274478a3a1be908eb788606a6950e727a0d36".to_string(), - vout: 0, - amount: "300000".to_string(), - block_height: Some(590093), - address: "bc1qannfxke2tfd4l7vhepehpvt05y83v3qsf6nfkk".to_string(), - path: "m/84'/0'/0'/0/0".to_string(), - confirmations: Some(100), - }], - }; + fn test_invalid_path_empty_after_m() { + use crate::modules::trezor::implementation::validate_derivation_path; - let fee_levels = vec![ - FeeLevel { - fee_per_unit: "1".to_string(), - base_fee: None, - floor_base_fee: None, - }, - FeeLevel { - fee_per_unit: "5".to_string(), - base_fee: None, - floor_base_fee: None, - }, - FeeLevel { - fee_per_unit: "30".to_string(), - base_fee: None, - floor_base_fee: None, - }, - ]; - - let params = ComposeTransactionParams { - outputs, - coin: "btc".to_string(), - push: None, - sequence: None, - account: Some(account), - fee_levels: Some(fee_levels), - skip_permutation: None, - common: None, - }; - - let result = client.compose_transaction(params, Some("precompose456".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=composeTransaction")); - assert!(result.url.contains("account")); - assert!(result.url.contains("fee_levels")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dprecompose456")); - assert_eq!(result.request_id, "precompose456"); - } - - #[test] - fn test_compose_transaction_send_max() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let outputs = vec![ - ComposeOutput::SendMax { - address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2".to_string(), + let result = validate_derivation_path("m/"); + assert!(result.is_err()); + match result { + Err(TrezorError::InvalidPath { error_details }) => { + assert!(error_details.contains("cannot be empty")); } - ]; - - let params = ComposeTransactionParams { - outputs, - coin: "btc".to_string(), - push: Some(false), - sequence: None, - account: None, - fee_levels: None, - skip_permutation: None, - common: None, - }; - - let result = client.compose_transaction(params, Some("sendmax789".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=composeTransaction")); - assert!(result.url.contains("send-max")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dsendmax789")); - assert_eq!(result.request_id, "sendmax789"); + _ => panic!("Expected InvalidPath error"), + } } #[test] - fn test_compose_transaction_op_return() { - let client = TrezorConnectClient::new( - TrezorEnvironment::Local, - "exampleapp://trezor-callback" - ).unwrap(); - - let outputs = vec![ - ComposeOutput::Regular { - amount: "100000".to_string(), - address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2".to_string(), - }, - ComposeOutput::OpReturn { - data_hex: "48656c6c6f20576f726c6421".to_string(), // "Hello World!" in hex - }, - ]; - - let params = ComposeTransactionParams { - outputs, - coin: "btc".to_string(), - push: None, - sequence: None, - account: None, - fee_levels: None, - skip_permutation: None, - common: None, - }; + fn test_invalid_path_non_numeric() { + use crate::modules::trezor::implementation::validate_derivation_path; - let result = client.compose_transaction(params, Some("opreturn123".to_string())).unwrap(); - assert!(result.url.starts_with("trezorsuitelite://connect/1/")); - assert!(result.url.contains("method=composeTransaction")); - assert!(result.url.contains("opreturn")); - assert!(result.url.contains("dataHex")); - assert!(result.url.contains("callback=exampleapp%3A%2F%2Ftrezor-callback%3Fid%3Dopreturn123")); - assert_eq!(result.request_id, "opreturn123"); + let result = validate_derivation_path("m/84'/abc/0'/0/0"); + assert!(result.is_err()); + match result { + Err(TrezorError::InvalidPath { error_details }) => { + assert!(error_details.contains("must be a number")); + } + _ => panic!("Expected InvalidPath error"), + } } #[test] - fn test_handle_deep_link_compose_transaction_payment() { - // Create a mock response URL that would come from a composeTransaction call (payment mode) - let signed_tx_json = json!({ - "signatures": [ - "304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022" - ], - "serializedTx": "0100000001ac99193d764bf0f3acdd037cc522a8168169316963d553c51357ce43459dd835b0000000006a47304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022012103f66bbe3c721f119bb4b8a1e6c1832b98f2cf625d9f59242008411dd92aab8d94ffffffff02b3893000000000001976a91441352a84436847a7b660d5e76518f6ebb718dedc88ac400d030000000000a914b7536c788d8cfbac33b0d3fb0b9cb4b34bb2bb1087000000", - "txid": "a1b2c3d4e5f6789012345678901234567890123456789012345678901234567890" - }); - - let response_json = json!({ - "success": true, - "payload": signed_tx_json - }); - - let callback_url = format!( - "exampleapp://trezor-callback?id=compose123&method=composeTransaction&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); - - let result = handle_deep_link(callback_url).unwrap(); + fn test_invalid_path_empty_component() { + use crate::modules::trezor::implementation::validate_derivation_path; + + let result = validate_derivation_path("m/84'//0'/0/0"); + assert!(result.is_err()); match result { - TrezorResponsePayload::ComposeTransaction(ComposeTransactionResponse::SignedTransaction(signed_tx)) => { - assert_eq!(signed_tx.signatures.len(), 1); - assert!(signed_tx.serializedTx.starts_with("0100000001")); - assert!(signed_tx.txid.is_some()); - assert_eq!(signed_tx.txid.unwrap(), "a1b2c3d4e5f6789012345678901234567890123456789012345678901234567890"); - }, - _ => panic!("Expected ComposeTransaction SignedTransaction payload, but got something else"), + Err(TrezorError::InvalidPath { error_details }) => { + assert!(error_details.contains("Empty path component")); + } + _ => panic!("Expected InvalidPath error"), } } + // ======================================================================== + // Error Display Tests + // ======================================================================== + #[test] - fn test_handle_deep_link_compose_transaction_precompose() { - // Create a mock response URL that would come from a composeTransaction call (precompose mode) - let precomposed_txs_json = json!([ - { - "type": "final", - "totalSpent": "200167", - "fee": "167", - "feePerByte": "1", - "bytes": 167, - "inputs": [ - { - "address_n": [2147483732u32, 2147483648u32, 2147483648u32, 0u32, 0u32], - "amount": "300000", - "prev_hash": "86a6e02943dcd057cfbe349f2c2274478a3a1be908eb788606a6950e727a0d36", - "prev_index": 0, - "script_type": "SPENDWITNESS" - } - ], - "outputs": [ - { - "address_n": [2147483732u32, 2147483648u32, 2147483649u32, 0u32], - "amount": "99833", - "script_type": "PAYTOWITNESS" - }, - { - "address": "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu", - "amount": "200000", - "script_type": "PAYTOADDRESS" - } - ], - "outputsPermutation": [1, 0] - }, - { - "type": "final", - "totalSpent": "200835", - "fee": "835", - "feePerByte": "5", - "bytes": 167 - }, - { - "type": "error" - } - ]); + fn test_error_display_messages() { + let err = TrezorError::DeviceNotFound; + assert_eq!(err.to_string(), "No Trezor device found"); - let response_json = json!({ - "success": true, - "payload": precomposed_txs_json - }); + let err = TrezorError::PinRequired; + assert_eq!(err.to_string(), "PIN is required"); - let callback_url = format!( - "exampleapp://trezor-callback?id=precompose456&method=composeTransaction&response={}", - url::form_urlencoded::byte_serialize(response_json.to_string().as_bytes()).collect::() - ); + let err = TrezorError::UserCancelled; + assert_eq!(err.to_string(), "Action cancelled by user"); - let result = handle_deep_link(callback_url).unwrap(); - match result { - TrezorResponsePayload::ComposeTransaction(ComposeTransactionResponse::PrecomposedTransactions(precomposed_txs)) => { - assert_eq!(precomposed_txs.len(), 3); - assert_eq!(precomposed_txs[0].tx_type, "final"); - assert_eq!(precomposed_txs[0].total_spent, Some("200167".to_string())); - assert_eq!(precomposed_txs[0].fee, Some("167".to_string())); - assert_eq!(precomposed_txs[1].tx_type, "final"); - assert_eq!(precomposed_txs[2].tx_type, "error"); - }, - _ => panic!("Expected ComposeTransaction PrecomposedTransactions payload, but got something else"), - } + let err = TrezorError::Timeout; + assert_eq!(err.to_string(), "Operation timed out"); + + let err = TrezorError::NotInitialized; + assert_eq!(err.to_string(), "Trezor not initialized. Call trezor_initialize first."); + + let err = TrezorError::NotConnected; + assert_eq!(err.to_string(), "No device connected. Call trezor_connect first."); } -} \ No newline at end of file +} diff --git a/src/modules/trezor/types.rs b/src/modules/trezor/types.rs index 453410b..6bf9714 100644 --- a/src/modules/trezor/types.rs +++ b/src/modules/trezor/types.rs @@ -1,1006 +1,499 @@ -use serde::{Deserialize, Serialize}; -use url::Url; -use crate::modules::trezor::TrezorConnectError; +//! FFI-compatible types for the Trezor module. -/// Result type for deep link generation, including the URL and the ID used -#[derive(Debug, Clone, uniffi::Record)] -pub struct DeepLinkResult { - /// The generated deep link URL - pub url: String, - /// The request ID used (either provided or auto-generated) - pub request_id: String, -} - -/// Environment options for Trezor deep linking -#[derive(Debug, Clone, Copy, uniffi::Enum)] -pub enum TrezorEnvironment { - /// Production environment (currently unavailable according to docs) - Production, - /// Development environment - Development, - /// Local environment - Local, -} - -/// Empty struct that serializes to {} -#[derive(Serialize)] -pub(crate) struct Empty; - -/// Main client for Trezor Connect deep linking -#[derive(Debug, Clone)] -pub struct TrezorConnectClient { - /// Environment to use for deep links - pub(crate) environment: TrezorEnvironment, - /// Base callback URL for Trezor to return results to (without the ID) - pub(crate) callback_base: Url, -} - -/// Common parameters for all Trezor Connect methods -#[derive(Serialize, Deserialize, Debug, Default, Clone, uniffi::Record)] -pub struct CommonParams { - /// Specific device instance to use - #[serde(skip_serializing_if = "Option::is_none")] - pub device: Option, - /// Set to true if method should use empty passphrase - #[serde(skip_serializing_if = "Option::is_none")] - pub useEmptyPassphrase: Option, - /// Allow seedless device - #[serde(skip_serializing_if = "Option::is_none")] - pub allowSeedlessDevice: Option, - /// Skip final reload - #[serde(skip_serializing_if = "Option::is_none")] - pub skipFinalReload: Option, -} - -/// Parameters for specifying a particular device -#[derive(Serialize, Deserialize, Debug, Default, Clone, uniffi::Record)] -pub struct DeviceParams { - /// Device instance path - #[serde(skip_serializing_if = "Option::is_none")] - pub path: Option, - /// Device instance ID - #[serde(skip_serializing_if = "Option::is_none")] - pub instance: Option, + +/// Transport type for Trezor devices. +#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)] +pub enum TrezorTransportType { + /// USB connection + Usb, + /// Bluetooth connection + Bluetooth, } -/// HD Node Type -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct HDNodeType { - /// Depth - pub depth: u32, - /// Fingerprint - pub fingerprint: u32, - /// Child number - pub child_num: u32, - /// Chain code - pub chain_code: String, - /// Public key - pub public_key: String, - /// Private key (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub private_key: Option, - /// BIP32 derivation path (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub address_n: Option>, -} - -/// HD Node Path Type -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct HDNodePathType { - /// Node data (can be String or HDNodeType) - #[serde(flatten)] - pub node: HDNodeTypeOrString, - /// BIP32 derivation path - pub address_n: Vec, -} - -/// Union type for HD Node (either a String or HDNodeType) -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Enum)] -#[serde(untagged)] -pub enum HDNodeTypeOrString { - /// HD Node as a string - String(String), - /// HD Node as an object - Node(HDNodeType), -} - -/// Multisig Redeem Script Type -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct MultisigRedeemScriptType { - /// Public keys - pub pubkeys: Vec, - /// Signatures - pub signatures: Vec, - /// M-of-N threshold - pub m: u32, - /// Nodes (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub nodes: Option>, - /// Pubkeys order (optional): 0 for PRESERVED, 1 for LEXICOGRAPHIC - #[serde(skip_serializing_if = "Option::is_none")] - pub pubkeys_order: Option, -} - -/// Unlock Path parameters -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct UnlockPath { - /// BIP32 derivation path - pub address_n: Vec, - /// MAC (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub mac: Option, -} - -/// Script type for inputs and outputs -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Enum)] -pub enum ScriptType { - #[serde(rename = "SPENDADDRESS")] +impl From for TrezorTransportType { + fn from(t: trezor_connect_rs::TransportType) -> Self { + match t { + trezor_connect_rs::TransportType::Usb => TrezorTransportType::Usb, + trezor_connect_rs::TransportType::Bluetooth => TrezorTransportType::Bluetooth, + } + } +} + +/// Device information exposed to FFI. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorDeviceInfo { + /// Unique identifier for the device + pub id: String, + /// Transport type (USB or Bluetooth) + pub transport_type: TrezorTransportType, + /// Device name (from BLE advertisement or USB descriptor) + pub name: Option, + /// Transport-specific path (used internally for connection) + pub path: String, + /// Device label (set by user during device setup) + pub label: Option, + /// Device model (e.g., "T2", "Safe 5", "Safe 7") + pub model: Option, + /// Whether the device is in bootloader mode + pub is_bootloader: bool, +} + +impl From for TrezorDeviceInfo { + fn from(info: trezor_connect_rs::DeviceInfo) -> Self { + Self { + id: info.id, + transport_type: info.transport_type.into(), + name: info.name, + path: info.path, + label: info.label, + model: info.model, + is_bootloader: info.is_bootloader, + } + } +} + +/// Device features after initialization. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorFeatures { + /// Vendor string + pub vendor: Option, + /// Device model + pub model: Option, + /// Device label (set by user during device setup) + pub label: Option, + /// Device ID (unique per device) + pub device_id: Option, + /// Major firmware version + pub major_version: Option, + /// Minor firmware version + pub minor_version: Option, + /// Patch firmware version + pub patch_version: Option, + /// Whether PIN protection is enabled + pub pin_protection: Option, + /// Whether passphrase protection is enabled + pub passphrase_protection: Option, + /// Whether the device is initialized with a seed + pub initialized: Option, + /// Whether the device needs backup + pub needs_backup: Option, +} + +impl From for TrezorFeatures { + fn from(f: trezor_connect_rs::device::Features) -> Self { + Self { + vendor: f.vendor, + model: f.model, + label: f.label, + device_id: f.device_id, + major_version: f.major_version, + minor_version: f.minor_version, + patch_version: f.patch_version, + pin_protection: f.pin_protection, + passphrase_protection: f.passphrase_protection, + initialized: f.initialized, + needs_backup: f.needs_backup, + } + } +} + +/// Script types for address derivation. +#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)] +pub enum TrezorScriptType { + /// P2PKH (legacy) SpendAddress, - #[serde(rename = "SPENDMULTISIG")] - SpendMultisig, - #[serde(rename = "SPENDWITNESS")] + /// P2SH-P2WPKH (nested SegWit) + SpendP2shWitness, + /// P2WPKH (native SegWit) SpendWitness, - #[serde(rename = "SPENDP2SHWITNESS")] - SpendP2SHWitness, - #[serde(rename = "SPENDTAPROOT")] + /// P2TR (Taproot) SpendTaproot, - #[serde(rename = "EXTERNAL")] + /// P2SH multisig + SpendMultisig, + /// External/watch-only input (not signed by device) External, - #[serde(rename = "PAYTOADDRESS")] - PayToAddress, - #[serde(rename = "PAYTOSCRIPTHASH")] - PayToScriptHash, - #[serde(rename = "PAYTOMULTISIG")] - PayToMultisig, - #[serde(rename = "PAYTOWITNESS")] - PayToWitness, - #[serde(rename = "PAYTOP2SHWITNESS")] - PayToP2SHWitness, - #[serde(rename = "PAYTOTAPROOT")] - PayToTaproot, - #[serde(rename = "PAYTOOPRETURN")] - PayToOpReturn, -} - -/// Transaction input type -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct TxInputType { - /// Previous transaction hash - pub prev_hash: String, - /// Previous transaction output index - pub prev_index: u32, - /// Amount in satoshis - pub amount: u64, - /// Transaction sequence - #[serde(skip_serializing_if = "Option::is_none")] - pub sequence: Option, - /// BIP32 derivation path - #[serde(skip_serializing_if = "Option::is_none")] - pub address_n: Option>, - /// Script type - #[serde(skip_serializing_if = "Option::is_none")] - pub script_type: Option, - /// Multisig information - #[serde(skip_serializing_if = "Option::is_none")] - pub multisig: Option, - /// Script public key (for external inputs) - #[serde(skip_serializing_if = "Option::is_none")] - pub script_pubkey: Option, - /// Script signature - #[serde(skip_serializing_if = "Option::is_none")] - pub script_sig: Option, - /// Witness data - #[serde(skip_serializing_if = "Option::is_none")] - pub witness: Option, - /// Ownership proof - #[serde(skip_serializing_if = "Option::is_none")] - pub ownership_proof: Option, - /// Commitment data - #[serde(skip_serializing_if = "Option::is_none")] - pub commitment_data: Option, - /// Original hash for RBF - #[serde(skip_serializing_if = "Option::is_none")] - pub orig_hash: Option, - /// Original index for RBF - #[serde(skip_serializing_if = "Option::is_none")] - pub orig_index: Option, - /// Coinjoin flags - #[serde(skip_serializing_if = "Option::is_none")] - pub coinjoin_flags: Option, } -/// Transaction output type -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct TxOutputType { - /// Output address (for address outputs) - #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option, - /// BIP32 derivation path (for change outputs) - #[serde(skip_serializing_if = "Option::is_none")] - pub address_n: Option>, - /// Amount in satoshis - pub amount: u64, - /// Script type - pub script_type: ScriptType, - /// Multisig information - #[serde(skip_serializing_if = "Option::is_none")] - pub multisig: Option, - /// OP_RETURN data - #[serde(skip_serializing_if = "Option::is_none")] - pub op_return_data: Option, - /// Original hash for RBF - #[serde(skip_serializing_if = "Option::is_none")] - pub orig_hash: Option, - /// Original index for RBF - #[serde(skip_serializing_if = "Option::is_none")] - pub orig_index: Option, - /// Payment request index - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_req_index: Option, +impl From for trezor_connect_rs::ScriptType { + fn from(t: TrezorScriptType) -> Self { + match t { + TrezorScriptType::SpendAddress => trezor_connect_rs::ScriptType::SpendAddress, + TrezorScriptType::SpendP2shWitness => trezor_connect_rs::ScriptType::SpendP2SHWitness, + TrezorScriptType::SpendWitness => trezor_connect_rs::ScriptType::SpendWitness, + TrezorScriptType::SpendTaproot => trezor_connect_rs::ScriptType::SpendTaproot, + TrezorScriptType::SpendMultisig => trezor_connect_rs::ScriptType::SpendMultisig, + TrezorScriptType::External => trezor_connect_rs::ScriptType::External, + } + } } -/// Reference transaction for transaction signing -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct RefTransaction { - /// Transaction hash - pub hash: String, - /// Transaction version - #[serde(skip_serializing_if = "Option::is_none")] - pub version: Option, - /// Transaction inputs - pub inputs: Vec, - /// Transaction outputs (binary format) - pub bin_outputs: Vec, - /// Lock time - #[serde(skip_serializing_if = "Option::is_none")] - pub lock_time: Option, - /// Expiry (for Zcash/Decred) - #[serde(skip_serializing_if = "Option::is_none")] - pub expiry: Option, - /// Version group ID (for Zcash) - #[serde(skip_serializing_if = "Option::is_none")] - pub version_group_id: Option, - /// Overwintered flag (for Zcash) - #[serde(skip_serializing_if = "Option::is_none")] - pub overwintered: Option, - /// Timestamp (for Capricoin) - #[serde(skip_serializing_if = "Option::is_none")] - pub timestamp: Option, - /// Branch ID (for Zcash) - #[serde(skip_serializing_if = "Option::is_none")] - pub branch_id: Option, - /// Extra data - #[serde(skip_serializing_if = "Option::is_none")] - pub extra_data: Option, -} - -/// Reference transaction input -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct RefTxInput { - /// Previous transaction hash - pub prev_hash: String, - /// Previous transaction output index - pub prev_index: u32, - /// Script signature - pub script_sig: String, - /// Sequence number - pub sequence: u32, +/// Bitcoin network / coin type for Trezor operations. +#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)] +pub enum TrezorCoinType { + /// Bitcoin mainnet + Bitcoin, + /// Bitcoin testnet + Testnet, + /// Bitcoin signet (treated as testnet by the device) + Signet, + /// Bitcoin regtest + Regtest, } -/// Reference transaction output (binary format) -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct RefTxOutput { - /// Amount in satoshis - pub amount: u64, - /// Script public key (binary hex) - pub script_pubkey: String, +impl From for trezor_connect_rs::Network { + fn from(c: TrezorCoinType) -> Self { + match c { + TrezorCoinType::Bitcoin => trezor_connect_rs::Network::Bitcoin, + TrezorCoinType::Testnet | TrezorCoinType::Signet => trezor_connect_rs::Network::Testnet, + TrezorCoinType::Regtest => trezor_connect_rs::Network::Regtest, + } + } } -/// Amount unit for display -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Enum)] -pub enum AmountUnit { - #[serde(rename = "BITCOIN")] - Bitcoin, - #[serde(rename = "MILLIBITCOIN")] - MilliBitcoin, - #[serde(rename = "MICROBITCOIN")] - MicroBitcoin, - #[serde(rename = "SATOSHI")] - Satoshi, -} - -/// Payment request memo types -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct PaymentRequestMemo { - /// Text memo - #[serde(skip_serializing_if = "Option::is_none")] - pub text_memo: Option, - /// Refund memo - #[serde(skip_serializing_if = "Option::is_none")] - pub refund_memo: Option, - /// Coin purchase memo - #[serde(skip_serializing_if = "Option::is_none")] - pub coin_purchase_memo: Option, -} - -/// Text memo -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct TextMemo { - /// Text content - pub text: String, -} - -/// Refund memo -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct RefundMemo { - /// Refund address +/// Parameters for getting an address from the device. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorGetAddressParams { + /// BIP32 path (e.g., "m/84'/0'/0'/0/0") + pub path: String, + /// Coin network (default: Bitcoin) + pub coin: Option, + /// Whether to display the address on the device for confirmation + pub show_on_trezor: bool, + /// Script type (auto-detected from path if not specified) + pub script_type: Option, +} + +impl From for trezor_connect_rs::GetAddressParams { + fn from(p: TrezorGetAddressParams) -> Self { + Self { + path: p.path, + coin: p.coin.map(|c| c.into()), + show_on_trezor: p.show_on_trezor, + script_type: p.script_type.map(|s| s.into()), + multisig: None, + } + } +} + +/// Address response from device. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorAddressResponse { + /// The Bitcoin address pub address: String, - /// MAC - pub mac: String, + /// The serialized path (e.g., "m/84'/0'/0'/0/0") + pub path: String, } -/// Coin purchase memo -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct CoinPurchaseMemo { - /// Coin type - pub coin_type: u32, - /// Amount - pub amount: u64, - /// Address - pub address: String, - /// MAC - pub mac: String, -} - -/// Payment request -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct TxAckPaymentRequest { - /// Nonce - #[serde(skip_serializing_if = "Option::is_none")] - pub nonce: Option, - /// Recipient name - pub recipient_name: String, - /// Memos - #[serde(skip_serializing_if = "Option::is_none")] - pub memos: Option>, - /// Amount - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option, - /// Signature - pub signature: String, +impl From for TrezorAddressResponse { + fn from(r: trezor_connect_rs::AddressResponse) -> Self { + Self { + address: r.address, + path: r.serialized_path, + } + } } -/// Output type for compose transaction -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Enum)] -#[serde(tag = "type")] -pub enum ComposeOutput { - /// Regular output with amount and address - #[serde(rename = "regular")] - Regular { - /// Amount in satoshis - amount: String, - /// Recipient address - address: String, - }, - /// Send max output - #[serde(rename = "send-max")] - SendMax { - /// Recipient address - address: String, - }, - /// OP_RETURN output - #[serde(rename = "opreturn")] - OpReturn { - /// Hexadecimal string with arbitrary data - #[serde(rename = "dataHex")] - data_hex: String, - }, - /// Payment without address (precompose only) - #[serde(rename = "payment-noaddress")] - PaymentNoAddress { - /// Amount in satoshis - amount: String, - }, - /// Send max without address (precompose only) - #[serde(rename = "send-max-noaddress")] - SendMaxNoAddress, -} - -/// UTXO information for account -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct AccountUtxo { - /// Transaction ID - pub txid: String, - /// Output index - pub vout: u32, - /// Amount in satoshis - pub amount: String, - /// Block height - #[serde(skip_serializing_if = "Option::is_none")] - pub block_height: Option, - /// Address - pub address: String, - /// Derivation path +/// Parameters for getting a public key from the device. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorGetPublicKeyParams { + /// BIP32 path (e.g., "m/84'/0'/0'") pub path: String, - /// Number of confirmations - #[serde(skip_serializing_if = "Option::is_none")] - pub confirmations: Option, + /// Coin network (default: Bitcoin) + pub coin: Option, + /// Whether to display on device for confirmation + pub show_on_trezor: bool, } -/// Address information -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct AddressInfo { - /// Address string - pub address: String, - /// Derivation path - pub path: String, - /// Number of transfers - pub transfers: u32, +impl From for trezor_connect_rs::GetPublicKeyParams { + fn from(p: TrezorGetPublicKeyParams) -> Self { + Self { + path: p.path, + coin: p.coin.map(|c| c.into()), + show_on_trezor: p.show_on_trezor, + script_type: None, + } + } } -/// Account addresses -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct AccountAddresses { - /// Used addresses - pub used: Vec, - /// Unused addresses - pub unused: Vec, - /// Change addresses - pub change: Vec, +/// Public key response from device. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorPublicKeyResponse { + /// Extended public key (xpub) + pub xpub: String, + /// The serialized path (e.g., "m/84'/0'/0'") + pub path: String, + /// Compressed public key (hex encoded) + pub public_key: String, + /// Chain code (hex encoded) + pub chain_code: String, + /// Parent key fingerprint + pub fingerprint: u32, + /// Derivation depth + pub depth: u32, + /// Master root fingerprint (from the device's master seed) + pub root_fingerprint: Option, } -/// Account information for compose transaction -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct ComposeAccount { - /// Derivation path - pub path: String, - /// Account addresses - pub addresses: AccountAddresses, - /// UTXOs - pub utxo: Vec, -} - -/// Fee level for compose transaction -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct FeeLevel { - /// Fee per unit (satoshi/byte or satoshi/vbyte) - #[serde(rename = "feePerUnit")] - pub fee_per_unit: String, - /// Base fee in satoshi (optional, used in RBF and DOGE) - #[serde(skip_serializing_if = "Option::is_none")] - pub base_fee: Option, - /// Floor base fee (optional, used in DOGE) - #[serde(skip_serializing_if = "Option::is_none")] - pub floor_base_fee: Option, -} - -/// Parameters for composeTransaction method -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct ComposeTransactionParams { - /// Array of output objects - pub outputs: Vec, - /// Coin name/type (required) - pub coin: String, - /// Push transaction to blockchain (payment mode only) - #[serde(skip_serializing_if = "Option::is_none")] - pub push: Option, - /// Transaction sequence (for RBF or locktime) - #[serde(skip_serializing_if = "Option::is_none")] - pub sequence: Option, - /// Account info (precompose mode only) - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option, - /// Fee levels (precompose mode only) - #[serde(skip_serializing_if = "Option::is_none")] - pub fee_levels: Option>, - /// Skip input/output permutation (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub skip_permutation: Option, - /// Additional common parameters - #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub common: Option, -} - -/// Precomposed transaction input -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct PrecomposedInput { - /// BIP32 derivation path - pub address_n: Vec, - /// Amount in satoshis - pub amount: String, - /// Previous transaction hash - pub prev_hash: String, - /// Previous output index - pub prev_index: u32, - /// Script type - pub script_type: ScriptType, +impl From for TrezorPublicKeyResponse { + fn from(r: trezor_connect_rs::PublicKeyResponse) -> Self { + Self { + xpub: r.xpub, + path: r.serialized_path, + public_key: r.public_key, + chain_code: r.chain_code, + fingerprint: r.fingerprint, + depth: r.depth, + root_fingerprint: r.root_fingerprint, + } + } } -/// Precomposed transaction output -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct PrecomposedOutput { - /// BIP32 derivation path (for change outputs) - #[serde(skip_serializing_if = "Option::is_none")] - pub address_n: Option>, - /// Amount in satoshis - pub amount: String, - /// Address (for regular outputs) - #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option, - /// Script type - pub script_type: ScriptType, -} - -/// Precomposed transaction -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct PrecomposedTransaction { - /// Transaction type (usually "final" or "error") - #[serde(rename = "type")] - pub tx_type: String, - /// Total amount spent (including fee) - #[serde(rename = "totalSpent", skip_serializing_if = "Option::is_none")] - pub total_spent: Option, - /// Transaction fee - #[serde(skip_serializing_if = "Option::is_none")] - pub fee: Option, - /// Fee per byte - #[serde(rename = "feePerByte", skip_serializing_if = "Option::is_none")] - pub fee_per_byte: Option, - /// Transaction size in bytes - #[serde(skip_serializing_if = "Option::is_none")] - pub bytes: Option, - /// Transaction inputs - #[serde(skip_serializing_if = "Option::is_none")] - pub inputs: Option>, - /// Transaction outputs - #[serde(skip_serializing_if = "Option::is_none")] - pub outputs: Option>, - /// Output permutation indices - #[serde(rename = "outputsPermutation", skip_serializing_if = "Option::is_none")] - pub outputs_permutation: Option>, -} - -/// Compose transaction response -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Enum)] -#[serde(untagged)] -pub enum ComposeTransactionResponse { - /// Signed transaction (payment mode) - SignedTransaction(SignedTransactionResponse), - /// Precomposed transactions (precompose mode) - PrecomposedTransactions(Vec), -} - -/// Parameters for verifyMessage method -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct VerifyMessageParams { - /// Signer address - pub address: String, - /// Signature in base64 format - pub signature: String, - /// Signed message - pub message: String, - /// Coin name/type (required) - pub coin: String, - /// Convert message from hex - #[serde(skip_serializing_if = "Option::is_none")] - pub hex: Option, - /// Additional common parameters - #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub common: Option, -} - -/// Parameters for signMessage method -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct SignMessageParams { - /// BIP-32 path as string or array of numbers +/// Parameters for signing a message. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorSignMessageParams { + /// BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") pub path: String, - /// Coin name/type (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub coin: Option, /// Message to sign pub message: String, - /// Convert message from hex - #[serde(skip_serializing_if = "Option::is_none")] - pub hex: Option, - /// No script type - #[serde(skip_serializing_if = "Option::is_none")] - pub no_script_type: Option, - /// Additional common parameters - #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub common: Option, -} - -/// Parameters for signTransaction method -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct SignTransactionParams { - /// Coin name/type - pub coin: String, - /// Transaction inputs - pub inputs: Vec, - /// Transaction outputs - pub outputs: Vec, - /// Reference transactions - #[serde(skip_serializing_if = "Option::is_none")] - pub refTxs: Option>, - /// Payment requests (SLIP-24) - #[serde(skip_serializing_if = "Option::is_none")] - pub paymentRequests: Option>, - /// Lock time - #[serde(skip_serializing_if = "Option::is_none")] - pub locktime: Option, - /// Transaction version - #[serde(skip_serializing_if = "Option::is_none")] - pub version: Option, - /// Expiry (for Zcash/Decred) - #[serde(skip_serializing_if = "Option::is_none")] - pub expiry: Option, - /// Version group ID (for Zcash) - #[serde(skip_serializing_if = "Option::is_none")] - pub versionGroupId: Option, - /// Overwintered flag (for Zcash) - #[serde(skip_serializing_if = "Option::is_none")] - pub overwintered: Option, - /// Timestamp (for Capricoin) - #[serde(skip_serializing_if = "Option::is_none")] - pub timestamp: Option, - /// Branch ID (for Zcash) - #[serde(skip_serializing_if = "Option::is_none")] - pub branchId: Option, - /// Broadcast transaction - #[serde(skip_serializing_if = "Option::is_none")] - pub push: Option, - /// Amount unit for display - #[serde(skip_serializing_if = "Option::is_none")] - pub amountUnit: Option, - /// Unlock path - #[serde(skip_serializing_if = "Option::is_none")] - pub unlockPath: Option, - /// Serialize full transaction - #[serde(skip_serializing_if = "Option::is_none")] - pub serialize: Option, - /// Display address in chunks - #[serde(skip_serializing_if = "Option::is_none")] - pub chunkify: Option, - /// Additional common parameters - #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub common: Option, -} - -/// Parameters for getAddress method -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct GetAddressParams { - /// BIP-32 path as string or array of numbers - #[serde(rename = "path")] - pub path: String, - - /// Address for validation (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option, - - /// Show on display (optional, default is true) - #[serde(skip_serializing_if = "Option::is_none")] - pub showOnTrezor: Option, - - /// Display address in chunks of 4 characters (optional, default is false) - #[serde(skip_serializing_if = "Option::is_none")] - pub chunkify: Option, - - /// Use event listener (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub useEventListener: Option, - - /// Coin name/type (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub coin: Option, - - /// Allow cross-chain address generation (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub crossChain: Option, - - /// Multisig information (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub multisig: Option, - - /// Script type (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub scriptType: Option, - - /// Unlock path information (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub unlockPath: Option, - - /// Additional common parameters - #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub common: Option, + /// Coin network (default: Bitcoin) + pub coin: Option, } -/// Parameters for getPublicKey method -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct GetPublicKeyParams { - /// BIP-32 path as string - pub path: String, - - /// Display the result on the Trezor device (optional, default is false) - #[serde(skip_serializing_if = "Option::is_none")] - pub showOnTrezor: Option, - - /// Suppress backup warning (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub suppressBackupWarning: Option, - - /// Display the result in chunks for better readability (optional, default is false) - #[serde(skip_serializing_if = "Option::is_none")] - pub chunkify: Option, - - /// Coin name/type (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub coin: Option, - - /// Allow cross-chain key generation (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub crossChain: Option, - - /// Script type (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub scriptType: Option, - - /// Ignore SLIP-0132 XPUB magic (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub ignoreXpubMagic: Option, - - /// ECDSA curve name to use (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub ecdsaCurveName: Option, - - /// Unlock path information (optional) - #[serde(skip_serializing_if = "Option::is_none")] - pub unlockPath: Option, - - /// Additional common parameters - #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub common: Option, -} - -/// Level of details to be returned by getAccountInfo -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Enum)] -pub enum AccountInfoDetails { - /// Return only account balances (default) - #[serde(rename = "basic")] - Basic, - /// Return with derived addresses or ERC20 tokens - #[serde(rename = "tokens")] - Tokens, - /// Same as tokens with balances - #[serde(rename = "tokenBalances")] - TokenBalances, - /// TokenBalances + complete account transaction history - #[serde(rename = "txs")] - Txs, -} - -/// Token filter options for getAccountInfo -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Enum)] -pub enum TokenFilter { - /// Return only addresses with nonzero balance (default) - #[serde(rename = "nonzero")] - Nonzero, - /// Return addresses with at least one transaction - #[serde(rename = "used")] - Used, - /// Return all derived addresses - #[serde(rename = "derived")] - Derived, -} - -/// Bitcoin account types for default display -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Enum)] -pub enum DefaultAccountType { - /// Normal account - #[serde(rename = "normal")] - Normal, - /// SegWit account - #[serde(rename = "segwit")] - Segwit, - /// Legacy account - #[serde(rename = "legacy")] - Legacy, -} - -/// Marker object for XRP accounts -#[derive(Serialize, Deserialize, Debug, Clone, uniffi::Record)] -pub struct XrpMarker { - /// Ledger number - pub ledger: u64, - /// Sequence number - pub seq: u64, +impl From for trezor_connect_rs::SignMessageParams { + fn from(p: TrezorSignMessageParams) -> Self { + Self { + path: p.path, + message: p.message, + coin: p.coin.map(|c| c.into()), + no_script_type: false, + } + } } -/// Parameters for getAccountInfo method -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct GetAccountInfoParams { - // Path-based parameters - /// BIP-32 path as string - #[serde(skip_serializing_if = "Option::is_none")] - pub path: Option, - - // Descriptor-based parameters - /// Public key or address of account - #[serde(skip_serializing_if = "Option::is_none")] - pub descriptor: Option, - - // Required for all modes - /// Coin name/type - pub coin: String, - - // Optional parameters - /// Level of details returned by request - #[serde(skip_serializing_if = "Option::is_none")] - pub details: Option, - - /// Specifies which tokens (xpub addresses) are returned - #[serde(skip_serializing_if = "Option::is_none")] - pub tokens: Option, - - /// Transaction history page index - #[serde(skip_serializing_if = "Option::is_none")] - pub page: Option, - - /// Transaction history page size - #[serde(skip_serializing_if = "Option::is_none")] - pub pageSize: Option, - - /// Transaction history from block filter - #[serde(skip_serializing_if = "Option::is_none")] - pub from: Option, - - /// Transaction history to block filter - #[serde(skip_serializing_if = "Option::is_none")] - pub to: Option, - - /// Address derivation gap size - #[serde(skip_serializing_if = "Option::is_none")] - pub gap: Option, - - /// Ethereum-like accounts only: get ERC20 token info and balance - #[serde(skip_serializing_if = "Option::is_none")] - pub contractFilter: Option, - - /// XRP accounts only, transaction history page marker - #[serde(skip_serializing_if = "Option::is_none")] - pub marker: Option, - - /// Bitcoin-like accounts only: specify which account group is displayed as default in popup - #[serde(skip_serializing_if = "Option::is_none")] - pub defaultAccountType: Option, - - /// Suppress backup warning - #[serde(skip_serializing_if = "Option::is_none")] - pub suppressBackupWarning: Option, - - /// Additional common parameters - #[serde(flatten, skip_serializing_if = "Option::is_none")] - pub common: Option, +/// Response from signing a message. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorSignedMessageResponse { + /// Bitcoin address that signed the message + pub address: String, + /// Signature (base64 encoded) + pub signature: String, } -/// Type alias for TrezorConnectResult -pub type TrezorConnectResult = Result; - -/// Enum representing the different types of Trezor responses -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Enum)] -#[serde(untagged)] -pub enum TrezorResponsePayload { - /// Response from getFeatures method - Features(FeatureResponse), - - /// Response from getAddress method - Address(AddressResponse), - - /// Response from getPublicKey method - PublicKey(PublicKeyResponse), - - /// Response from getAccountInfo method - AccountInfo(AccountInfoResponse), - - /// Response from composeTransaction method - ComposeTransaction(ComposeTransactionResponse), +impl From for TrezorSignedMessageResponse { + fn from(r: trezor_connect_rs::SignedMessageResponse) -> Self { + Self { + address: r.address, + signature: r.signature, + } + } +} - /// Response from verifyMessage method - VerifyMessage(VerifyMessageResponse), +/// Parameters for verifying a message signature. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorVerifyMessageParams { + /// Bitcoin address that signed the message + pub address: String, + /// Signature (base64 encoded) + pub signature: String, + /// Original message + pub message: String, + /// Coin network (default: Bitcoin) + pub coin: Option, +} - /// Response from signMessage method - MessageSignature(MessageSignatureResponse), +impl From for trezor_connect_rs::VerifyMessageParams { + fn from(p: TrezorVerifyMessageParams) -> Self { + Self { + address: p.address, + signature: p.signature, + message: p.message, + coin: p.coin.map(|c| c.into()), + } + } +} - /// Response from signTransaction method - SignedTransaction(SignedTransactionResponse), +/// Transaction input for signing. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorTxInput { + /// Previous transaction hash (hex, 32 bytes) + pub prev_hash: String, + /// Previous output index + pub prev_index: u32, + /// BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") + pub path: String, + /// Amount in satoshis + pub amount: u64, + /// Script type + pub script_type: TrezorScriptType, + /// Sequence number (default: 0xFFFFFFFD for RBF) + pub sequence: Option, + /// Original transaction hash for RBF replacement (hex encoded) + pub orig_hash: Option, + /// Original input index for RBF replacement + pub orig_index: Option, } -/// Feature response containing device capabilities and information -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Record)] -pub struct FeatureResponse { - pub vendor: String, - pub major_version: u32, - pub minor_version: u32, - pub patch_version: u32, - pub device_id: String, - // Add other fields as needed from the getFeatures response - #[serde(skip_serializing_if = "Option::is_none")] - pub capabilities: Option>, - // Add other optional fields as needed +/// Transaction output for signing. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorTxOutput { + /// Destination address (for external outputs) + pub address: Option, + /// BIP32 path (for change outputs) + pub path: Option, + /// Amount in satoshis + pub amount: u64, + /// Script type (for change outputs) + pub script_type: Option, + /// OP_RETURN data (hex encoded, for data outputs) + pub op_return_data: Option, + /// Original transaction hash for RBF replacement (hex encoded) + pub orig_hash: Option, + /// Original output index for RBF replacement + pub orig_index: Option, } -/// Address response containing the derived address information -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Record)] -pub struct AddressResponse { - pub address: String, - pub path: Vec, - pub serializedPath: String, - // Add other fields as needed +/// Previous transaction data (for non-SegWit input verification). +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorPrevTx { + /// Transaction hash (hex encoded) + pub hash: String, + /// Transaction version + pub version: u32, + /// Lock time + pub lock_time: u32, + /// Transaction inputs + pub inputs: Vec, + /// Transaction outputs + pub outputs: Vec, } -/// Public key response containing the derived public key information -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Record)] -pub struct PublicKeyResponse { - pub path: Vec, - pub serializedPath: String, - pub xpub: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub xpubSegwit: Option, - pub chainCode: String, - pub childNum: u32, - pub publicKey: String, - pub fingerprint: u32, - pub depth: u32, - #[serde(skip_serializing_if = "Option::is_none")] - pub descriptor: Option, +/// Input of a previous transaction. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorPrevTxInput { + /// Previous transaction hash (hex encoded) + pub prev_hash: String, + /// Previous output index + pub prev_index: u32, + /// Script signature (hex encoded) + pub script_sig: String, + /// Sequence number + pub sequence: u32, } -/// Account info response -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Record)] -pub struct AccountInfoResponse { - pub id: u32, - pub path: String, - pub descriptor: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub legacyXpub: Option, - pub balance: String, - pub availableBalance: String, - // Add other fields as needed -} - -/// Verify message response -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Record)] -pub struct VerifyMessageResponse { - /// Verification result message - pub message: String, +/// Output of a previous transaction. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorPrevTxOutput { + /// Amount in satoshis + pub amount: u64, + /// Script pubkey (hex encoded) + pub script_pubkey: String, } -/// Message signature response -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Record)] -pub struct MessageSignatureResponse { - /// Signer address - pub address: String, - /// Signature in base64 format - pub signature: String, +/// Parameters for signing a transaction. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorSignTxParams { + /// Transaction inputs + pub inputs: Vec, + /// Transaction outputs + pub outputs: Vec, + /// Coin network (default: Bitcoin) + pub coin: Option, + /// Lock time (default: 0) + pub lock_time: Option, + /// Version (default: 2) + pub version: Option, + /// Previous transactions (for non-SegWit input verification) + pub prev_txs: Vec, } -/// Signed transaction response -#[derive(Debug, Clone, Deserialize, Serialize, uniffi::Record)] -pub struct SignedTransactionResponse { - /// Array of signer signatures +/// Signed transaction result. +#[derive(Debug, Clone, uniffi::Record)] +pub struct TrezorSignedTx { + /// Signatures for each input (hex encoded) pub signatures: Vec, - /// Serialized transaction - pub serializedTx: String, - /// Broadcasted transaction ID (if push was true) - #[serde(skip_serializing_if = "Option::is_none")] - pub txid: Option, -} - -/// Common response wrapper for all Trezor responses -#[derive(Debug, Clone, Deserialize)] -pub struct TrezorResponse { - pub success: bool, - #[serde(skip_serializing_if = "Option::is_none")] - pub payload: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, -} \ No newline at end of file + /// Serialized transaction (hex) + pub serialized_tx: String, +} + +impl From for trezor_connect_rs::SignTxInput { + fn from(input: TrezorTxInput) -> Self { + Self { + prev_hash: input.prev_hash, + prev_index: input.prev_index, + path: input.path, + amount: input.amount, + script_type: input.script_type.into(), + sequence: input.sequence, + orig_hash: input.orig_hash, + orig_index: input.orig_index, + } + } +} + +impl From for trezor_connect_rs::SignTxOutput { + fn from(output: TrezorTxOutput) -> Self { + Self { + address: output.address, + path: output.path, + amount: output.amount, + script_type: output.script_type.map(|s| s.into()), + op_return_data: output.op_return_data, + orig_hash: output.orig_hash, + orig_index: output.orig_index, + } + } +} + +impl From for trezor_connect_rs::SignTxPrevTxInput { + fn from(input: TrezorPrevTxInput) -> Self { + Self { + prev_hash: input.prev_hash, + prev_index: input.prev_index, + script_sig: input.script_sig, + sequence: input.sequence, + } + } +} + +impl From for trezor_connect_rs::SignTxPrevTxOutput { + fn from(output: TrezorPrevTxOutput) -> Self { + Self { + amount: output.amount, + script_pubkey: output.script_pubkey, + } + } +} + +impl From for trezor_connect_rs::SignTxPrevTx { + fn from(tx: TrezorPrevTx) -> Self { + Self { + hash: tx.hash, + version: tx.version, + lock_time: tx.lock_time, + inputs: tx.inputs.into_iter().map(|i| i.into()).collect(), + outputs: tx.outputs.into_iter().map(|o| o.into()).collect(), + } + } +} + +impl From for trezor_connect_rs::SignTxParams { + fn from(params: TrezorSignTxParams) -> Self { + Self { + inputs: params.inputs.into_iter().map(|i| i.into()).collect(), + outputs: params.outputs.into_iter().map(|o| o.into()).collect(), + coin: params.coin.map(|c| c.into()), + lock_time: params.lock_time, + version: params.version, + prev_txs: params.prev_txs.into_iter().map(|t| t.into()).collect(), + } + } +} + +impl From for TrezorSignedTx { + fn from(response: trezor_connect_rs::SignedTxResponse) -> Self { + Self { + signatures: response.signatures, + serialized_tx: response.serialized_tx, + } + } +}