diff --git a/AGENTS.md b/AGENTS.md index b59d26b..37a0b24 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,7 +20,7 @@ Android bindings are built and published by `.github/workflows/gradle-publish.ym ```bash cargo test # All tests -cargo test modules:: # Single module (arkade, scanner, lnurl, onchain, activity, blocktank, boltz, trezor, jade, hardware_wallet, ur, pubky, usdt) +cargo test modules:: # Single module (arkade, scanner, lnurl, onchain, activity, blocktank, boltz, trezor, jade, hardware_wallet, ur, pubky, pubky_swaps, usdt) ``` ## Lint & Format @@ -35,7 +35,7 @@ Android bindings use ktlint via Gradle plugin (`org.jlleitschuh.gradle.ktlint`), ## Architecture - `src/lib.rs` — UniFFI exports and module re-exports -- `src/modules/`: core modules: arkade, scanner, lnurl, onchain, activity, blocktank, boltz, trezor, jade, hardware_wallet, ur, pubky, usdt +- `src/modules/`: core modules: arkade, scanner, lnurl, onchain, activity, blocktank, boltz, trezor, jade, hardware_wallet, ur, pubky, pubky_swaps, usdt - `bindings/` — Platform-specific binding outputs (ios/, android/, python/) - `build.sh`, `build_ios.sh`, `build_android.sh`, `build_python.sh` — Build scripts diff --git a/Cargo.lock b/Cargo.lock index ede2df6..39737e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,7 +101,7 @@ dependencies = [ "fixed-cache", "foldhash 0.2.0", "hashbrown 0.17.1", - "indexmap 2.13.0", + "indexmap 2.14.2", "itoa", "k256", "keccak-asm", @@ -149,7 +149,7 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.13.0", + "indexmap 2.14.2", "proc-macro-error3", "proc-macro2", "quote", @@ -295,6 +295,15 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +[[package]] +name = "arc-swap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380962b3d93b99642e50b9febf72c071e97e8b32d86eae9cf4ef582bb960ae6e" +dependencies = [ + "rustversion", +] + [[package]] name = "argon2" version = "0.5.3" @@ -833,6 +842,17 @@ dependencies = [ "web-sys", ] +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version 0.4.1", +] + [[package]] name = "atomic-destructor" version = "0.3.0" @@ -854,6 +874,18 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "attohttpc" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e2cdb6d5ed835199484bb92bb8b3edd526effe995c61732580439c1a67e2e9" +dependencies = [ + "base64 0.22.1", + "http 1.4.0", + "log", + "url", +] + [[package]] name = "auto_impl" version = "1.3.0" @@ -954,6 +986,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +[[package]] +name = "base16ct" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" + [[package]] name = "base32" version = "0.5.1" @@ -988,6 +1026,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + [[package]] name = "base64ct" version = "1.8.3" @@ -1127,7 +1171,7 @@ dependencies = [ "rand_core 0.6.4", "ripemd", "secp256k1 0.27.0", - "sha2", + "sha2 0.10.9", "subtle", "zeroize", ] @@ -1221,7 +1265,7 @@ dependencies = [ "secp256k1 0.30.0", "serde", "serde_json", - "sha2", + "sha2 0.10.9", "zeroize", ] @@ -1319,7 +1363,7 @@ dependencies = [ [[package]] name = "bitkitcore" -version = "0.8.0-arkade.2" +version = "0.8.0-routes.1" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -1341,10 +1385,12 @@ dependencies = [ "boltz-client", "btleplug", "chrono", + "electrum-client 0.25.0", "esplora-client", "hex", + "iroh", "jade-client-rs", - "jni", + "jni 0.19.0", "lazy-regex", "lightning-invoice 0.32.0", "lnurl-rs", @@ -1369,6 +1415,7 @@ dependencies = [ "serde", "serde_json", "serial_test", + "swap-common", "tempfile", "test-case", "thiserror 2.0.18", @@ -1449,7 +1496,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" dependencies = [ - "objc2", + "objc2 0.5.2", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2 0.6.5", ] [[package]] @@ -1554,7 +1610,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ - "sha2", + "sha2 0.10.9", "tinyvec", ] @@ -1570,20 +1626,20 @@ dependencies = [ "dashmap 6.1.0", "dbus", "futures", - "jni", + "jni 0.19.0", "jni-utils", "log", - "objc2", + "objc2 0.5.2", "objc2-core-bluetooth", - "objc2-foundation", + "objc2-foundation 0.2.2", "once_cell", "static_assertions", "thiserror 2.0.18", "tokio", "tokio-stream", "uuid", - "windows", - "windows-future", + "windows 0.61.3", + "windows-future 0.2.1", ] [[package]] @@ -1718,9 +1774,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" [[package]] name = "chacha20" @@ -1857,6 +1913,12 @@ dependencies = [ "cc", ] +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + [[package]] name = "cobs" version = "0.3.0" @@ -1900,6 +1962,12 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const-oid" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" + [[package]] name = "const_format" version = "0.2.36" @@ -2129,6 +2197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ "hybrid-array", + "rand_core 0.10.0", ] [[package]] @@ -2155,6 +2224,15 @@ dependencies = [ "cipher", ] +[[package]] +name = "ctutils" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2376ffd6f96d8a9db59875b4b6b0237d6900b5baf64279714e05493ce64828a" +dependencies = [ + "cmov", +] + [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -2165,8 +2243,26 @@ dependencies = [ "cpufeatures 0.2.17", "curve25519-dalek-derive", "digest 0.10.7", - "fiat-crypto", + "fiat-crypto 0.2.9", + "rustc_version 0.4.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "curve25519-dalek-derive", + "digest 0.11.3", + "fiat-crypto 0.3.0", + "rand_core 0.10.0", "rustc_version 0.4.1", + "serde", "subtle", "zeroize", ] @@ -2245,9 +2341,29 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.11.0" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" + +[[package]] +name = "data-encoding-macro" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6a127ecbb3c4632e1525380e04c0c3fcf8dcb44d32a79ea290d8a36906edcd8" +dependencies = [ + "data-encoding", + "data-encoding-macro-internal", +] + +[[package]] +name = "data-encoding-macro-internal" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" +checksum = "c54e03a951783e8b327515db3f2a2fd0e3bed362a96b066f341ce66ed49b4ead" +dependencies = [ + "data-encoding", + "syn 3.0.6", +] [[package]] name = "dbus" @@ -2311,7 +2427,18 @@ version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ - "const-oid", + "const-oid 0.9.6", + "zeroize", +] + +[[package]] +name = "der" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a996a108feb8b427a6e12fcf6af4aa83409b79d72c15337d7741368131ee004" +dependencies = [ + "const-oid 0.10.2", + "pem-rfc7468", "zeroize", ] @@ -2381,7 +2508,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid", + "const-oid 0.9.6", "crypto-common 0.1.7", "subtle", ] @@ -2396,6 +2523,18 @@ dependencies = [ "crypto-common 0.2.2", ] +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags 2.11.0", + "block2 0.6.2", + "libc", + "objc2 0.6.5", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -2407,6 +2546,17 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "dlopen2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e2c5bd4158e66d1e215c49b837e11d62f3267b30c92f1d171c4d3105e3dc4d4" +dependencies = [ + "libc", + "once_cell", + "winapi", +] + [[package]] name = "dnssec-prover" version = "0.6.8" @@ -2449,12 +2599,12 @@ version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der", + "der 0.7.10", "digest 0.10.7", "elliptic-curve", "rfc6979", - "signature", - "spki", + "signature 2.2.0", + "spki 0.7.3", ] [[package]] @@ -2463,9 +2613,20 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", + "pkcs8 0.10.2", "serde", - "signature", + "signature 2.2.0", +] + +[[package]] +name = "ed25519" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a" +dependencies = [ + "pkcs8 0.11.0", + "serdect", + "signature 3.0.0", ] [[package]] @@ -2474,10 +2635,26 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" dependencies = [ - "curve25519-dalek", - "ed25519", + "curve25519-dalek 4.1.3", + "ed25519 2.2.3", + "serde", + "sha2 0.10.9", + "subtle", + "zeroize", +] + +[[package]] +name = "ed25519-dalek" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" +dependencies = [ + "curve25519-dalek 5.0.0", + "ed25519 3.0.0", + "rand_core 0.10.0", "serde", - "sha2", + "sha2 0.11.1", + "signature 3.0.0", "subtle", "zeroize", ] @@ -2555,13 +2732,13 @@ version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ - "base16ct", + "base16ct 0.2.0", "crypto-bigint", "digest 0.10.7", "ff", "generic-array", "group", - "pkcs8", + "pkcs8 0.10.2", "rand_core 0.6.4", "sec1", "subtle", @@ -2591,9 +2768,9 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "encoding_rs" -version = "0.8.42" +version = "0.8.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" dependencies = [ "cfg-if", "core_detect", @@ -2603,6 +2780,17 @@ dependencies = [ "simdutf8", ] +[[package]] +name = "enum-assoc" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0590c4a94da3372e83493b956755a6e2266830b6e4e3b101afe66e3f39477b91" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + [[package]] name = "enum-ordinalize" version = "4.4.2" @@ -2742,6 +2930,12 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "fiat-crypto" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" + [[package]] name = "find-msvc-tools" version = "0.1.9" @@ -3140,7 +3334,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.13.0", + "indexmap 2.14.2", "slab", "tokio", "tokio-util", @@ -3159,7 +3353,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.4.0", - "indexmap 2.13.0", + "indexmap 2.14.2", "slab", "tokio", "tokio-util", @@ -3220,12 +3414,6 @@ dependencies = [ "foldhash 0.1.5", ] -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" - [[package]] name = "hashbrown" version = "0.17.1" @@ -3663,6 +3851,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "identity-hash" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfdd7caa900436d8f13b2346fe10257e0c05c1f1f9e351f4f5d57c03bd5f45da" + [[package]] name = "idna" version = "1.1.0" @@ -3684,6 +3878,26 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "igd-next" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de7238d487a9aff61f81b5ab41c0a841532a115a398b5fa92a2fadd0885e2581" +dependencies = [ + "attohttpc", + "bytes", + "futures", + "http 1.4.0", + "http-body-util", + "hyper 1.12.0", + "hyper-util", + "log", + "rand 0.10.3", + "tokio", + "url", + "xmltree", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -3717,12 +3931,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.13.0" +version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", - "hashbrown 0.16.1", + "hashbrown 0.17.1", "serde", "serde_core", ] @@ -3759,6 +3973,19 @@ dependencies = [ "mach2", ] +[[package]] +name = "ipconfig" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d40460c0ce33d6ce4b0630ad68ff63d6661961c48b6dba35e5a4d81cfb48222" +dependencies = [ + "socket2 0.6.3", + "widestring", + "windows-registry", + "windows-result 0.4.1", + "windows-sys 0.61.2", +] + [[package]] name = "ipnet" version = "2.12.0" @@ -3776,48 +4003,212 @@ dependencies = [ ] [[package]] -name = "is_terminal_polyfill" -version = "1.70.2" +name = "iroh" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +checksum = "b2f8d1cfffc83efe39a1031aab423ce09cb8048071baba550508931e9a81ce46" +dependencies = [ + "backon", + "blake3", + "bytes", + "cfg_aliases", + "ctutils", + "data-encoding", + "derive_more", + "ed25519-dalek 3.0.0", + "futures-util", + "getrandom 0.4.2", + "http 1.4.0", + "ipnet", + "iroh-base", + "iroh-dns", + "iroh-metrics", + "iroh-relay", + "n0-error", + "n0-future", + "n0-watcher", + "netwatch", + "noq", + "noq-proto", + "noq-udp", + "papaya", + "pin-project", + "portable-atomic", + "portmapper", + "rand 0.10.3", + "reqwest 0.13.5", + "rustc-hash", + "rustls 0.23.46", + "rustls-pki-types", + "serde", + "smallvec", + "strum", + "time", + "tokio", + "tokio-stream", + "tokio-util", + "tracing", + "url", + "wasm-bindgen-futures", +] [[package]] -name = "itertools" -version = "0.10.5" +name = "iroh-base" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "43b72366b16001af3a51574233df88ca6d62da0215807549a769e7de887da803" dependencies = [ - "either", + "curve25519-dalek 5.0.0", + "data-encoding", + "data-encoding-macro", + "derive_more", + "ed25519-dalek 3.0.0", + "getrandom 0.4.2", + "n0-error", + "rand 0.10.3", + "serde", + "url", + "zeroize", ] [[package]] -name = "itertools" -version = "0.13.0" +name = "iroh-dns" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "7481d0792dde1035a2b06ec06ed3cf6d01fcb1a494e6931b489e32073382048d" dependencies = [ - "either", + "arc-swap", + "cfg_aliases", + "derive_more", + "iroh-base", + "n0-dns-resolver", + "n0-error", + "n0-future", + "portable-atomic", + "rand 0.10.3", + "rustls 0.23.46", + "simple-dns 0.12.0", + "strum", + "tokio", + "tracing", + "url", ] [[package]] -name = "itertools" -version = "0.14.0" +name = "iroh-metrics" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +checksum = "8ede55536349842337f7cdc63012ec33dc637945f3259c98a0763aac364cdf09" dependencies = [ - "either", + "iroh-metrics-derive", + "itoa", + "n0-error", + "portable-atomic", + "ryu", + "serde", + "tracing", ] [[package]] -name = "itoa" -version = "1.0.17" +name = "iroh-metrics-derive" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +checksum = "1ae5f0c4405d1fbc9fb16ff422ca40620e93dc36c30ecaba0c2aee3992b7bd48" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.117", +] [[package]] -name = "jade-client-rs" -version = "0.2.0" -source = "git+https://github.com/synonymdev/jade-client-rs?rev=d46d02a#d46d02a33b373805c487262390a85f9cec0f7723" +name = "iroh-relay" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e5589e7c1475700686603a970275687f760df853bc6525c7eb1347aa31d7230" +dependencies = [ + "blake3", + "bytes", + "cfg_aliases", + "data-encoding", + "derive_more", + "getrandom 0.4.2", + "http 1.4.0", + "http-body-util", + "hyper 1.12.0", + "hyper-util", + "iroh-base", + "iroh-dns", + "iroh-metrics", + "lru 0.18.5", + "n0-error", + "n0-future", + "noq", + "noq-proto", + "num_enum", + "percent-encoding", + "pin-project", + "postcard", + "rand 0.10.3", + "reqwest 0.13.5", + "rustls 0.23.46", + "rustls-pki-types", + "serde", + "serde_bytes", + "strum", + "tokio", + "tokio-rustls", + "tokio-util", + "tokio-websockets", + "tracing", + "url", + "webpki-roots 1.0.11", + "ws_stream_wasm", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[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.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jade-client-rs" +version = "0.2.0" +source = "git+https://github.com/synonymdev/jade-client-rs?rev=d46d02a#d46d02a33b373805c487262390a85f9cec0f7723" dependencies = [ "async-trait", "base64 0.22.1", @@ -3887,10 +4278,56 @@ checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" dependencies = [ "cesu8", "combine", - "jni-sys", + "jni-sys 0.3.0", + "log", + "thiserror 1.0.69", + "walkdir", +] + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys 0.3.0", "log", "thiserror 1.0.69", "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.18", + "walkdir", + "windows-link 0.2.1", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version 0.4.1", + "simd_cesu8", + "syn 2.0.117", ] [[package]] @@ -3899,6 +4336,25 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.117", +] + [[package]] name = "jni-utils" version = "0.1.1" @@ -3907,7 +4363,7 @@ checksum = "259e9f2c3ead61de911f147000660511f07ab00adeed1d84f5ac4d0386e7a6c4" dependencies = [ "dashmap 5.5.3", "futures", - "jni", + "jni 0.19.0", "log", "once_cell", "static_assertions", @@ -3944,7 +4400,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2", + "sha2 0.10.9", ] [[package]] @@ -4250,12 +4706,27 @@ version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" +[[package]] +name = "lru" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5" +dependencies = [ + "hashbrown 0.17.1", +] + [[package]] name = "lru-slab" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" +[[package]] +name = "mac-addr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3d25b0e0b648a86960ac23b7ad4abb9717601dec6f66c165f5b037f3f03065f" + [[package]] name = "mach2" version = "0.4.3" @@ -4285,7 +4756,7 @@ dependencies = [ "crc", "document-features", "dyn-clone", - "ed25519-dalek", + "ed25519-dalek 2.2.0", "flume", "futures-lite", "getrandom 0.2.17", @@ -4401,6 +4872,99 @@ dependencies = [ "byteorder", ] +[[package]] +name = "musig2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183312a1f782d0e27c2e9aa4d68c151301caa39b38f48ea125c1d55ab1ff29f0" +dependencies = [ + "base16ct 0.2.0", + "hmac", + "secp", + "secp256k1 0.31.1", + "sha2 0.10.9", + "subtle", +] + +[[package]] +name = "n0-dns-resolver" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535c99c9a786bee714155d2ee4fc2477405c2c43536e1bc6a51de09a0d1448f7" +dependencies = [ + "derive_more", + "ipconfig", + "jni 0.22.4", + "lru 0.18.5", + "n0-error", + "n0-future", + "ndk-context", + "rand 0.10.3", + "reqwest 0.13.5", + "rustc-hash", + "rustls 0.23.46", + "simple-dns 0.12.0", + "system-configuration 0.8.0", + "tokio", + "tokio-rustls", + "tracing", + "webpki-roots 1.0.11", +] + +[[package]] +name = "n0-error" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c59ea174675ce6bc196878851e5049e11b8b1f9af3ba87e4d6df8d828bb001" +dependencies = [ + "n0-error-macros", + "spez", +] + +[[package]] +name = "n0-error-macros" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4412346410d6616f3668c40e53c298e5320c7b856f7a960e5914e442601be79f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "n0-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2ab99dfb861450e68853d34ae665243a88b8c493d01ba957321a1e9b2312bbe" +dependencies = [ + "cfg_aliases", + "derive_more", + "futures-buffered", + "futures-lite", + "futures-util", + "js-sys", + "pin-project", + "send_wrapper", + "tokio", + "tokio-util", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-time", +] + +[[package]] +name = "n0-watcher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64bf1ecb076a87e0e3f5edcf726e7d29e788c273bb0161ba30666b53f085906c" +dependencies = [ + "derive_more", + "n0-error", + "n0-future", + "slotmap", +] + [[package]] name = "native-tls" version = "0.2.18" @@ -4419,30 +4983,266 @@ dependencies = [ ] [[package]] -name = "negentropy" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d66662cb5ca384d4991509755ed5a42dd8e31c4282bf881938e506fc3146ec" - -[[package]] -name = "nix" -version = "0.26.4" +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "negentropy" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6f12461d14b5768028d39fab3cdfbcefb0bc7f09e95f413a00b6fdedcc9c2d" + +[[package]] +name = "netdev" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "096c44b66a9b09b99b4dd36b1c295ff3a492039ccecaf55466bd6ddcdba59968" +dependencies = [ + "block2 0.6.2", + "dispatch2", + "dlopen2", + "ipnet", + "jni 0.21.1", + "libc", + "mac-addr", + "ndk-context", + "netlink-packet-core 0.8.2", + "netlink-packet-route 0.31.0", + "netlink-sys 0.8.8", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-wlan", + "objc2-foundation 0.3.2", + "objc2-system-configuration", + "once_cell", + "plist", + "windows-sys 0.61.2", +] + +[[package]] +name = "netdev" +version = "0.46.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c52c2584961c68f5a6e3356797344061f818c93b8acc9cd6d7e284795e563e" +dependencies = [ + "block2 0.6.2", + "dispatch2", + "dlopen2", + "ipnet", + "jni 0.21.1", + "libc", + "mac-addr", + "ndk-context", + "netlink-packet-core 0.9.0", + "netlink-packet-route 0.33.0", + "netlink-sys 0.9.0", + "objc2-core-foundation", + "objc2-system-configuration", + "once_cell", + "plist", + "windows-sys 0.61.2", +] + +[[package]] +name = "netlink-packet-core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b897d7bd4f0af82e68d40d0344cf37e97f9c97ddf74a098de3e4da05e96ca395" +dependencies = [ + "paste", +] + +[[package]] +name = "netlink-packet-core" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d6e2daf9a8c2e21302714706860a0e6be02e03d17294ecc66b354ea7d4059dd" + +[[package]] +name = "netlink-packet-route" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2288fcb784eb3defd5fb16f4c4160d5f477de192eac730f43e1d11c24d9a007" +dependencies = [ + "bitflags 2.11.0", + "libc", + "log", + "netlink-packet-core 0.8.2", +] + +[[package]] +name = "netlink-packet-route" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59d48ffc8b73a506e1ff0878528c72668f2bfbc3d875b6be890a96be5d0d5576" +dependencies = [ + "bitflags 2.11.0", + "libc", + "log", + "netlink-packet-core 0.9.0", + "zerocopy", +] + +[[package]] +name = "netlink-proto" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93af8261786086024cd5e96e0a991dd65ced07bbf7c233a487bbc96b971d5539" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "log", + "netlink-packet-core 0.8.2", + "netlink-sys 0.8.8", + "thiserror 2.0.18", +] + +[[package]] +name = "netlink-sys" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6c30ed10fa69cc491d491b85cc971f6bdeb8e7367b7cde2ee6cc878d583fae" +dependencies = [ + "bytes", + "futures-util", + "libc", + "log", + "tokio", +] + +[[package]] +name = "netlink-sys" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c99d38e00b420df49e940fe0826e667c3dad82ac68eb4c2bbf754c1c14a83a10" +dependencies = [ + "bytes", + "libc", + "log", +] + +[[package]] +name = "netwatch" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39da9cad5f23aa43401f09497d3b280e51b5feba115d9ffbf38ca35d6ff95e96" +dependencies = [ + "atomic-waker", + "bytes", + "cfg_aliases", + "derive_more", + "ipnet", + "js-sys", + "libc", + "n0-error", + "n0-future", + "n0-watcher", + "netdev 0.45.1", + "netdev 0.46.3", + "netlink-packet-core 0.8.2", + "netlink-packet-route 0.31.0", + "netlink-proto", + "netlink-sys 0.8.8", + "noq-udp", + "objc2-core-foundation", + "objc2-system-configuration", + "pin-project-lite", + "serde", + "socket2 0.6.3", + "time", + "tokio", + "tokio-util", + "tracing", + "web-sys", + "windows 0.62.2", + "windows-result 0.4.1", + "wmi", +] + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "noq" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6249a065adc1edbc1704a95436f38dd60476064dbc3b7c47cf279e02d1590eb5" +dependencies = [ + "bytes", + "cfg_aliases", + "derive_more", + "noq-proto", + "noq-udp", + "pin-project-lite", + "rustc-hash", + "rustls 0.23.46", + "socket2 0.6.3", + "thiserror 2.0.18", + "tokio", + "tokio-stream", + "tracing", + "web-time", +] + +[[package]] +name = "noq-proto" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c01a35be3ed37558c8db69554419f24eff8a63599b54f711bbe3863ec727c47d" +dependencies = [ + "aes-gcm", + "bytes", + "derive_more", + "enum-assoc", + "getrandom 0.4.2", + "identity-hash", + "lru-slab", + "rand 0.10.3", + "rand_pcg", + "ring", + "rustc-hash", + "rustls 0.23.46", + "rustls-pki-types", + "slab", + "sorted-index-buffer", + "thiserror 2.0.18", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "noq-udp" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "8d0160422832eea1cc11c34be04ee6d5a046452b0b46cfb14695d55a1f24c954" dependencies = [ - "bitflags 1.3.2", - "cfg-if", + "cfg_aliases", "libc", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", + "socket2 0.6.3", + "tracing", + "windows-sys 0.61.2", ] [[package]] @@ -4568,6 +5368,28 @@ dependencies = [ "libm", ] +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "objc-sys" version = "0.3.5" @@ -4584,6 +5406,15 @@ dependencies = [ "objc2-encode", ] +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + [[package]] name = "objc2-core-bluetooth" version = "0.2.2" @@ -4591,8 +5422,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a644b62ffb826a5277f536cf0f701493de420b13d40e700c452c36567771111" dependencies = [ "bitflags 2.11.0", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.11.0", + "block2 0.6.2", + "dispatch2", + "libc", + "objc2 0.6.5", +] + +[[package]] +name = "objc2-core-wlan" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e34919aba0d701380d911702455038a8a3587467fe0141d6a71501e7ffe48" +dependencies = [ + "bitflags 2.11.0", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-security", + "objc2-security-foundation", ] [[package]] @@ -4608,9 +5466,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ "bitflags 2.11.0", - "block2", + "block2 0.5.1", + "libc", + "objc2 0.5.2", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.11.0", + "block2 0.6.2", + "libc", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-security" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" +dependencies = [ + "bitflags 2.11.0", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-security-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef76382e9cedd18123099f17638715cc3d81dba3637d4c0d39ab69df2ef345a5" +dependencies = [ + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-system-configuration" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396" +dependencies = [ + "bitflags 2.11.0", + "dispatch2", "libc", - "objc2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-security", ] [[package]] @@ -4695,6 +5601,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "papaya" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da2442474a9404698c42509b8967f437249dbc7b50493e83020333d3943ec0ae" +dependencies = [ + "equivalent", + "seize", +] + [[package]] name = "parity-scale-codec" version = "3.7.5" @@ -4804,6 +5720,15 @@ dependencies = [ "hmac", ] +[[package]] +name = "pem-rfc7468" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.2" @@ -4827,7 +5752,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" dependencies = [ "fixedbitset", - "indexmap 2.13.0", + "indexmap 2.14.2", ] [[package]] @@ -4838,7 +5763,17 @@ checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" dependencies = [ "fixedbitset", "hashbrown 0.15.5", - "indexmap 2.13.0", + "indexmap 2.14.2", +] + +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version 0.4.1", ] [[package]] @@ -4922,7 +5857,7 @@ dependencies = [ "cfg_aliases", "document-features", "dyn-clone", - "ed25519-dalek", + "ed25519-dalek 2.2.0", "futures-buffered", "futures-lite", "genawaiter", @@ -4939,7 +5874,7 @@ dependencies = [ "self_cell", "serde", "sha1_smol", - "simple-dns", + "simple-dns 0.9.3", "thiserror 2.0.18", "tokio", "tracing", @@ -4953,8 +5888,18 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der", - "spki", + "der 0.7.10", + "spki 0.7.3", +] + +[[package]] +name = "pkcs8" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" +dependencies = [ + "der 0.8.3", + "spki 0.8.1", ] [[package]] @@ -4969,6 +5914,19 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "plist" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327a4cb2ad49dc48adfdc9da89e22c64d488b508c67a044d71ba729e4521a285" +dependencies = [ + "base64 0.23.1", + "indexmap 2.14.2", + "quick-xml", + "serde", + "time", +] + [[package]] name = "poly1305" version = "0.8.0" @@ -4997,6 +5955,9 @@ name = "portable-atomic" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" +dependencies = [ + "serde", +] [[package]] name = "portable-atomic-util" @@ -5007,6 +5968,35 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "portmapper" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca97242f016e090a25330613bc2382aab65eb22f9149dbe84d8f8e711d49a530" +dependencies = [ + "base64 0.22.1", + "bytes", + "derive_more", + "hyper-util", + "igd-next", + "iroh-metrics", + "libc", + "n0-error", + "n0-future", + "netwatch", + "num_enum", + "rand 0.10.3", + "serde", + "smallvec", + "socket2 0.6.3", + "time", + "tokio", + "tokio-util", + "tower-layer", + "tracing", + "url", +] + [[package]] name = "possiblyrandom" version = "0.2.1" @@ -5026,9 +6016,21 @@ dependencies = [ "embedded-io 0.4.0", "embedded-io 0.6.1", "heapless", + "postcard-derive", "serde", ] +[[package]] +name = "postcard-derive" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0232bd009a197ceec9cc881ba46f727fcd8060a2d8d6a9dde7a69030a6fe2bb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "potential_utf" version = "0.1.4" @@ -5360,7 +6362,7 @@ dependencies = [ "base32", "blake3", "crypto_secretbox", - "ed25519-dalek", + "ed25519-dalek 2.2.0", "js-sys", "once_cell", "pkarr", @@ -5381,7 +6383,7 @@ dependencies = [ "base32", "blake3", "crypto_secretbox", - "ed25519-dalek", + "ed25519-dalek 2.2.0", "js-sys", "once_cell", "pkarr", @@ -5420,9 +6422,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.13.5" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278e9268c93b9e498a2da46c34d90ba93a3255eb99009646398f34bc73ab36eb" +checksum = "3db2be46835f013dd3f4fa7f5f7402c537787b54ebb6fe2b94bbdd7e2669bb7b" dependencies = [ "bitflags 2.11.0", "memchr", @@ -5438,6 +6440,15 @@ dependencies = [ "pulldown-cmark", ] +[[package]] +name = "quick-xml" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b" +dependencies = [ + "memchr", +] + [[package]] name = "quinn" version = "0.11.9" @@ -5821,6 +6832,43 @@ dependencies = [ "webpki-roots 1.0.11", ] +[[package]] +name = "reqwest" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-core", + "futures-util", + "http 1.4.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.12.0", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "rustls 0.23.46", + "rustls-pki-types", + "rustls-platform-verifier", + "sync_wrapper 1.0.2", + "tokio", + "tokio-rustls", + "tokio-util", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams 0.5.0", + "web-sys", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -5985,9 +7033,9 @@ dependencies = [ [[package]] name = "rustc-hash" -version = "2.1.1" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" [[package]] name = "rustc-hex" @@ -6085,6 +7133,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni 0.22.4", + "log", + "once_cell", + "rustls 0.23.46", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki 0.103.15", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -6240,7 +7315,7 @@ dependencies = [ "password-hash", "pbkdf2", "salsa20", - "sha2", + "sha2 0.10.9", ] [[package]] @@ -6271,14 +7346,25 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "base16ct", - "der", + "base16ct 0.2.0", + "der 0.7.10", "generic-array", - "pkcs8", + "pkcs8 0.10.2", "subtle", "zeroize", ] +[[package]] +name = "secp" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ef0ffc3b1b2720b00b919f6c697b1e64aca7bba54b93e0ef4b8560fac6f946" +dependencies = [ + "base16ct 0.2.0", + "secp256k1 0.31.1", + "subtle", +] + [[package]] name = "secp256k1" version = "0.27.0" @@ -6437,6 +7523,12 @@ dependencies = [ "libc", ] +[[package]] +name = "seize" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b55fb86dfd3a2f5f76ea78310a88f96c4ea21a3031f8d212443d56123fd0521" + [[package]] name = "self_cell" version = "1.2.2" @@ -6471,6 +7563,12 @@ dependencies = [ "pest", ] +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" version = "1.0.228" @@ -6580,7 +7678,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.13.0", + "indexmap 2.14.2", "jiff", "schemars 0.9.0", "schemars 1.2.2", @@ -6602,6 +7700,16 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "serdect" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e" +dependencies = [ + "base16ct 1.0.0", + "serde", +] + [[package]] name = "serial_test" version = "3.4.0" @@ -6674,6 +7782,17 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.3", +] + [[package]] name = "sha3" version = "0.10.9" @@ -6739,12 +7858,31 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" +dependencies = [ + "rand_core 0.10.0", +] + [[package]] name = "simd-adler32" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version 0.4.1", + "simdutf8", +] + [[package]] name = "simdutf8" version = "0.1.5" @@ -6760,6 +7898,15 @@ dependencies = [ "bitflags 2.11.0", ] +[[package]] +name = "simple-dns" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b6f884fa9a8d48101774bfbd3aeb81e968dd22cffd19a372da69f183db22c1a" +dependencies = [ + "bitflags 2.11.0", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -6794,6 +7941,15 @@ dependencies = [ "parking_lot 0.11.2", ] +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + [[package]] name = "smallvec" version = "1.15.1" @@ -6837,6 +7993,23 @@ dependencies = [ "winapi", ] +[[package]] +name = "sorted-index-buffer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea06cc588e43c632923a55450401b8f25e628131571d4e1baea1bdfdb2b5ed06" + +[[package]] +name = "spez" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87e960f4dca2788eeb86bbdde8dd246be8948790b7618d656e68f9b720a86e8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "spin" version = "0.9.8" @@ -6859,7 +8032,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der", + "der 0.7.10", +] + +[[package]] +name = "spki" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9" +dependencies = [ + "base64ct", + "der 0.8.3", ] [[package]] @@ -6880,12 +8063,51 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "swap-common" +version = "0.1.0" +source = "git+https://github.com/coreyphillips/pubky-swap?rev=8686702#86867029e6da06e7ba787c6ec61667a38789fe7a" +dependencies = [ + "anyhow", + "bitcoin 0.32.8", + "hex", + "musig2", + "rand 0.8.5", + "serde", + "serde_json", + "thiserror 1.0.69", + "tokio", + "tracing", + "uuid", +] + [[package]] name = "syn" version = "1.0.109" @@ -6988,6 +8210,17 @@ dependencies = [ "system-configuration-sys 0.6.0", ] +[[package]] +name = "system-configuration" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501336eb7ba9e417300a6a0fa985721065467aa83a6dcf0422a8e43e4c0328fa" +dependencies = [ + "bitflags 2.11.0", + "core-foundation 0.10.1", + "system-configuration-sys 0.6.0", +] + [[package]] name = "system-configuration-sys" version = "0.5.0" @@ -7126,6 +8359,7 @@ checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" dependencies = [ "deranged", "itoa", + "js-sys", "num-conv", "powerfmt", "serde_core", @@ -7291,10 +8525,34 @@ dependencies = [ "bytes", "futures-core", "futures-sink", + "futures-util", "pin-project-lite", "tokio", ] +[[package]] +name = "tokio-websockets" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52efb639344a7c6adb8e62c6f3d2c19c001ff1b79a5041ba1c6ed42e19c6aa5" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-sink", + "getrandom 0.4.2", + "http 1.4.0", + "httparse", + "rand 0.10.3", + "ring", + "rustls-pki-types", + "sha1_smol", + "simdutf8", + "tokio", + "tokio-rustls", + "tokio-util", +] + [[package]] name = "toml" version = "0.5.11" @@ -7319,7 +8577,7 @@ version = "0.25.4+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7193cbd0ce53dc966037f54351dbbcf0d5a642c7f0038c382ef9e677ce8c13f2" dependencies = [ - "indexmap 2.13.0", + "indexmap 2.14.2", "toml_datetime", "toml_parser", "winnow 0.7.15", @@ -7445,7 +8703,7 @@ dependencies = [ "tower-service", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", + "wasm-streams 0.4.2", "web-sys", ] @@ -7457,7 +8715,7 @@ checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", - "indexmap 2.13.0", + "indexmap 2.14.2", "pin-project-lite", "slab", "sync_wrapper 1.0.2", @@ -7504,6 +8762,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -7584,7 +8843,7 @@ dependencies = [ "rusb", "serde", "serde_json", - "sha2", + "sha2 0.10.9", "thiserror 1.0.69", "tokio", "tracing", @@ -7727,7 +8986,7 @@ dependencies = [ "glob", "goblin", "heck", - "indexmap 2.13.0", + "indexmap 2.14.2", "once_cell", "serde", "tempfile", @@ -7759,7 +9018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09acd2ce09c777dd65ee97c251d33c8a972afc04873f1e3b21eb3492ade16933" dependencies = [ "anyhow", - "indexmap 2.13.0", + "indexmap 2.14.2", "proc-macro2", "quote", "syn 2.0.117", @@ -7802,7 +9061,7 @@ checksum = "dd76b3ac8a2d964ca9fce7df21c755afb4c77b054a85ad7a029ad179cc5abb8a" dependencies = [ "anyhow", "heck", - "indexmap 2.13.0", + "indexmap 2.14.2", "tempfile", "uniffi_internal_macros", ] @@ -7906,6 +9165,7 @@ dependencies = [ "getrandom 0.4.2", "js-sys", "rand 0.10.3", + "serde_core", "wasm-bindgen", ] @@ -8046,7 +9306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" dependencies = [ "anyhow", - "indexmap 2.13.0", + "indexmap 2.14.2", "wasm-encoder", "wasmparser", ] @@ -8064,6 +9324,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm-streams" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmparser" version = "0.244.0" @@ -8072,7 +9345,7 @@ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ "bitflags 2.11.0", "hashbrown 0.15.5", - "indexmap 2.13.0", + "indexmap 2.14.2", "semver 1.0.27", ] @@ -8106,6 +9379,15 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e49d0e65abc00c142e8f9428da991da9f1a250c39be97459901eb12b9b49f62a" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webpki-roots" version = "0.22.6" @@ -8148,6 +9430,12 @@ dependencies = [ "nom", ] +[[package]] +name = "widestring" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" + [[package]] name = "winapi" version = "0.3.9" @@ -8185,11 +9473,23 @@ version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "windows-collections", + "windows-collections 0.2.0", "windows-core 0.61.2", - "windows-future", + "windows-future 0.2.1", "windows-link 0.1.3", - "windows-numerics", + "windows-numerics 0.2.0", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections 0.3.2", + "windows-core 0.62.2", + "windows-future 0.3.2", + "windows-numerics 0.3.1", ] [[package]] @@ -8201,6 +9501,15 @@ dependencies = [ "windows-core 0.61.2", ] +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core 0.62.2", +] + [[package]] name = "windows-core" version = "0.61.2" @@ -8235,7 +9544,18 @@ checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ "windows-core 0.61.2", "windows-link 0.1.3", - "windows-threading", + "windows-threading 0.1.0", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", + "windows-threading 0.2.1", ] [[package]] @@ -8282,6 +9602,16 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", +] + [[package]] name = "windows-registry" version = "0.6.1" @@ -8329,6 +9659,15 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -8365,6 +9704,21 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -8405,6 +9759,21 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -8417,6 +9786,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -8429,6 +9804,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -8447,6 +9828,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -8459,6 +9846,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -8471,6 +9864,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -8483,6 +9882,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -8551,7 +9956,7 @@ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" dependencies = [ "anyhow", "heck", - "indexmap 2.13.0", + "indexmap 2.14.2", "prettyplease", "syn 2.0.117", "wasm-metadata", @@ -8582,7 +9987,7 @@ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", "bitflags 2.11.0", - "indexmap 2.13.0", + "indexmap 2.14.2", "log", "serde", "serde_derive", @@ -8601,7 +10006,7 @@ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" dependencies = [ "anyhow", "id-arena", - "indexmap 2.13.0", + "indexmap 2.14.2", "log", "semver 1.0.27", "serde", @@ -8611,12 +10016,46 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wmi" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c81b85c57a57500e56669586496bf2abd5cf082b9d32995251185d105208b64" +dependencies = [ + "chrono", + "futures", + "log", + "serde", + "thiserror 2.0.18", + "windows 0.62.2", + "windows-core 0.62.2", +] + [[package]] name = "writeable" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" +[[package]] +name = "ws_stream_wasm" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c173014acad22e83f16403ee360115b38846fe754e735c5d9d3803fe70c6abc" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version 0.4.1", + "send_wrapper", + "thiserror 2.0.18", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wyz" version = "0.5.1" @@ -8632,7 +10071,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ - "curve25519-dalek", + "curve25519-dalek 4.1.3", "rand_core 0.6.4", "serde", "zeroize", @@ -8644,6 +10083,21 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8aa498d22c9bbaf482329839bc5620c46be275a19a812e9a22a2b07529a642a" +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "xmltree" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb" +dependencies = [ + "xml-rs", +] + [[package]] name = "yoke" version = "0.8.1" @@ -8710,18 +10164,18 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 4d0fdee..e4f02bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitkitcore" -version = "0.8.0-arkade.2" +version = "0.8.0-routes.1" edition = "2021" rust-version = "1.90" @@ -45,6 +45,11 @@ ur = "0.5.2" log = "0.4" pubky = "0.6.0" pubky-app-specs = "0.4" +# Pubky Swaps client: wire types, contract checks and HTLC spends from pubky-swap, +# requests over its iroh `pubky-swap/direct/1` protocol, lockups read over Electrum. +swap-common = { git = "https://github.com/coreyphillips/pubky-swap", rev = "8686702" } +iroh = "=1.2.0" +electrum-client = { version = "0.25", default-features = false, features = ["proxy", "use-rustls-ring"] } # Bluetooth (for Android JNI initialization) # btleplug is also pulled in transitively by trezor-connect-rs diff --git a/Package.swift b/Package.swift index b405195..76d6f5b 100644 --- a/Package.swift +++ b/Package.swift @@ -4,8 +4,8 @@ import PackageDescription import Foundation -let tag = "v0.8.0-arkade.2" -let checksum = "2c69c91efc237616ad7c7610af2177c1d41a44da30ee8b0e3ab6e1c3a344403d" +let tag = "v0.8.0-routes.1" +let checksum = "39589fb9d15069ea0a2e26b597f4438dd1e0b7bc86aca24cd924bca3a30bf464" let url = "https://github.com/synonymdev/bitkit-core/releases/download/\(tag)/BitkitCore.xcframework.zip" let localBinary = ProcessInfo.processInfo.environment["BITKIT_CORE_LOCAL"] == "1" @@ -27,7 +27,9 @@ let package = Package( name: "BitkitCore", dependencies: ["BitkitCoreFFI"], path: "./bindings/ios", - sources: ["bitkitcore.swift"] + sources: ["bitkitcore.swift"], + // iroh reads network interfaces through Network.framework. + linkerSettings: [.linkedFramework("Network")] ), localBinary ? .binaryTarget( diff --git a/bindings/android/gradle.properties b/bindings/android/gradle.properties index cd24a7f..e8ffad0 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.8.0-arkade.2 +version=0.8.0-routes.1 diff --git a/bindings/ios/bitkitcore.swift b/bindings/ios/bitkitcore.swift index c64b1a9..44a558c 100644 --- a/bindings/ios/bitkitcore.swift +++ b/bindings/ios/bitkitcore.swift @@ -13047,6 +13047,222 @@ public func FfiConverterTypePassportAccountExport_lower(_ value: PassportAccount } +public struct PaykitEndpoint { + public var methodId: String + public var value: String + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(methodId: String, value: String) { + self.methodId = methodId + self.value = value + } +} + +#if compiler(>=6) +extension PaykitEndpoint: Sendable {} +#endif + + +extension PaykitEndpoint: Equatable, Hashable { + public static func ==(lhs: PaykitEndpoint, rhs: PaykitEndpoint) -> Bool { + if lhs.methodId != rhs.methodId { + return false + } + if lhs.value != rhs.value { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(methodId) + hasher.combine(value) + } +} + +extension PaykitEndpoint: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePaykitEndpoint: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PaykitEndpoint { + return + try PaykitEndpoint( + methodId: FfiConverterString.read(from: &buf), + value: FfiConverterString.read(from: &buf) + ) + } + + public static func write(_ value: PaykitEndpoint, into buf: inout [UInt8]) { + FfiConverterString.write(value.methodId, into: &buf) + FfiConverterString.write(value.value, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePaykitEndpoint_lift(_ buf: RustBuffer) throws -> PaykitEndpoint { + return try FfiConverterTypePaykitEndpoint.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePaykitEndpoint_lower(_ value: PaykitEndpoint) -> RustBuffer { + return FfiConverterTypePaykitEndpoint.lower(value) +} + + +/** + * What the wallet knows when it pays a Paykit contact: the amount, the endpoints the contact + * published and what the wallet can spend on each rail. + */ +public struct PaykitRouteRequest { + public var amountSat: UInt64 + /** + * Payment Endpoint Identifiers paired with their values, as Paykit resolved them. + */ + public var contactEndpoints: [PaykitEndpoint] + public var lightningSpendableSat: UInt64 + public var onchainSpendableSat: UInt64 + /** + * Candidate swap providers as pubkys, usually the user's contacts. Each is asked for its + * offer; those that run no provider are skipped. + */ + public var providers: [String] + /** + * Fee rate for the wallet's own claim transaction. + */ + public var feeRateSatVb: UInt64 + /** + * Routes through services the wallet holds a balance on (Arkade, Spark), each already quoted + * by the app's engine for that service. They compete with the Pubky Swaps providers on fee. + */ + public var serviceLegs: [ServiceRouteLeg] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(amountSat: UInt64, + /** + * Payment Endpoint Identifiers paired with their values, as Paykit resolved them. + */contactEndpoints: [PaykitEndpoint], lightningSpendableSat: UInt64, onchainSpendableSat: UInt64, + /** + * Candidate swap providers as pubkys, usually the user's contacts. Each is asked for its + * offer; those that run no provider are skipped. + */providers: [String], + /** + * Fee rate for the wallet's own claim transaction. + */feeRateSatVb: UInt64, + /** + * Routes through services the wallet holds a balance on (Arkade, Spark), each already quoted + * by the app's engine for that service. They compete with the Pubky Swaps providers on fee. + */serviceLegs: [ServiceRouteLeg]) { + self.amountSat = amountSat + self.contactEndpoints = contactEndpoints + self.lightningSpendableSat = lightningSpendableSat + self.onchainSpendableSat = onchainSpendableSat + self.providers = providers + self.feeRateSatVb = feeRateSatVb + self.serviceLegs = serviceLegs + } +} + +#if compiler(>=6) +extension PaykitRouteRequest: Sendable {} +#endif + + +extension PaykitRouteRequest: Equatable, Hashable { + public static func ==(lhs: PaykitRouteRequest, rhs: PaykitRouteRequest) -> Bool { + if lhs.amountSat != rhs.amountSat { + return false + } + if lhs.contactEndpoints != rhs.contactEndpoints { + return false + } + if lhs.lightningSpendableSat != rhs.lightningSpendableSat { + return false + } + if lhs.onchainSpendableSat != rhs.onchainSpendableSat { + return false + } + if lhs.providers != rhs.providers { + return false + } + if lhs.feeRateSatVb != rhs.feeRateSatVb { + return false + } + if lhs.serviceLegs != rhs.serviceLegs { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(amountSat) + hasher.combine(contactEndpoints) + hasher.combine(lightningSpendableSat) + hasher.combine(onchainSpendableSat) + hasher.combine(providers) + hasher.combine(feeRateSatVb) + hasher.combine(serviceLegs) + } +} + +extension PaykitRouteRequest: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePaykitRouteRequest: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PaykitRouteRequest { + return + try PaykitRouteRequest( + amountSat: FfiConverterUInt64.read(from: &buf), + contactEndpoints: FfiConverterSequenceTypePaykitEndpoint.read(from: &buf), + lightningSpendableSat: FfiConverterUInt64.read(from: &buf), + onchainSpendableSat: FfiConverterUInt64.read(from: &buf), + providers: FfiConverterSequenceString.read(from: &buf), + feeRateSatVb: FfiConverterUInt64.read(from: &buf), + serviceLegs: FfiConverterSequenceTypeServiceRouteLeg.read(from: &buf) + ) + } + + public static func write(_ value: PaykitRouteRequest, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.amountSat, into: &buf) + FfiConverterSequenceTypePaykitEndpoint.write(value.contactEndpoints, into: &buf) + FfiConverterUInt64.write(value.lightningSpendableSat, into: &buf) + FfiConverterUInt64.write(value.onchainSpendableSat, into: &buf) + FfiConverterSequenceString.write(value.providers, into: &buf) + FfiConverterUInt64.write(value.feeRateSatVb, into: &buf) + FfiConverterSequenceTypeServiceRouteLeg.write(value.serviceLegs, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePaykitRouteRequest_lift(_ buf: RustBuffer) throws -> PaykitRouteRequest { + return try FfiConverterTypePaykitRouteRequest.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePaykitRouteRequest_lower(_ value: PaykitRouteRequest) -> RustBuffer { + return FfiConverterTypePaykitRouteRequest.lower(value) +} + + public struct PreActivityMetadata { public var walletId: String public var paymentId: String @@ -13553,70 +13769,53 @@ public func FfiConverterTypePubkyProfileLink_lower(_ value: PubkyProfileLink) -> /** - * Result of creating a reverse swap (Lightning -> onchain). - * - * The caller pays `invoice` from its Lightning node; once Boltz locks funds at - * `lockup_address`, the module claims them to the provided onchain address. + * A committed swap: the hold invoice the wallet pays to start it. */ -public struct ReverseSwapResponse { - public var id: String - /** - * Hold invoice the caller must pay via Lightning. - */ +public struct PubkySwapRoutePayment { + public var swapId: String public var invoice: String - /** - * Address Boltz locks the onchain funds to. - */ - public var lockupAddress: String - /** - * Amount in satoshis that will be received onchain (after Boltz fees). - */ - public var onchainAmountSat: UInt64 - /** - * Onchain timeout height for the swap. - */ - public var timeoutBlockHeight: UInt64 + public var debitSat: UInt64 + public var deliveredSat: UInt64 + public var destinationAddress: String + public var htlcAddress: String + public var timeoutBlockHeight: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, - /** - * Hold invoice the caller must pay via Lightning. - */invoice: String, - /** - * Address Boltz locks the onchain funds to. - */lockupAddress: String, - /** - * Amount in satoshis that will be received onchain (after Boltz fees). - */onchainAmountSat: UInt64, - /** - * Onchain timeout height for the swap. - */timeoutBlockHeight: UInt64) { - self.id = id + public init(swapId: String, invoice: String, debitSat: UInt64, deliveredSat: UInt64, destinationAddress: String, htlcAddress: String, timeoutBlockHeight: UInt32) { + self.swapId = swapId self.invoice = invoice - self.lockupAddress = lockupAddress - self.onchainAmountSat = onchainAmountSat + self.debitSat = debitSat + self.deliveredSat = deliveredSat + self.destinationAddress = destinationAddress + self.htlcAddress = htlcAddress self.timeoutBlockHeight = timeoutBlockHeight } } #if compiler(>=6) -extension ReverseSwapResponse: Sendable {} +extension PubkySwapRoutePayment: Sendable {} #endif -extension ReverseSwapResponse: Equatable, Hashable { - public static func ==(lhs: ReverseSwapResponse, rhs: ReverseSwapResponse) -> Bool { - if lhs.id != rhs.id { +extension PubkySwapRoutePayment: Equatable, Hashable { + public static func ==(lhs: PubkySwapRoutePayment, rhs: PubkySwapRoutePayment) -> Bool { + if lhs.swapId != rhs.swapId { return false } if lhs.invoice != rhs.invoice { return false } - if lhs.lockupAddress != rhs.lockupAddress { + if lhs.debitSat != rhs.debitSat { return false } - if lhs.onchainAmountSat != rhs.onchainAmountSat { + if lhs.deliveredSat != rhs.deliveredSat { + return false + } + if lhs.destinationAddress != rhs.destinationAddress { + return false + } + if lhs.htlcAddress != rhs.htlcAddress { return false } if lhs.timeoutBlockHeight != rhs.timeoutBlockHeight { @@ -13626,39 +13825,45 @@ extension ReverseSwapResponse: Equatable, Hashable { } public func hash(into hasher: inout Hasher) { - hasher.combine(id) + hasher.combine(swapId) hasher.combine(invoice) - hasher.combine(lockupAddress) - hasher.combine(onchainAmountSat) + hasher.combine(debitSat) + hasher.combine(deliveredSat) + hasher.combine(destinationAddress) + hasher.combine(htlcAddress) hasher.combine(timeoutBlockHeight) } } -extension ReverseSwapResponse: Codable {} +extension PubkySwapRoutePayment: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeReverseSwapResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReverseSwapResponse { +public struct FfiConverterTypePubkySwapRoutePayment: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkySwapRoutePayment { return - try ReverseSwapResponse( - id: FfiConverterString.read(from: &buf), + try PubkySwapRoutePayment( + swapId: FfiConverterString.read(from: &buf), invoice: FfiConverterString.read(from: &buf), - lockupAddress: FfiConverterString.read(from: &buf), - onchainAmountSat: FfiConverterUInt64.read(from: &buf), - timeoutBlockHeight: FfiConverterUInt64.read(from: &buf) + debitSat: FfiConverterUInt64.read(from: &buf), + deliveredSat: FfiConverterUInt64.read(from: &buf), + destinationAddress: FfiConverterString.read(from: &buf), + htlcAddress: FfiConverterString.read(from: &buf), + timeoutBlockHeight: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: ReverseSwapResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) + public static func write(_ value: PubkySwapRoutePayment, into buf: inout [UInt8]) { + FfiConverterString.write(value.swapId, into: &buf) FfiConverterString.write(value.invoice, into: &buf) - FfiConverterString.write(value.lockupAddress, into: &buf) - FfiConverterUInt64.write(value.onchainAmountSat, into: &buf) - FfiConverterUInt64.write(value.timeoutBlockHeight, into: &buf) + FfiConverterUInt64.write(value.debitSat, into: &buf) + FfiConverterUInt64.write(value.deliveredSat, into: &buf) + FfiConverterString.write(value.destinationAddress, into: &buf) + FfiConverterString.write(value.htlcAddress, into: &buf) + FfiConverterUInt32.write(value.timeoutBlockHeight, into: &buf) } } @@ -13666,128 +13871,198 @@ public struct FfiConverterTypeReverseSwapResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeReverseSwapResponse_lift(_ buf: RustBuffer) throws -> ReverseSwapResponse { - return try FfiConverterTypeReverseSwapResponse.lift(buf) +public func FfiConverterTypePubkySwapRoutePayment_lift(_ buf: RustBuffer) throws -> PubkySwapRoutePayment { + return try FfiConverterTypePubkySwapRoutePayment.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeReverseSwapResponse_lower(_ value: ReverseSwapResponse) -> RustBuffer { - return FfiConverterTypeReverseSwapResponse.lower(value) +public func FfiConverterTypePubkySwapRoutePayment_lower(_ value: PubkySwapRoutePayment) -> RustBuffer { + return FfiConverterTypePubkySwapRoutePayment.lower(value) } /** - * Result from querying a single Bitcoin address. + * A firm `swap/1` quote for one route, with everything the review screen shows. */ -public struct SingleAddressInfoResult { +public struct PubkySwapRouteQuote { + public var providerPubky: String + public var quoteId: String /** - * The queried address + * The contact endpoint the swap delivers to. */ - public var address: String + public var endpoint: PaykitEndpoint /** - * Total confirmed balance in satoshis + * What the contact receives. */ - public var balance: UInt64 + public var deliveredSat: UInt64 /** - * UTXOs for this address + * What the provider locks on chain: the delivered amount plus the wallet's claim fee. */ - public var utxos: [AccountUtxo] + public var lockSat: UInt64 /** - * Number of transactions involving this address + * What the wallet pays over Lightning. */ - public var transfers: UInt32 + public var debitSat: UInt64 + public var serviceFeeSat: UInt64 + public var providerOnchainFeeSat: UInt64 + public var claimFeeSat: UInt64 /** - * Current blockchain tip height + * `debit_sat - delivered_sat`. */ - public var blockHeight: UInt32 + public var totalFeeSat: UInt64 + public var atomicity: String + public var validUntilUnix: UInt64 + /** + * How many providers were asked for a quote. + */ + public var providersQuoted: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. - public init( + public init(providerPubky: String, quoteId: String, /** - * The queried address - */address: String, + * The contact endpoint the swap delivers to. + */endpoint: PaykitEndpoint, /** - * Total confirmed balance in satoshis - */balance: UInt64, + * What the contact receives. + */deliveredSat: UInt64, /** - * UTXOs for this address - */utxos: [AccountUtxo], + * What the provider locks on chain: the delivered amount plus the wallet's claim fee. + */lockSat: UInt64, /** - * Number of transactions involving this address - */transfers: UInt32, + * What the wallet pays over Lightning. + */debitSat: UInt64, serviceFeeSat: UInt64, providerOnchainFeeSat: UInt64, claimFeeSat: UInt64, /** - * Current blockchain tip height - */blockHeight: UInt32) { - self.address = address - self.balance = balance - self.utxos = utxos - self.transfers = transfers - self.blockHeight = blockHeight + * `debit_sat - delivered_sat`. + */totalFeeSat: UInt64, atomicity: String, validUntilUnix: UInt64, + /** + * How many providers were asked for a quote. + */providersQuoted: UInt32) { + self.providerPubky = providerPubky + self.quoteId = quoteId + self.endpoint = endpoint + self.deliveredSat = deliveredSat + self.lockSat = lockSat + self.debitSat = debitSat + self.serviceFeeSat = serviceFeeSat + self.providerOnchainFeeSat = providerOnchainFeeSat + self.claimFeeSat = claimFeeSat + self.totalFeeSat = totalFeeSat + self.atomicity = atomicity + self.validUntilUnix = validUntilUnix + self.providersQuoted = providersQuoted } } #if compiler(>=6) -extension SingleAddressInfoResult: Sendable {} +extension PubkySwapRouteQuote: Sendable {} #endif -extension SingleAddressInfoResult: Equatable, Hashable { - public static func ==(lhs: SingleAddressInfoResult, rhs: SingleAddressInfoResult) -> Bool { - if lhs.address != rhs.address { +extension PubkySwapRouteQuote: Equatable, Hashable { + public static func ==(lhs: PubkySwapRouteQuote, rhs: PubkySwapRouteQuote) -> Bool { + if lhs.providerPubky != rhs.providerPubky { return false } - if lhs.balance != rhs.balance { + if lhs.quoteId != rhs.quoteId { return false } - if lhs.utxos != rhs.utxos { + if lhs.endpoint != rhs.endpoint { return false } - if lhs.transfers != rhs.transfers { + if lhs.deliveredSat != rhs.deliveredSat { return false } - if lhs.blockHeight != rhs.blockHeight { + if lhs.lockSat != rhs.lockSat { return false } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(balance) - hasher.combine(utxos) - hasher.combine(transfers) - hasher.combine(blockHeight) - } -} - -extension SingleAddressInfoResult: Codable {} - + if lhs.debitSat != rhs.debitSat { + return false + } + if lhs.serviceFeeSat != rhs.serviceFeeSat { + return false + } + if lhs.providerOnchainFeeSat != rhs.providerOnchainFeeSat { + return false + } + if lhs.claimFeeSat != rhs.claimFeeSat { + return false + } + if lhs.totalFeeSat != rhs.totalFeeSat { + return false + } + if lhs.atomicity != rhs.atomicity { + return false + } + if lhs.validUntilUnix != rhs.validUntilUnix { + return false + } + if lhs.providersQuoted != rhs.providersQuoted { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(providerPubky) + hasher.combine(quoteId) + hasher.combine(endpoint) + hasher.combine(deliveredSat) + hasher.combine(lockSat) + hasher.combine(debitSat) + hasher.combine(serviceFeeSat) + hasher.combine(providerOnchainFeeSat) + hasher.combine(claimFeeSat) + hasher.combine(totalFeeSat) + hasher.combine(atomicity) + hasher.combine(validUntilUnix) + hasher.combine(providersQuoted) + } +} + +extension PubkySwapRouteQuote: Codable {} + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSingleAddressInfoResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SingleAddressInfoResult { +public struct FfiConverterTypePubkySwapRouteQuote: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkySwapRouteQuote { return - try SingleAddressInfoResult( - address: FfiConverterString.read(from: &buf), - balance: FfiConverterUInt64.read(from: &buf), - utxos: FfiConverterSequenceTypeAccountUtxo.read(from: &buf), - transfers: FfiConverterUInt32.read(from: &buf), - blockHeight: FfiConverterUInt32.read(from: &buf) + try PubkySwapRouteQuote( + providerPubky: FfiConverterString.read(from: &buf), + quoteId: FfiConverterString.read(from: &buf), + endpoint: FfiConverterTypePaykitEndpoint.read(from: &buf), + deliveredSat: FfiConverterUInt64.read(from: &buf), + lockSat: FfiConverterUInt64.read(from: &buf), + debitSat: FfiConverterUInt64.read(from: &buf), + serviceFeeSat: FfiConverterUInt64.read(from: &buf), + providerOnchainFeeSat: FfiConverterUInt64.read(from: &buf), + claimFeeSat: FfiConverterUInt64.read(from: &buf), + totalFeeSat: FfiConverterUInt64.read(from: &buf), + atomicity: FfiConverterString.read(from: &buf), + validUntilUnix: FfiConverterUInt64.read(from: &buf), + providersQuoted: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: SingleAddressInfoResult, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterUInt64.write(value.balance, into: &buf) - FfiConverterSequenceTypeAccountUtxo.write(value.utxos, into: &buf) - FfiConverterUInt32.write(value.transfers, into: &buf) - FfiConverterUInt32.write(value.blockHeight, into: &buf) + public static func write(_ value: PubkySwapRouteQuote, into buf: inout [UInt8]) { + FfiConverterString.write(value.providerPubky, into: &buf) + FfiConverterString.write(value.quoteId, into: &buf) + FfiConverterTypePaykitEndpoint.write(value.endpoint, into: &buf) + FfiConverterUInt64.write(value.deliveredSat, into: &buf) + FfiConverterUInt64.write(value.lockSat, into: &buf) + FfiConverterUInt64.write(value.debitSat, into: &buf) + FfiConverterUInt64.write(value.serviceFeeSat, into: &buf) + FfiConverterUInt64.write(value.providerOnchainFeeSat, into: &buf) + FfiConverterUInt64.write(value.claimFeeSat, into: &buf) + FfiConverterUInt64.write(value.totalFeeSat, into: &buf) + FfiConverterString.write(value.atomicity, into: &buf) + FfiConverterUInt64.write(value.validUntilUnix, into: &buf) + FfiConverterUInt32.write(value.providersQuoted, into: &buf) } } @@ -13795,44 +14070,136 @@ public struct FfiConverterTypeSingleAddressInfoResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSingleAddressInfoResult_lift(_ buf: RustBuffer) throws -> SingleAddressInfoResult { - return try FfiConverterTypeSingleAddressInfoResult.lift(buf) +public func FfiConverterTypePubkySwapRouteQuote_lift(_ buf: RustBuffer) throws -> PubkySwapRouteQuote { + return try FfiConverterTypePubkySwapRouteQuote.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSingleAddressInfoResult_lower(_ value: SingleAddressInfoResult) -> RustBuffer { - return FfiConverterTypeSingleAddressInfoResult.lower(value) +public func FfiConverterTypePubkySwapRouteQuote_lower(_ value: PubkySwapRouteQuote) -> RustBuffer { + return FfiConverterTypePubkySwapRouteQuote.lower(value) +} + + +public struct PubkySwapRouteStatus { + public var swapId: String + public var state: PubkySwapRouteState + public var providerPubky: String + public var deliveredSat: UInt64 + public var destinationAddress: String + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(swapId: String, state: PubkySwapRouteState, providerPubky: String, deliveredSat: UInt64, destinationAddress: String) { + self.swapId = swapId + self.state = state + self.providerPubky = providerPubky + self.deliveredSat = deliveredSat + self.destinationAddress = destinationAddress + } +} + +#if compiler(>=6) +extension PubkySwapRouteStatus: Sendable {} +#endif + + +extension PubkySwapRouteStatus: Equatable, Hashable { + public static func ==(lhs: PubkySwapRouteStatus, rhs: PubkySwapRouteStatus) -> Bool { + if lhs.swapId != rhs.swapId { + return false + } + if lhs.state != rhs.state { + return false + } + if lhs.providerPubky != rhs.providerPubky { + return false + } + if lhs.deliveredSat != rhs.deliveredSat { + return false + } + if lhs.destinationAddress != rhs.destinationAddress { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(swapId) + hasher.combine(state) + hasher.combine(providerPubky) + hasher.combine(deliveredSat) + hasher.combine(destinationAddress) + } +} + +extension PubkySwapRouteStatus: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePubkySwapRouteStatus: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkySwapRouteStatus { + return + try PubkySwapRouteStatus( + swapId: FfiConverterString.read(from: &buf), + state: FfiConverterTypePubkySwapRouteState.read(from: &buf), + providerPubky: FfiConverterString.read(from: &buf), + deliveredSat: FfiConverterUInt64.read(from: &buf), + destinationAddress: FfiConverterString.read(from: &buf) + ) + } + + public static func write(_ value: PubkySwapRouteStatus, into buf: inout [UInt8]) { + FfiConverterString.write(value.swapId, into: &buf) + FfiConverterTypePubkySwapRouteState.write(value.state, into: &buf) + FfiConverterString.write(value.providerPubky, into: &buf) + FfiConverterUInt64.write(value.deliveredSat, into: &buf) + FfiConverterString.write(value.destinationAddress, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePubkySwapRouteStatus_lift(_ buf: RustBuffer) throws -> PubkySwapRouteStatus { + return try FfiConverterTypePubkySwapRouteStatus.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePubkySwapRouteStatus_lower(_ value: PubkySwapRouteStatus) -> RustBuffer { + return FfiConverterTypePubkySwapRouteStatus.lower(value) } /** - * Result of creating a submarine swap (onchain -> Lightning). + * Result of creating a reverse swap (Lightning -> onchain). * - * The caller funds `address` with `expected_amount_sat` from its onchain - * wallet; Boltz then pays the Lightning invoice supplied at creation. + * The caller pays `invoice` from its Lightning node; once Boltz locks funds at + * `lockup_address`, the module claims them to the provided onchain address. */ -public struct SubmarineSwapResponse { +public struct ReverseSwapResponse { public var id: String /** - * Onchain lockup address to send funds to. - */ - public var address: String - /** - * BIP21 URI for the lockup payment. + * Hold invoice the caller must pay via Lightning. */ - public var bip21: String + public var invoice: String /** - * Exact amount in satoshis the caller must send to `address`. + * Address Boltz locks the onchain funds to. */ - public var expectedAmountSat: UInt64 + public var lockupAddress: String /** - * Whether Boltz will accept a zero-conf lockup. + * Amount in satoshis that will be received onchain (after Boltz fees). */ - public var acceptZeroConf: Bool + public var onchainAmountSat: UInt64 /** - * Onchain timeout height after which a refund is possible. + * Onchain timeout height for the swap. */ public var timeoutBlockHeight: UInt64 @@ -13840,49 +14207,42 @@ public struct SubmarineSwapResponse { // declare one manually. public init(id: String, /** - * Onchain lockup address to send funds to. - */address: String, - /** - * BIP21 URI for the lockup payment. - */bip21: String, + * Hold invoice the caller must pay via Lightning. + */invoice: String, /** - * Exact amount in satoshis the caller must send to `address`. - */expectedAmountSat: UInt64, + * Address Boltz locks the onchain funds to. + */lockupAddress: String, /** - * Whether Boltz will accept a zero-conf lockup. - */acceptZeroConf: Bool, + * Amount in satoshis that will be received onchain (after Boltz fees). + */onchainAmountSat: UInt64, /** - * Onchain timeout height after which a refund is possible. + * Onchain timeout height for the swap. */timeoutBlockHeight: UInt64) { self.id = id - self.address = address - self.bip21 = bip21 - self.expectedAmountSat = expectedAmountSat - self.acceptZeroConf = acceptZeroConf + self.invoice = invoice + self.lockupAddress = lockupAddress + self.onchainAmountSat = onchainAmountSat self.timeoutBlockHeight = timeoutBlockHeight } } #if compiler(>=6) -extension SubmarineSwapResponse: Sendable {} +extension ReverseSwapResponse: Sendable {} #endif -extension SubmarineSwapResponse: Equatable, Hashable { - public static func ==(lhs: SubmarineSwapResponse, rhs: SubmarineSwapResponse) -> Bool { +extension ReverseSwapResponse: Equatable, Hashable { + public static func ==(lhs: ReverseSwapResponse, rhs: ReverseSwapResponse) -> Bool { if lhs.id != rhs.id { return false } - if lhs.address != rhs.address { - return false - } - if lhs.bip21 != rhs.bip21 { + if lhs.invoice != rhs.invoice { return false } - if lhs.expectedAmountSat != rhs.expectedAmountSat { + if lhs.lockupAddress != rhs.lockupAddress { return false } - if lhs.acceptZeroConf != rhs.acceptZeroConf { + if lhs.onchainAmountSat != rhs.onchainAmountSat { return false } if lhs.timeoutBlockHeight != rhs.timeoutBlockHeight { @@ -13893,40 +14253,37 @@ extension SubmarineSwapResponse: Equatable, Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(id) - hasher.combine(address) - hasher.combine(bip21) - hasher.combine(expectedAmountSat) - hasher.combine(acceptZeroConf) + hasher.combine(invoice) + hasher.combine(lockupAddress) + hasher.combine(onchainAmountSat) hasher.combine(timeoutBlockHeight) } } -extension SubmarineSwapResponse: Codable {} +extension ReverseSwapResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSubmarineSwapResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SubmarineSwapResponse { +public struct FfiConverterTypeReverseSwapResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReverseSwapResponse { return - try SubmarineSwapResponse( + try ReverseSwapResponse( id: FfiConverterString.read(from: &buf), - address: FfiConverterString.read(from: &buf), - bip21: FfiConverterString.read(from: &buf), - expectedAmountSat: FfiConverterUInt64.read(from: &buf), - acceptZeroConf: FfiConverterBool.read(from: &buf), + invoice: FfiConverterString.read(from: &buf), + lockupAddress: FfiConverterString.read(from: &buf), + onchainAmountSat: FfiConverterUInt64.read(from: &buf), timeoutBlockHeight: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: SubmarineSwapResponse, into buf: inout [UInt8]) { + public static func write(_ value: ReverseSwapResponse, into buf: inout [UInt8]) { FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.bip21, into: &buf) - FfiConverterUInt64.write(value.expectedAmountSat, into: &buf) - FfiConverterBool.write(value.acceptZeroConf, into: &buf) + FfiConverterString.write(value.invoice, into: &buf) + FfiConverterString.write(value.lockupAddress, into: &buf) + FfiConverterUInt64.write(value.onchainAmountSat, into: &buf) FfiConverterUInt64.write(value.timeoutBlockHeight, into: &buf) } } @@ -13935,122 +14292,145 @@ public struct FfiConverterTypeSubmarineSwapResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSubmarineSwapResponse_lift(_ buf: RustBuffer) throws -> SubmarineSwapResponse { - return try FfiConverterTypeSubmarineSwapResponse.lift(buf) +public func FfiConverterTypeReverseSwapResponse_lift(_ buf: RustBuffer) throws -> ReverseSwapResponse { + return try FfiConverterTypeReverseSwapResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSubmarineSwapResponse_lower(_ value: SubmarineSwapResponse) -> RustBuffer { - return FfiConverterTypeSubmarineSwapResponse.lower(value) +public func FfiConverterTypeReverseSwapResponse_lower(_ value: ReverseSwapResponse) -> RustBuffer { + return FfiConverterTypeReverseSwapResponse.lower(value) } /** - * A hardware-wallet model Bitkit supports. + * A one-leg route through a service the wallet holds a balance on, such as an Arkade offboard + * or a Spark withdrawal to the contact's on-chain address. The app quotes it and runs it. */ -public struct SupportedHardwareWallet { - public var vendor: HardwareWalletVendor +public struct ServiceRouteLeg { /** - * Human-readable manufacturer name, e.g. "Foundation". + * `arkade` or `spark`. */ - public var vendorName: String + public var service: String /** - * Stable model identifier that applications can map to bundled assets. + * The contact endpoint the service delivers to. It must be one the contact published. */ - public var model: String + public var endpoint: PaykitEndpoint /** - * Full user-facing name. + * What the contact receives. */ - public var displayName: String + public var deliveredSat: UInt64 /** - * Transports over which the application can interact with this model. + * What the wallet's balance on the service is debited. */ - public var transports: [HardwareWalletTransport] + public var debitSat: UInt64 + /** + * Who the wallet trusts to complete the leg: `operator` for an Arkade batch, `trusted` for + * Spark's operators. Pubky Swaps legs are `hash`. + */ + public var atomicity: String + /** + * When the quote stops holding, or 0 when it does not expire. + */ + public var validUntilUnix: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(vendor: HardwareWalletVendor, + public init( /** - * Human-readable manufacturer name, e.g. "Foundation". - */vendorName: String, + * `arkade` or `spark`. + */service: String, /** - * Stable model identifier that applications can map to bundled assets. - */model: String, + * The contact endpoint the service delivers to. It must be one the contact published. + */endpoint: PaykitEndpoint, /** - * Full user-facing name. - */displayName: String, + * What the contact receives. + */deliveredSat: UInt64, /** - * Transports over which the application can interact with this model. - */transports: [HardwareWalletTransport]) { - self.vendor = vendor - self.vendorName = vendorName - self.model = model - self.displayName = displayName - self.transports = transports + * What the wallet's balance on the service is debited. + */debitSat: UInt64, + /** + * Who the wallet trusts to complete the leg: `operator` for an Arkade batch, `trusted` for + * Spark's operators. Pubky Swaps legs are `hash`. + */atomicity: String, + /** + * When the quote stops holding, or 0 when it does not expire. + */validUntilUnix: UInt64) { + self.service = service + self.endpoint = endpoint + self.deliveredSat = deliveredSat + self.debitSat = debitSat + self.atomicity = atomicity + self.validUntilUnix = validUntilUnix } } #if compiler(>=6) -extension SupportedHardwareWallet: Sendable {} +extension ServiceRouteLeg: Sendable {} #endif -extension SupportedHardwareWallet: Equatable, Hashable { - public static func ==(lhs: SupportedHardwareWallet, rhs: SupportedHardwareWallet) -> Bool { - if lhs.vendor != rhs.vendor { +extension ServiceRouteLeg: Equatable, Hashable { + public static func ==(lhs: ServiceRouteLeg, rhs: ServiceRouteLeg) -> Bool { + if lhs.service != rhs.service { return false } - if lhs.vendorName != rhs.vendorName { + if lhs.endpoint != rhs.endpoint { return false } - if lhs.model != rhs.model { + if lhs.deliveredSat != rhs.deliveredSat { return false } - if lhs.displayName != rhs.displayName { + if lhs.debitSat != rhs.debitSat { return false } - if lhs.transports != rhs.transports { + if lhs.atomicity != rhs.atomicity { + return false + } + if lhs.validUntilUnix != rhs.validUntilUnix { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(vendor) - hasher.combine(vendorName) - hasher.combine(model) - hasher.combine(displayName) - hasher.combine(transports) + hasher.combine(service) + hasher.combine(endpoint) + hasher.combine(deliveredSat) + hasher.combine(debitSat) + hasher.combine(atomicity) + hasher.combine(validUntilUnix) } } -extension SupportedHardwareWallet: Codable {} +extension ServiceRouteLeg: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSupportedHardwareWallet: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SupportedHardwareWallet { +public struct FfiConverterTypeServiceRouteLeg: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ServiceRouteLeg { return - try SupportedHardwareWallet( - vendor: FfiConverterTypeHardwareWalletVendor.read(from: &buf), - vendorName: FfiConverterString.read(from: &buf), - model: FfiConverterString.read(from: &buf), - displayName: FfiConverterString.read(from: &buf), - transports: FfiConverterSequenceTypeHardwareWalletTransport.read(from: &buf) + try ServiceRouteLeg( + service: FfiConverterString.read(from: &buf), + endpoint: FfiConverterTypePaykitEndpoint.read(from: &buf), + deliveredSat: FfiConverterUInt64.read(from: &buf), + debitSat: FfiConverterUInt64.read(from: &buf), + atomicity: FfiConverterString.read(from: &buf), + validUntilUnix: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: SupportedHardwareWallet, into buf: inout [UInt8]) { - FfiConverterTypeHardwareWalletVendor.write(value.vendor, into: &buf) - FfiConverterString.write(value.vendorName, into: &buf) - FfiConverterString.write(value.model, into: &buf) - FfiConverterString.write(value.displayName, into: &buf) - FfiConverterSequenceTypeHardwareWalletTransport.write(value.transports, into: &buf) + public static func write(_ value: ServiceRouteLeg, into buf: inout [UInt8]) { + FfiConverterString.write(value.service, into: &buf) + FfiConverterTypePaykitEndpoint.write(value.endpoint, into: &buf) + FfiConverterUInt64.write(value.deliveredSat, into: &buf) + FfiConverterUInt64.write(value.debitSat, into: &buf) + FfiConverterString.write(value.atomicity, into: &buf) + FfiConverterUInt64.write(value.validUntilUnix, into: &buf) } } @@ -14058,111 +14438,128 @@ public struct FfiConverterTypeSupportedHardwareWallet: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSupportedHardwareWallet_lift(_ buf: RustBuffer) throws -> SupportedHardwareWallet { - return try FfiConverterTypeSupportedHardwareWallet.lift(buf) +public func FfiConverterTypeServiceRouteLeg_lift(_ buf: RustBuffer) throws -> ServiceRouteLeg { + return try FfiConverterTypeServiceRouteLeg.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSupportedHardwareWallet_lower(_ value: SupportedHardwareWallet) -> RustBuffer { - return FfiConverterTypeSupportedHardwareWallet.lower(value) +public func FfiConverterTypeServiceRouteLeg_lower(_ value: ServiceRouteLeg) -> RustBuffer { + return FfiConverterTypeServiceRouteLeg.lower(value) } -public struct SweepResult { +/** + * Result from querying a single Bitcoin address. + */ +public struct SingleAddressInfoResult { /** - * The transaction ID of the sweep transaction + * The queried address */ - public var txid: String + public var address: String /** - * The total amount swept (in satoshis) + * Total confirmed balance in satoshis */ - public var amountSwept: UInt64 + public var balance: UInt64 /** - * The fee paid (in satoshis) + * UTXOs for this address */ - public var feePaid: UInt64 + public var utxos: [AccountUtxo] /** - * The number of UTXOs swept + * Number of transactions involving this address */ - public var utxosSwept: UInt32 + public var transfers: UInt32 + /** + * Current blockchain tip height + */ + public var blockHeight: UInt32 // 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 queried address + */address: String, /** - * The total amount swept (in satoshis) - */amountSwept: UInt64, + * Total confirmed balance in satoshis + */balance: UInt64, /** - * The fee paid (in satoshis) - */feePaid: UInt64, + * UTXOs for this address + */utxos: [AccountUtxo], /** - * The number of UTXOs swept - */utxosSwept: UInt32) { - self.txid = txid - self.amountSwept = amountSwept - self.feePaid = feePaid - self.utxosSwept = utxosSwept + * Number of transactions involving this address + */transfers: UInt32, + /** + * Current blockchain tip height + */blockHeight: UInt32) { + self.address = address + self.balance = balance + self.utxos = utxos + self.transfers = transfers + self.blockHeight = blockHeight } } #if compiler(>=6) -extension SweepResult: Sendable {} +extension SingleAddressInfoResult: Sendable {} #endif -extension SweepResult: Equatable, Hashable { - public static func ==(lhs: SweepResult, rhs: SweepResult) -> Bool { - if lhs.txid != rhs.txid { +extension SingleAddressInfoResult: Equatable, Hashable { + public static func ==(lhs: SingleAddressInfoResult, rhs: SingleAddressInfoResult) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.amountSwept != rhs.amountSwept { + if lhs.balance != rhs.balance { return false } - if lhs.feePaid != rhs.feePaid { + if lhs.utxos != rhs.utxos { return false } - if lhs.utxosSwept != rhs.utxosSwept { + if lhs.transfers != rhs.transfers { + return false + } + if lhs.blockHeight != rhs.blockHeight { 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(address) + hasher.combine(balance) + hasher.combine(utxos) + hasher.combine(transfers) + hasher.combine(blockHeight) } } -extension SweepResult: Codable {} +extension SingleAddressInfoResult: 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 FfiConverterTypeSingleAddressInfoResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SingleAddressInfoResult { return - try SweepResult( - txid: FfiConverterString.read(from: &buf), - amountSwept: FfiConverterUInt64.read(from: &buf), - feePaid: FfiConverterUInt64.read(from: &buf), - utxosSwept: FfiConverterUInt32.read(from: &buf) + try SingleAddressInfoResult( + address: FfiConverterString.read(from: &buf), + balance: FfiConverterUInt64.read(from: &buf), + utxos: FfiConverterSequenceTypeAccountUtxo.read(from: &buf), + transfers: FfiConverterUInt32.read(from: &buf), + blockHeight: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: 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: SingleAddressInfoResult, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterUInt64.write(value.balance, into: &buf) + FfiConverterSequenceTypeAccountUtxo.write(value.utxos, into: &buf) + FfiConverterUInt32.write(value.transfers, into: &buf) + FfiConverterUInt32.write(value.blockHeight, into: &buf) } } @@ -14170,153 +14567,139 @@ 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 FfiConverterTypeSingleAddressInfoResult_lift(_ buf: RustBuffer) throws -> SingleAddressInfoResult { + return try FfiConverterTypeSingleAddressInfoResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepResult_lower(_ value: SweepResult) -> RustBuffer { - return FfiConverterTypeSweepResult.lower(value) +public func FfiConverterTypeSingleAddressInfoResult_lower(_ value: SingleAddressInfoResult) -> RustBuffer { + return FfiConverterTypeSingleAddressInfoResult.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 +/** + * Result of creating a submarine swap (onchain -> Lightning). + * + * The caller funds `address` with `expected_amount_sat` from its onchain + * wallet; Boltz then pays the Lightning invoice supplied at creation. + */ +public struct SubmarineSwapResponse { + public var id: String /** - * The estimated fee for the transaction (in satoshis) + * Onchain lockup address to send funds to. */ - public var estimatedFee: UInt64 + public var address: String /** - * The estimated virtual size of the transaction (in vbytes) + * BIP21 URI for the lockup payment. */ - public var estimatedVsize: UInt64 + public var bip21: String /** - * The number of UTXOs that will be swept + * Exact amount in satoshis the caller must send to `address`. */ - public var utxosCount: UInt32 + public var expectedAmountSat: UInt64 /** - * The destination address + * Whether Boltz will accept a zero-conf lockup. */ - public var destinationAddress: String + public var acceptZeroConf: Bool /** - * The amount that will be sent to destination after fees (in satoshis) + * Onchain timeout height after which a refund is possible. */ - public var amountAfterFees: UInt64 + public var timeoutBlockHeight: UInt64 // 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, + public init(id: String, /** - * The estimated fee for the transaction (in satoshis) - */estimatedFee: UInt64, + * Onchain lockup address to send funds to. + */address: String, /** - * The estimated virtual size of the transaction (in vbytes) - */estimatedVsize: UInt64, + * BIP21 URI for the lockup payment. + */bip21: String, /** - * The number of UTXOs that will be swept - */utxosCount: UInt32, + * Exact amount in satoshis the caller must send to `address`. + */expectedAmountSat: UInt64, /** - * The destination address - */destinationAddress: String, + * Whether Boltz will accept a zero-conf lockup. + */acceptZeroConf: 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 + * Onchain timeout height after which a refund is possible. + */timeoutBlockHeight: UInt64) { + self.id = id + self.address = address + self.bip21 = bip21 + self.expectedAmountSat = expectedAmountSat + self.acceptZeroConf = acceptZeroConf + self.timeoutBlockHeight = timeoutBlockHeight } } #if compiler(>=6) -extension SweepTransactionPreview: Sendable {} +extension SubmarineSwapResponse: 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 { +extension SubmarineSwapResponse: Equatable, Hashable { + public static func ==(lhs: SubmarineSwapResponse, rhs: SubmarineSwapResponse) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.estimatedFee != rhs.estimatedFee { + if lhs.address != rhs.address { return false } - if lhs.estimatedVsize != rhs.estimatedVsize { + if lhs.bip21 != rhs.bip21 { return false } - if lhs.utxosCount != rhs.utxosCount { + if lhs.expectedAmountSat != rhs.expectedAmountSat { return false } - if lhs.destinationAddress != rhs.destinationAddress { + if lhs.acceptZeroConf != rhs.acceptZeroConf { return false } - if lhs.amountAfterFees != rhs.amountAfterFees { + if lhs.timeoutBlockHeight != rhs.timeoutBlockHeight { 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(id) + hasher.combine(address) + hasher.combine(bip21) + hasher.combine(expectedAmountSat) + hasher.combine(acceptZeroConf) + hasher.combine(timeoutBlockHeight) } } -extension SweepTransactionPreview: Codable {} +extension SubmarineSwapResponse: 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 FfiConverterTypeSubmarineSwapResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SubmarineSwapResponse { 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 SubmarineSwapResponse( + id: FfiConverterString.read(from: &buf), + address: FfiConverterString.read(from: &buf), + bip21: FfiConverterString.read(from: &buf), + expectedAmountSat: FfiConverterUInt64.read(from: &buf), + acceptZeroConf: FfiConverterBool.read(from: &buf), + timeoutBlockHeight: FfiConverterUInt64.read(from: &buf) ) } - 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: SubmarineSwapResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.address, into: &buf) + FfiConverterString.write(value.bip21, into: &buf) + FfiConverterUInt64.write(value.expectedAmountSat, into: &buf) + FfiConverterBool.write(value.acceptZeroConf, into: &buf) + FfiConverterUInt64.write(value.timeoutBlockHeight, into: &buf) } } @@ -14324,167 +14707,122 @@ 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 FfiConverterTypeSubmarineSwapResponse_lift(_ buf: RustBuffer) throws -> SubmarineSwapResponse { + return try FfiConverterTypeSubmarineSwapResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepTransactionPreview_lower(_ value: SweepTransactionPreview) -> RustBuffer { - return FfiConverterTypeSweepTransactionPreview.lower(value) +public func FfiConverterTypeSubmarineSwapResponse_lower(_ value: SubmarineSwapResponse) -> RustBuffer { + return FfiConverterTypeSubmarineSwapResponse.lower(value) } -public struct SweepableBalances { - /** - * Balance in legacy (P2PKH) addresses (in satoshis) - */ - public var legacyBalance: UInt64 - /** - * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) - */ - public var p2shBalance: UInt64 - /** - * Balance in Taproot (P2TR) addresses (in satoshis) - */ - public var taprootBalance: UInt64 - /** - * Total balance across all wallet types (in satoshis) - */ - public var totalBalance: UInt64 +/** + * A hardware-wallet model Bitkit supports. + */ +public struct SupportedHardwareWallet { + public var vendor: HardwareWalletVendor /** - * Number of UTXOs in legacy wallet + * Human-readable manufacturer name, e.g. "Foundation". */ - public var legacyUtxosCount: UInt32 + public var vendorName: String /** - * Number of UTXOs in P2SH-SegWit wallet + * Stable model identifier that applications can map to bundled assets. */ - public var p2shUtxosCount: UInt32 + public var model: String /** - * Number of UTXOs in Taproot wallet + * Full user-facing name. */ - public var taprootUtxosCount: UInt32 + public var displayName: String /** - * Total number of UTXOs across all wallet types + * Transports over which the application can interact with this model. */ - public var totalUtxosCount: UInt32 + public var transports: [HardwareWalletTransport] // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Balance in legacy (P2PKH) addresses (in satoshis) - */legacyBalance: UInt64, - /** - * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) - */p2shBalance: UInt64, - /** - * Balance in Taproot (P2TR) addresses (in satoshis) - */taprootBalance: UInt64, - /** - * Total balance across all wallet types (in satoshis) - */totalBalance: UInt64, + public init(vendor: HardwareWalletVendor, /** - * Number of UTXOs in legacy wallet - */legacyUtxosCount: UInt32, + * Human-readable manufacturer name, e.g. "Foundation". + */vendorName: String, /** - * Number of UTXOs in P2SH-SegWit wallet - */p2shUtxosCount: UInt32, + * Stable model identifier that applications can map to bundled assets. + */model: String, /** - * Number of UTXOs in Taproot wallet - */taprootUtxosCount: UInt32, + * Full user-facing name. + */displayName: 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 + * Transports over which the application can interact with this model. + */transports: [HardwareWalletTransport]) { + self.vendor = vendor + self.vendorName = vendorName + self.model = model + self.displayName = displayName + self.transports = transports } } #if compiler(>=6) -extension SweepableBalances: Sendable {} +extension SupportedHardwareWallet: Sendable {} #endif -extension SweepableBalances: Equatable, Hashable { - public static func ==(lhs: SweepableBalances, rhs: SweepableBalances) -> Bool { - if lhs.legacyBalance != rhs.legacyBalance { - return false - } - if lhs.p2shBalance != rhs.p2shBalance { - return false - } - if lhs.taprootBalance != rhs.taprootBalance { - return false - } - if lhs.totalBalance != rhs.totalBalance { +extension SupportedHardwareWallet: Equatable, Hashable { + public static func ==(lhs: SupportedHardwareWallet, rhs: SupportedHardwareWallet) -> Bool { + if lhs.vendor != rhs.vendor { return false } - if lhs.legacyUtxosCount != rhs.legacyUtxosCount { + if lhs.vendorName != rhs.vendorName { return false } - if lhs.p2shUtxosCount != rhs.p2shUtxosCount { + if lhs.model != rhs.model { return false } - if lhs.taprootUtxosCount != rhs.taprootUtxosCount { + if lhs.displayName != rhs.displayName { return false } - if lhs.totalUtxosCount != rhs.totalUtxosCount { + if lhs.transports != rhs.transports { 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(vendor) + hasher.combine(vendorName) + hasher.combine(model) + hasher.combine(displayName) + hasher.combine(transports) } } -extension SweepableBalances: Codable {} +extension SupportedHardwareWallet: 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 FfiConverterTypeSupportedHardwareWallet: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SupportedHardwareWallet { 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 SupportedHardwareWallet( + vendor: FfiConverterTypeHardwareWalletVendor.read(from: &buf), + vendorName: FfiConverterString.read(from: &buf), + model: FfiConverterString.read(from: &buf), + displayName: FfiConverterString.read(from: &buf), + transports: FfiConverterSequenceTypeHardwareWalletTransport.read(from: &buf) ) } - public static func write(_ value: 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: SupportedHardwareWallet, into buf: inout [UInt8]) { + FfiConverterTypeHardwareWalletVendor.write(value.vendor, into: &buf) + FfiConverterString.write(value.vendorName, into: &buf) + FfiConverterString.write(value.model, into: &buf) + FfiConverterString.write(value.displayName, into: &buf) + FfiConverterSequenceTypeHardwareWalletTransport.write(value.transports, into: &buf) } } @@ -14492,282 +14830,185 @@ 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 FfiConverterTypeSupportedHardwareWallet_lift(_ buf: RustBuffer) throws -> SupportedHardwareWallet { + return try FfiConverterTypeSupportedHardwareWallet.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepableBalances_lower(_ value: SweepableBalances) -> RustBuffer { - return FfiConverterTypeSweepableBalances.lower(value) +public func FfiConverterTypeSupportedHardwareWallet_lower(_ value: SupportedHardwareWallet) -> RustBuffer { + return FfiConverterTypeSupportedHardwareWallet.lower(value) } /** - * Full details for a single transaction, including raw inputs/outputs and size metrics. + * A `swap/1` edge from a provider's offer, in Paykit Capabilities terms: the payment endpoint + * the owner pays from, the endpoint the route delivers to, its bounds and its indicative fee. */ -public struct TransactionDetail { - /** - * Transaction ID (hex) - */ - public var txid: String - /** - * Amount received by the wallet (sats) - */ - public var received: UInt64 - /** - * Amount sent by the wallet (sats) — includes change sent back to self - */ - public var sent: UInt64 - /** - * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) - */ - public var net: Int64 - /** - * Display amount in sats (same semantics as HistoryTransaction.amount) - */ - public var amount: UInt64 - /** - * Transaction fee in sats (None if not available) - */ - public var fee: UInt64? - /** - * Transaction direction - */ - public var direction: TxDirection - /** - * Block height (None if unconfirmed/mempool) - */ - public var blockHeight: UInt32? - /** - * Block timestamp as unix epoch seconds (None if unconfirmed) - */ - public var timestamp: UInt64? - /** - * Number of confirmations (0 if unconfirmed) - */ - public var confirmations: UInt32 +public struct SwapRouteEdge { + public var providerPubky: String + public var offerId: String /** - * Transaction inputs + * `reverse` (Lightning to on-chain) or `submarine` (on-chain to Lightning). */ - public var inputs: [TxDetailInput] + public var direction: String /** - * Transaction outputs + * Payment Endpoint Identifier the owner pays with, such as `btc-lightning-bolt11`. */ - public var outputs: [TxDetailOutput] + public var fromEndpoint: String /** - * Serialized transaction size in bytes + * Payment Endpoint Identifier family the route delivers to, such as `btc-regtest-*`. */ - public var size: UInt32 + public var toEndpoint: String /** - * Virtual size in vbytes (ceil(weight / 4)) + * The minimum the provider enforces, not its configured floor. */ - public var vsize: UInt32 + public var minSat: UInt64 + public var maxSat: UInt64 + public var baseFeeSat: UInt64 + public var feePpm: UInt64 + public var onchainFeeSat: UInt64 /** - * Transaction weight in weight units + * Atomicity class of the edge. Pubky Swaps legs are always `hash`. */ - public var weight: UInt32 - /** - * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero - */ - public var feeRate: Double? + public var atomicity: String + public var fundWithinSecs: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Transaction ID (hex) - */txid: String, - /** - * Amount received by the wallet (sats) - */received: UInt64, - /** - * Amount sent by the wallet (sats) — includes change sent back to self - */sent: UInt64, - /** - * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) - */net: Int64, - /** - * Display amount in sats (same semantics as HistoryTransaction.amount) - */amount: UInt64, - /** - * Transaction fee in sats (None if not available) - */fee: UInt64?, - /** - * Transaction direction - */direction: TxDirection, - /** - * Block height (None if unconfirmed/mempool) - */blockHeight: UInt32?, - /** - * Block timestamp as unix epoch seconds (None if unconfirmed) - */timestamp: UInt64?, - /** - * Number of confirmations (0 if unconfirmed) - */confirmations: UInt32, - /** - * Transaction inputs - */inputs: [TxDetailInput], + public init(providerPubky: String, offerId: String, /** - * Transaction outputs - */outputs: [TxDetailOutput], + * `reverse` (Lightning to on-chain) or `submarine` (on-chain to Lightning). + */direction: String, /** - * Serialized transaction size in bytes - */size: UInt32, + * Payment Endpoint Identifier the owner pays with, such as `btc-lightning-bolt11`. + */fromEndpoint: String, /** - * Virtual size in vbytes (ceil(weight / 4)) - */vsize: UInt32, + * Payment Endpoint Identifier family the route delivers to, such as `btc-regtest-*`. + */toEndpoint: String, /** - * Transaction weight in weight units - */weight: UInt32, + * The minimum the provider enforces, not its configured floor. + */minSat: UInt64, maxSat: UInt64, baseFeeSat: UInt64, feePpm: UInt64, onchainFeeSat: UInt64, /** - * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero - */feeRate: Double?) { - self.txid = txid - self.received = received - self.sent = sent - self.net = net - self.amount = amount - self.fee = fee + * Atomicity class of the edge. Pubky Swaps legs are always `hash`. + */atomicity: String, fundWithinSecs: UInt64) { + self.providerPubky = providerPubky + self.offerId = offerId self.direction = direction - self.blockHeight = blockHeight - self.timestamp = timestamp - self.confirmations = confirmations - self.inputs = inputs - self.outputs = outputs - self.size = size - self.vsize = vsize - self.weight = weight - self.feeRate = feeRate + self.fromEndpoint = fromEndpoint + self.toEndpoint = toEndpoint + self.minSat = minSat + self.maxSat = maxSat + self.baseFeeSat = baseFeeSat + self.feePpm = feePpm + self.onchainFeeSat = onchainFeeSat + self.atomicity = atomicity + self.fundWithinSecs = fundWithinSecs } } #if compiler(>=6) -extension TransactionDetail: Sendable {} +extension SwapRouteEdge: Sendable {} #endif -extension TransactionDetail: Equatable, Hashable { - public static func ==(lhs: TransactionDetail, rhs: TransactionDetail) -> Bool { - if lhs.txid != rhs.txid { - return false - } - if lhs.received != rhs.received { - return false - } - if lhs.sent != rhs.sent { +extension SwapRouteEdge: Equatable, Hashable { + public static func ==(lhs: SwapRouteEdge, rhs: SwapRouteEdge) -> Bool { + if lhs.providerPubky != rhs.providerPubky { return false } - if lhs.net != rhs.net { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.fee != rhs.fee { + if lhs.offerId != rhs.offerId { return false } if lhs.direction != rhs.direction { return false } - if lhs.blockHeight != rhs.blockHeight { + if lhs.fromEndpoint != rhs.fromEndpoint { return false } - if lhs.timestamp != rhs.timestamp { + if lhs.toEndpoint != rhs.toEndpoint { return false } - if lhs.confirmations != rhs.confirmations { + if lhs.minSat != rhs.minSat { return false } - if lhs.inputs != rhs.inputs { + if lhs.maxSat != rhs.maxSat { return false } - if lhs.outputs != rhs.outputs { + if lhs.baseFeeSat != rhs.baseFeeSat { return false } - if lhs.size != rhs.size { + if lhs.feePpm != rhs.feePpm { return false } - if lhs.vsize != rhs.vsize { + if lhs.onchainFeeSat != rhs.onchainFeeSat { return false } - if lhs.weight != rhs.weight { + if lhs.atomicity != rhs.atomicity { return false } - if lhs.feeRate != rhs.feeRate { + if lhs.fundWithinSecs != rhs.fundWithinSecs { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(received) - hasher.combine(sent) - hasher.combine(net) - hasher.combine(amount) - hasher.combine(fee) + hasher.combine(providerPubky) + hasher.combine(offerId) hasher.combine(direction) - hasher.combine(blockHeight) - hasher.combine(timestamp) - hasher.combine(confirmations) - hasher.combine(inputs) - hasher.combine(outputs) - hasher.combine(size) - hasher.combine(vsize) - hasher.combine(weight) - hasher.combine(feeRate) + hasher.combine(fromEndpoint) + hasher.combine(toEndpoint) + hasher.combine(minSat) + hasher.combine(maxSat) + hasher.combine(baseFeeSat) + hasher.combine(feePpm) + hasher.combine(onchainFeeSat) + hasher.combine(atomicity) + hasher.combine(fundWithinSecs) } } -extension TransactionDetail: Codable {} +extension SwapRouteEdge: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTransactionDetail: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetail { +public struct FfiConverterTypeSwapRouteEdge: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwapRouteEdge { return - try TransactionDetail( - txid: FfiConverterString.read(from: &buf), - received: FfiConverterUInt64.read(from: &buf), - sent: FfiConverterUInt64.read(from: &buf), - net: FfiConverterInt64.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - fee: FfiConverterOptionUInt64.read(from: &buf), - direction: FfiConverterTypeTxDirection.read(from: &buf), - blockHeight: FfiConverterOptionUInt32.read(from: &buf), - timestamp: FfiConverterOptionUInt64.read(from: &buf), - confirmations: FfiConverterUInt32.read(from: &buf), - inputs: FfiConverterSequenceTypeTxDetailInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTxDetailOutput.read(from: &buf), - size: FfiConverterUInt32.read(from: &buf), - vsize: FfiConverterUInt32.read(from: &buf), - weight: FfiConverterUInt32.read(from: &buf), - feeRate: FfiConverterOptionDouble.read(from: &buf) + try SwapRouteEdge( + providerPubky: FfiConverterString.read(from: &buf), + offerId: FfiConverterString.read(from: &buf), + direction: FfiConverterString.read(from: &buf), + fromEndpoint: FfiConverterString.read(from: &buf), + toEndpoint: FfiConverterString.read(from: &buf), + minSat: FfiConverterUInt64.read(from: &buf), + maxSat: FfiConverterUInt64.read(from: &buf), + baseFeeSat: FfiConverterUInt64.read(from: &buf), + feePpm: FfiConverterUInt64.read(from: &buf), + onchainFeeSat: FfiConverterUInt64.read(from: &buf), + atomicity: FfiConverterString.read(from: &buf), + fundWithinSecs: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: TransactionDetail, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt64.write(value.received, into: &buf) - FfiConverterUInt64.write(value.sent, into: &buf) - FfiConverterInt64.write(value.net, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterOptionUInt64.write(value.fee, into: &buf) - FfiConverterTypeTxDirection.write(value.direction, into: &buf) - FfiConverterOptionUInt32.write(value.blockHeight, into: &buf) - FfiConverterOptionUInt64.write(value.timestamp, into: &buf) - FfiConverterUInt32.write(value.confirmations, into: &buf) - FfiConverterSequenceTypeTxDetailInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeTxDetailOutput.write(value.outputs, into: &buf) - FfiConverterUInt32.write(value.size, into: &buf) - FfiConverterUInt32.write(value.vsize, into: &buf) - FfiConverterUInt32.write(value.weight, into: &buf) - FfiConverterOptionDouble.write(value.feeRate, into: &buf) + public static func write(_ value: SwapRouteEdge, into buf: inout [UInt8]) { + FfiConverterString.write(value.providerPubky, into: &buf) + FfiConverterString.write(value.offerId, into: &buf) + FfiConverterString.write(value.direction, into: &buf) + FfiConverterString.write(value.fromEndpoint, into: &buf) + FfiConverterString.write(value.toEndpoint, into: &buf) + FfiConverterUInt64.write(value.minSat, into: &buf) + FfiConverterUInt64.write(value.maxSat, into: &buf) + FfiConverterUInt64.write(value.baseFeeSat, into: &buf) + FfiConverterUInt64.write(value.feePpm, into: &buf) + FfiConverterUInt64.write(value.onchainFeeSat, into: &buf) + FfiConverterString.write(value.atomicity, into: &buf) + FfiConverterUInt64.write(value.fundWithinSecs, into: &buf) } } @@ -14775,261 +15016,265 @@ public struct FfiConverterTypeTransactionDetail: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetail_lift(_ buf: RustBuffer) throws -> TransactionDetail { - return try FfiConverterTypeTransactionDetail.lift(buf) +public func FfiConverterTypeSwapRouteEdge_lift(_ buf: RustBuffer) throws -> SwapRouteEdge { + return try FfiConverterTypeSwapRouteEdge.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetail_lower(_ value: TransactionDetail) -> RustBuffer { - return FfiConverterTypeTransactionDetail.lower(value) +public func FfiConverterTypeSwapRouteEdge_lower(_ value: SwapRouteEdge) -> RustBuffer { + return FfiConverterTypeSwapRouteEdge.lower(value) } -/** - * Details about an onchain transaction. - */ -public struct TransactionDetails { - public var walletId: String +public struct SweepResult { /** - * The transaction ID. + * The transaction ID of the sweep transaction */ - public var txId: String + 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. + * The total amount swept (in satoshis) */ - public var amountSats: Int64 + public var amountSwept: UInt64 /** - * The transaction inputs with full details. + * The fee paid (in satoshis) */ - public var inputs: [TxInput] + public var feePaid: UInt64 /** - * The transaction outputs with full details. + * The number of UTXOs swept */ - public var outputs: [TxOutput] + public var utxosSwept: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(walletId: String, + public init( /** - * The transaction ID. - */txId: String, + * The transaction ID of the sweep transaction + */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 total amount swept (in satoshis) + */amountSwept: UInt64, /** - * The transaction inputs with full details. - */inputs: [TxInput], + * The fee paid (in satoshis) + */feePaid: UInt64, /** - * The transaction outputs with full details. - */outputs: [TxOutput]) { - self.walletId = walletId - self.txId = txId - self.amountSats = amountSats - self.inputs = inputs - self.outputs = outputs + * The number of UTXOs swept + */utxosSwept: UInt32) { + self.txid = txid + self.amountSwept = amountSwept + self.feePaid = feePaid + self.utxosSwept = utxosSwept } } #if compiler(>=6) -extension TransactionDetails: Sendable {} +extension SweepResult: Sendable {} #endif -extension TransactionDetails: Equatable, Hashable { - public static func ==(lhs: TransactionDetails, rhs: TransactionDetails) -> Bool { - if lhs.walletId != rhs.walletId { - return false - } - if lhs.txId != rhs.txId { +extension SweepResult: Equatable, Hashable { + public static func ==(lhs: SweepResult, rhs: SweepResult) -> Bool { + if lhs.txid != rhs.txid { return false } - if lhs.amountSats != rhs.amountSats { + if lhs.amountSwept != rhs.amountSwept { return false } - if lhs.inputs != rhs.inputs { + if lhs.feePaid != rhs.feePaid { return false } - if lhs.outputs != rhs.outputs { + if lhs.utxosSwept != rhs.utxosSwept { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(walletId) - hasher.combine(txId) - hasher.combine(amountSats) - hasher.combine(inputs) - hasher.combine(outputs) + hasher.combine(txid) + hasher.combine(amountSwept) + hasher.combine(feePaid) + hasher.combine(utxosSwept) } } -extension TransactionDetails: Codable {} +extension SweepResult: 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 FfiConverterTypeSweepResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepResult { return - try TransactionDetails( - walletId: FfiConverterString.read(from: &buf), - txId: FfiConverterString.read(from: &buf), - amountSats: FfiConverterInt64.read(from: &buf), - inputs: FfiConverterSequenceTypeTxInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTxOutput.read(from: &buf) + try 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: TransactionDetails, into buf: inout [UInt8]) { - FfiConverterString.write(value.walletId, into: &buf) - FfiConverterString.write(value.txId, into: &buf) - FfiConverterInt64.write(value.amountSats, into: &buf) - FfiConverterSequenceTypeTxInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeTxOutput.write(value.outputs, into: &buf) - } -} + public static func write(_ value: 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) + } +} #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetails_lift(_ buf: RustBuffer) throws -> TransactionDetails { - return try FfiConverterTypeTransactionDetails.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 FfiConverterTypeTransactionDetails_lower(_ value: TransactionDetails) -> RustBuffer { - return FfiConverterTypeTransactionDetails.lower(value) +public func FfiConverterTypeSweepResult_lower(_ value: SweepResult) -> RustBuffer { + return FfiConverterTypeSweepResult.lower(value) } -/** - * Result from querying transaction history for an xpub. - */ -public struct TransactionHistoryResult { +public struct SweepTransactionPreview { /** - * All transactions, sorted: unconfirmed first, then by timestamp descending + * The PSBT (Partially Signed Bitcoin Transaction) in base64 format */ - public var transactions: [HistoryTransaction] + public var psbt: String /** - * Balance breakdown + * The total amount available to sweep (in satoshis) */ - public var balance: WalletBalance + public var totalAmount: UInt64 /** - * Total number of transactions + * The estimated fee for the transaction (in satoshis) */ - public var txCount: UInt32 + public var estimatedFee: UInt64 /** - * Current blockchain tip height + * The estimated virtual size of the transaction (in vbytes) */ - public var blockHeight: UInt32 + public var estimatedVsize: UInt64 /** - * The detected or specified account type + * The number of UTXOs that will be swept */ - public var accountType: AccountType + 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( /** - * All transactions, sorted: unconfirmed first, then by timestamp descending - */transactions: [HistoryTransaction], + * The PSBT (Partially Signed Bitcoin Transaction) in base64 format + */psbt: String, /** - * Balance breakdown - */balance: WalletBalance, + * The total amount available to sweep (in satoshis) + */totalAmount: UInt64, /** - * Total number of transactions - */txCount: UInt32, + * The estimated fee for the transaction (in satoshis) + */estimatedFee: UInt64, /** - * Current blockchain tip height - */blockHeight: UInt32, + * The estimated virtual size of the transaction (in vbytes) + */estimatedVsize: UInt64, /** - * The detected or specified account type - */accountType: AccountType) { - self.transactions = transactions - self.balance = balance - self.txCount = txCount - self.blockHeight = blockHeight - self.accountType = accountType + * 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 TransactionHistoryResult: Sendable {} +extension SweepTransactionPreview: Sendable {} #endif -extension TransactionHistoryResult: Equatable, Hashable { - public static func ==(lhs: TransactionHistoryResult, rhs: TransactionHistoryResult) -> Bool { - if lhs.transactions != rhs.transactions { +extension SweepTransactionPreview: Equatable, Hashable { + public static func ==(lhs: SweepTransactionPreview, rhs: SweepTransactionPreview) -> Bool { + if lhs.psbt != rhs.psbt { return false } - if lhs.balance != rhs.balance { + if lhs.totalAmount != rhs.totalAmount { return false } - if lhs.txCount != rhs.txCount { + if lhs.estimatedFee != rhs.estimatedFee { return false } - if lhs.blockHeight != rhs.blockHeight { + if lhs.estimatedVsize != rhs.estimatedVsize { return false } - if lhs.accountType != rhs.accountType { + 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(transactions) - hasher.combine(balance) - hasher.combine(txCount) - hasher.combine(blockHeight) - hasher.combine(accountType) + hasher.combine(psbt) + hasher.combine(totalAmount) + hasher.combine(estimatedFee) + hasher.combine(estimatedVsize) + hasher.combine(utxosCount) + hasher.combine(destinationAddress) + hasher.combine(amountAfterFees) } } -extension TransactionHistoryResult: Codable {} +extension SweepTransactionPreview: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTransactionHistoryResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionHistoryResult { +public struct FfiConverterTypeSweepTransactionPreview: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepTransactionPreview { return - try TransactionHistoryResult( - transactions: FfiConverterSequenceTypeHistoryTransaction.read(from: &buf), - balance: FfiConverterTypeWalletBalance.read(from: &buf), - txCount: FfiConverterUInt32.read(from: &buf), - blockHeight: FfiConverterUInt32.read(from: &buf), - accountType: FfiConverterTypeAccountType.read(from: &buf) + try 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: TransactionHistoryResult, into buf: inout [UInt8]) { - FfiConverterSequenceTypeHistoryTransaction.write(value.transactions, into: &buf) - FfiConverterTypeWalletBalance.write(value.balance, into: &buf) - FfiConverterUInt32.write(value.txCount, into: &buf) - FfiConverterUInt32.write(value.blockHeight, into: &buf) - FfiConverterTypeAccountType.write(value.accountType, into: &buf) + 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) } } @@ -15037,215 +15282,167 @@ public struct FfiConverterTypeTransactionHistoryResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionHistoryResult_lift(_ buf: RustBuffer) throws -> TransactionHistoryResult { - return try FfiConverterTypeTransactionHistoryResult.lift(buf) +public func FfiConverterTypeSweepTransactionPreview_lift(_ buf: RustBuffer) throws -> SweepTransactionPreview { + return try FfiConverterTypeSweepTransactionPreview.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionHistoryResult_lower(_ value: TransactionHistoryResult) -> RustBuffer { - return FfiConverterTypeTransactionHistoryResult.lower(value) +public func FfiConverterTypeSweepTransactionPreview_lower(_ value: SweepTransactionPreview) -> RustBuffer { + return FfiConverterTypeSweepTransactionPreview.lower(value) } -/** - * Address response from device. - */ -public struct TrezorAddressResponse { +public struct SweepableBalances { /** - * The Bitcoin address + * Balance in legacy (P2PKH) addresses (in satoshis) */ - public var address: String + public var legacyBalance: UInt64 /** - * The serialized path (e.g., "m/84'/0'/0'/0/0") + * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) */ - public var path: String + public var p2shBalance: UInt64 + /** + * 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 p2shUtxosCount: UInt32 + /** + * Number of UTXOs in Taproot wallet + */ + public var taprootUtxosCount: UInt32 + /** + * Total number of UTXOs across all wallet types + */ + public var totalUtxosCount: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * The Bitcoin address - */address: String, + * Balance in legacy (P2PKH) addresses (in satoshis) + */legacyBalance: UInt64, /** - * The serialized path (e.g., "m/84'/0'/0'/0/0") - */path: String) { - self.address = address - self.path = path + * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) + */p2shBalance: UInt64, + /** + * Balance in Taproot (P2TR) addresses (in satoshis) + */taprootBalance: UInt64, + /** + * Total balance across all wallet types (in satoshis) + */totalBalance: UInt64, + /** + * Number of UTXOs in legacy wallet + */legacyUtxosCount: UInt32, + /** + * Number of UTXOs in P2SH-SegWit wallet + */p2shUtxosCount: UInt32, + /** + * Number of UTXOs in Taproot wallet + */taprootUtxosCount: UInt32, + /** + * Total number of UTXOs across all wallet types + */totalUtxosCount: UInt32) { + self.legacyBalance = legacyBalance + self.p2shBalance = p2shBalance + self.taprootBalance = taprootBalance + self.totalBalance = totalBalance + self.legacyUtxosCount = legacyUtxosCount + self.p2shUtxosCount = p2shUtxosCount + self.taprootUtxosCount = taprootUtxosCount + self.totalUtxosCount = totalUtxosCount } } #if compiler(>=6) -extension TrezorAddressResponse: Sendable {} +extension SweepableBalances: Sendable {} #endif -extension TrezorAddressResponse: Equatable, Hashable { - public static func ==(lhs: TrezorAddressResponse, rhs: TrezorAddressResponse) -> Bool { - if lhs.address != rhs.address { +extension SweepableBalances: Equatable, Hashable { + public static func ==(lhs: SweepableBalances, rhs: SweepableBalances) -> Bool { + if lhs.legacyBalance != rhs.legacyBalance { return false } - if lhs.path != rhs.path { + if lhs.p2shBalance != rhs.p2shBalance { return false } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(path) - } -} - -extension TrezorAddressResponse: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTrezorAddressResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorAddressResponse { - return - try TrezorAddressResponse( - address: FfiConverterString.read(from: &buf), - path: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: TrezorAddressResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.path, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorAddressResponse_lift(_ buf: RustBuffer) throws -> TrezorAddressResponse { - return try FfiConverterTypeTrezorAddressResponse.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorAddressResponse_lower(_ value: TrezorAddressResponse) -> RustBuffer { - return FfiConverterTypeTrezorAddressResponse.lower(value) -} - - -/** - * Result from a high-level message call (for BLE/THP devices) - */ -public struct TrezorCallMessageResult { - /** - * Whether the call succeeded - */ - public var success: Bool - /** - * Response message type - */ - public var messageType: UInt16 - /** - * Response protobuf data - */ - public var data: Data - /** - * Error message (empty on success) - */ - public var error: String - /** - * Structured error code (None on success or when the native error is generic) - */ - public var errorCode: TrezorTransportErrorCode? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Whether the call succeeded - */success: Bool, - /** - * Response message type - */messageType: UInt16, - /** - * Response protobuf data - */data: Data, - /** - * Error message (empty on success) - */error: String, - /** - * Structured error code (None on success or when the native error is generic) - */errorCode: TrezorTransportErrorCode?) { - self.success = success - self.messageType = messageType - self.data = data - self.error = error - self.errorCode = errorCode - } -} - -#if compiler(>=6) -extension TrezorCallMessageResult: Sendable {} -#endif - - -extension TrezorCallMessageResult: Equatable, Hashable { - public static func ==(lhs: TrezorCallMessageResult, rhs: TrezorCallMessageResult) -> Bool { - if lhs.success != rhs.success { + if lhs.taprootBalance != rhs.taprootBalance { return false } - if lhs.messageType != rhs.messageType { + if lhs.totalBalance != rhs.totalBalance { return false } - if lhs.data != rhs.data { + if lhs.legacyUtxosCount != rhs.legacyUtxosCount { return false } - if lhs.error != rhs.error { + if lhs.p2shUtxosCount != rhs.p2shUtxosCount { return false } - if lhs.errorCode != rhs.errorCode { + if lhs.taprootUtxosCount != rhs.taprootUtxosCount { + return false + } + if lhs.totalUtxosCount != rhs.totalUtxosCount { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(success) - hasher.combine(messageType) - hasher.combine(data) - hasher.combine(error) - hasher.combine(errorCode) + 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 TrezorCallMessageResult: Codable {} +extension SweepableBalances: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorCallMessageResult { +public struct FfiConverterTypeSweepableBalances: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepableBalances { return - try TrezorCallMessageResult( - success: FfiConverterBool.read(from: &buf), - messageType: FfiConverterUInt16.read(from: &buf), - data: FfiConverterData.read(from: &buf), - error: FfiConverterString.read(from: &buf), - errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) + try 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: TrezorCallMessageResult, into buf: inout [UInt8]) { - FfiConverterBool.write(value.success, into: &buf) - FfiConverterUInt16.write(value.messageType, into: &buf) - FfiConverterData.write(value.data, into: &buf) - FfiConverterString.write(value.error, into: &buf) - FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) + public static func write(_ value: 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) } } @@ -15253,156 +15450,282 @@ public struct FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorCallMessageResult_lift(_ buf: RustBuffer) throws -> TrezorCallMessageResult { - return try FfiConverterTypeTrezorCallMessageResult.lift(buf) +public func FfiConverterTypeSweepableBalances_lift(_ buf: RustBuffer) throws -> SweepableBalances { + return try FfiConverterTypeSweepableBalances.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorCallMessageResult_lower(_ value: TrezorCallMessageResult) -> RustBuffer { - return FfiConverterTypeTrezorCallMessageResult.lower(value) +public func FfiConverterTypeSweepableBalances_lower(_ value: SweepableBalances) -> RustBuffer { + return FfiConverterTypeSweepableBalances.lower(value) } /** - * Device information exposed to FFI. + * Full details for a single transaction, including raw inputs/outputs and size metrics. */ -public struct TrezorDeviceInfo { +public struct TransactionDetail { /** - * Unique identifier for the device + * Transaction ID (hex) */ - public var id: String + public var txid: String /** - * Transport type (USB or Bluetooth) + * Amount received by the wallet (sats) */ - public var transportType: TrezorTransportType + public var received: UInt64 /** - * Device name (from BLE advertisement or USB descriptor) + * Amount sent by the wallet (sats) — includes change sent back to self */ - public var name: String? + public var sent: UInt64 /** - * Transport-specific path (used internally for connection) + * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) */ - public var path: String + public var net: Int64 /** - * Device label (set by user during device setup) + * Display amount in sats (same semantics as HistoryTransaction.amount) */ - public var label: String? + public var amount: UInt64 /** - * Device model (e.g., "T2", "Safe 5", "Safe 7") + * Transaction fee in sats (None if not available) */ - public var model: String? + public var fee: UInt64? /** - * Whether the device is in bootloader mode + * Transaction direction */ - public var isBootloader: Bool + public var direction: TxDirection + /** + * Block height (None if unconfirmed/mempool) + */ + public var blockHeight: UInt32? + /** + * Block timestamp as unix epoch seconds (None if unconfirmed) + */ + public var timestamp: UInt64? + /** + * Number of confirmations (0 if unconfirmed) + */ + public var confirmations: UInt32 + /** + * Transaction inputs + */ + public var inputs: [TxDetailInput] + /** + * Transaction outputs + */ + public var outputs: [TxDetailOutput] + /** + * Serialized transaction size in bytes + */ + public var size: UInt32 + /** + * Virtual size in vbytes (ceil(weight / 4)) + */ + public var vsize: UInt32 + /** + * Transaction weight in weight units + */ + public var weight: UInt32 + /** + * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero + */ + public var feeRate: Double? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Unique identifier for the device - */id: String, + * Transaction ID (hex) + */txid: String, /** - * Transport type (USB or Bluetooth) - */transportType: TrezorTransportType, + * Amount received by the wallet (sats) + */received: UInt64, /** - * Device name (from BLE advertisement or USB descriptor) - */name: String?, + * Amount sent by the wallet (sats) — includes change sent back to self + */sent: UInt64, /** - * Transport-specific path (used internally for connection) - */path: String, + * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) + */net: Int64, /** - * Device label (set by user during device setup) - */label: String?, + * Display amount in sats (same semantics as HistoryTransaction.amount) + */amount: UInt64, /** - * Device model (e.g., "T2", "Safe 5", "Safe 7") - */model: String?, + * Transaction fee in sats (None if not available) + */fee: UInt64?, /** - * Whether the device is in bootloader mode - */isBootloader: Bool) { - self.id = id - self.transportType = transportType - self.name = name - self.path = path - self.label = label - self.model = model - self.isBootloader = isBootloader + * Transaction direction + */direction: TxDirection, + /** + * Block height (None if unconfirmed/mempool) + */blockHeight: UInt32?, + /** + * Block timestamp as unix epoch seconds (None if unconfirmed) + */timestamp: UInt64?, + /** + * Number of confirmations (0 if unconfirmed) + */confirmations: UInt32, + /** + * Transaction inputs + */inputs: [TxDetailInput], + /** + * Transaction outputs + */outputs: [TxDetailOutput], + /** + * Serialized transaction size in bytes + */size: UInt32, + /** + * Virtual size in vbytes (ceil(weight / 4)) + */vsize: UInt32, + /** + * Transaction weight in weight units + */weight: UInt32, + /** + * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero + */feeRate: Double?) { + self.txid = txid + self.received = received + self.sent = sent + self.net = net + self.amount = amount + self.fee = fee + self.direction = direction + self.blockHeight = blockHeight + self.timestamp = timestamp + self.confirmations = confirmations + self.inputs = inputs + self.outputs = outputs + self.size = size + self.vsize = vsize + self.weight = weight + self.feeRate = feeRate } } #if compiler(>=6) -extension TrezorDeviceInfo: Sendable {} +extension TransactionDetail: Sendable {} #endif -extension TrezorDeviceInfo: Equatable, Hashable { - public static func ==(lhs: TrezorDeviceInfo, rhs: TrezorDeviceInfo) -> Bool { - if lhs.id != rhs.id { +extension TransactionDetail: Equatable, Hashable { + public static func ==(lhs: TransactionDetail, rhs: TransactionDetail) -> Bool { + if lhs.txid != rhs.txid { return false } - if lhs.transportType != rhs.transportType { + if lhs.received != rhs.received { return false } - if lhs.name != rhs.name { + if lhs.sent != rhs.sent { return false } - if lhs.path != rhs.path { + if lhs.net != rhs.net { return false } - if lhs.label != rhs.label { + if lhs.amount != rhs.amount { return false } - if lhs.model != rhs.model { + if lhs.fee != rhs.fee { return false } - if lhs.isBootloader != rhs.isBootloader { + if lhs.direction != rhs.direction { + return false + } + if lhs.blockHeight != rhs.blockHeight { + return false + } + if lhs.timestamp != rhs.timestamp { + return false + } + if lhs.confirmations != rhs.confirmations { + return false + } + if lhs.inputs != rhs.inputs { + return false + } + if lhs.outputs != rhs.outputs { + return false + } + if lhs.size != rhs.size { + return false + } + if lhs.vsize != rhs.vsize { + return false + } + if lhs.weight != rhs.weight { + return false + } + if lhs.feeRate != rhs.feeRate { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(transportType) - hasher.combine(name) - hasher.combine(path) - hasher.combine(label) - hasher.combine(model) - hasher.combine(isBootloader) + hasher.combine(txid) + hasher.combine(received) + hasher.combine(sent) + hasher.combine(net) + hasher.combine(amount) + hasher.combine(fee) + hasher.combine(direction) + hasher.combine(blockHeight) + hasher.combine(timestamp) + hasher.combine(confirmations) + hasher.combine(inputs) + hasher.combine(outputs) + hasher.combine(size) + hasher.combine(vsize) + hasher.combine(weight) + hasher.combine(feeRate) } } -extension TrezorDeviceInfo: Codable {} +extension TransactionDetail: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorDeviceInfo { +public struct FfiConverterTypeTransactionDetail: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetail { return - try TrezorDeviceInfo( - id: FfiConverterString.read(from: &buf), - transportType: FfiConverterTypeTrezorTransportType.read(from: &buf), - name: FfiConverterOptionString.read(from: &buf), - path: FfiConverterString.read(from: &buf), - label: FfiConverterOptionString.read(from: &buf), - model: FfiConverterOptionString.read(from: &buf), - isBootloader: FfiConverterBool.read(from: &buf) + try TransactionDetail( + txid: FfiConverterString.read(from: &buf), + received: FfiConverterUInt64.read(from: &buf), + sent: FfiConverterUInt64.read(from: &buf), + net: FfiConverterInt64.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + fee: FfiConverterOptionUInt64.read(from: &buf), + direction: FfiConverterTypeTxDirection.read(from: &buf), + blockHeight: FfiConverterOptionUInt32.read(from: &buf), + timestamp: FfiConverterOptionUInt64.read(from: &buf), + confirmations: FfiConverterUInt32.read(from: &buf), + inputs: FfiConverterSequenceTypeTxDetailInput.read(from: &buf), + outputs: FfiConverterSequenceTypeTxDetailOutput.read(from: &buf), + size: FfiConverterUInt32.read(from: &buf), + vsize: FfiConverterUInt32.read(from: &buf), + weight: FfiConverterUInt32.read(from: &buf), + feeRate: FfiConverterOptionDouble.read(from: &buf) ) } - public static func write(_ value: TrezorDeviceInfo, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterTypeTrezorTransportType.write(value.transportType, into: &buf) - FfiConverterOptionString.write(value.name, into: &buf) - FfiConverterString.write(value.path, into: &buf) - FfiConverterOptionString.write(value.label, into: &buf) - FfiConverterOptionString.write(value.model, into: &buf) - FfiConverterBool.write(value.isBootloader, into: &buf) + public static func write(_ value: TransactionDetail, into buf: inout [UInt8]) { + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt64.write(value.received, into: &buf) + FfiConverterUInt64.write(value.sent, into: &buf) + FfiConverterInt64.write(value.net, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterOptionUInt64.write(value.fee, into: &buf) + FfiConverterTypeTxDirection.write(value.direction, into: &buf) + FfiConverterOptionUInt32.write(value.blockHeight, into: &buf) + FfiConverterOptionUInt64.write(value.timestamp, into: &buf) + FfiConverterUInt32.write(value.confirmations, into: &buf) + FfiConverterSequenceTypeTxDetailInput.write(value.inputs, into: &buf) + FfiConverterSequenceTypeTxDetailOutput.write(value.outputs, into: &buf) + FfiConverterUInt32.write(value.size, into: &buf) + FfiConverterUInt32.write(value.vsize, into: &buf) + FfiConverterUInt32.write(value.weight, into: &buf) + FfiConverterOptionDouble.write(value.feeRate, into: &buf) } } @@ -15410,246 +15733,132 @@ public struct FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorDeviceInfo_lift(_ buf: RustBuffer) throws -> TrezorDeviceInfo { - return try FfiConverterTypeTrezorDeviceInfo.lift(buf) +public func FfiConverterTypeTransactionDetail_lift(_ buf: RustBuffer) throws -> TransactionDetail { + return try FfiConverterTypeTransactionDetail.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorDeviceInfo_lower(_ value: TrezorDeviceInfo) -> RustBuffer { - return FfiConverterTypeTrezorDeviceInfo.lower(value) +public func FfiConverterTypeTransactionDetail_lower(_ value: TransactionDetail) -> RustBuffer { + return FfiConverterTypeTransactionDetail.lower(value) } /** - * Device features after initialization. + * Details about an onchain transaction. */ -public struct TrezorFeatures { - /** - * Vendor string - */ - public var vendor: String? - /** - * Device model - */ - public var model: String? - /** - * Device label (set by user during device setup) - */ - public var label: String? - /** - * Device ID (unique per device) - */ - public var deviceId: String? - /** - * Major firmware version - */ - public var majorVersion: UInt32? - /** - * Minor firmware version - */ - public var minorVersion: UInt32? - /** - * Patch firmware version - */ - public var patchVersion: UInt32? - /** - * Whether PIN protection is enabled - */ - public var pinProtection: Bool? - /** - * Whether the device is currently unlocked. When PIN protection is enabled - * and this is `Some(false)`, mobile callers should back off and ask the - * user to unlock the Trezor instead of repeatedly reconnecting. - */ - public var unlocked: Bool? +public struct TransactionDetails { + public var walletId: String /** - * Whether passphrase protection is enabled + * The transaction ID. */ - public var passphraseProtection: Bool? + public var txId: String /** - * Whether the device is initialized with a seed + * 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 initialized: Bool? + public var amountSats: Int64 /** - * Whether the device needs backup + * The transaction inputs with full details. */ - public var needsBackup: Bool? + public var inputs: [TxInput] /** - * Whether the device can accept passphrase entry on the device itself - * (`Capability_PassphraseEntry`). When false/None, use host entry only. + * The transaction outputs with full details. */ - public var passphraseEntryCapable: Bool? + public var outputs: [TxOutput] // Default memberwise initializers are never public by default, so we // declare one manually. - public init( + public init(walletId: String, /** - * Vendor string - */vendor: String?, - /** - * Device model - */model: String?, - /** - * Device label (set by user during device setup) - */label: String?, - /** - * Device ID (unique per device) - */deviceId: String?, - /** - * Major firmware version - */majorVersion: UInt32?, - /** - * Minor firmware version - */minorVersion: UInt32?, - /** - * Patch firmware version - */patchVersion: UInt32?, - /** - * Whether PIN protection is enabled - */pinProtection: Bool?, - /** - * Whether the device is currently unlocked. When PIN protection is enabled - * and this is `Some(false)`, mobile callers should back off and ask the - * user to unlock the Trezor instead of repeatedly reconnecting. - */unlocked: Bool?, - /** - * Whether passphrase protection is enabled - */passphraseProtection: Bool?, + * The transaction ID. + */txId: String, /** - * Whether the device is initialized with a seed - */initialized: Bool?, + * 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, /** - * Whether the device needs backup - */needsBackup: Bool?, + * The transaction inputs with full details. + */inputs: [TxInput], /** - * Whether the device can accept passphrase entry on the device itself - * (`Capability_PassphraseEntry`). When false/None, use host entry only. - */passphraseEntryCapable: Bool?) { - self.vendor = vendor - self.model = model - self.label = label - self.deviceId = deviceId - self.majorVersion = majorVersion - self.minorVersion = minorVersion - self.patchVersion = patchVersion - self.pinProtection = pinProtection - self.unlocked = unlocked - self.passphraseProtection = passphraseProtection - self.initialized = initialized - self.needsBackup = needsBackup - self.passphraseEntryCapable = passphraseEntryCapable + * The transaction outputs with full details. + */outputs: [TxOutput]) { + self.walletId = walletId + self.txId = txId + self.amountSats = amountSats + self.inputs = inputs + self.outputs = outputs } } #if compiler(>=6) -extension TrezorFeatures: Sendable {} +extension TransactionDetails: Sendable {} #endif -extension TrezorFeatures: Equatable, Hashable { - public static func ==(lhs: TrezorFeatures, rhs: TrezorFeatures) -> Bool { - if lhs.vendor != rhs.vendor { - return false - } - if lhs.model != rhs.model { - return false - } - if lhs.label != rhs.label { - return false - } - if lhs.deviceId != rhs.deviceId { - return false - } - if lhs.majorVersion != rhs.majorVersion { - return false - } - if lhs.minorVersion != rhs.minorVersion { - return false - } - if lhs.patchVersion != rhs.patchVersion { - return false - } - if lhs.pinProtection != rhs.pinProtection { - return false - } - if lhs.unlocked != rhs.unlocked { +extension TransactionDetails: Equatable, Hashable { + public static func ==(lhs: TransactionDetails, rhs: TransactionDetails) -> Bool { + if lhs.walletId != rhs.walletId { return false } - if lhs.passphraseProtection != rhs.passphraseProtection { + if lhs.txId != rhs.txId { return false } - if lhs.initialized != rhs.initialized { + if lhs.amountSats != rhs.amountSats { return false } - if lhs.needsBackup != rhs.needsBackup { + if lhs.inputs != rhs.inputs { return false } - if lhs.passphraseEntryCapable != rhs.passphraseEntryCapable { + if lhs.outputs != rhs.outputs { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(vendor) - hasher.combine(model) - hasher.combine(label) - hasher.combine(deviceId) - hasher.combine(majorVersion) - hasher.combine(minorVersion) - hasher.combine(patchVersion) - hasher.combine(pinProtection) - hasher.combine(unlocked) - hasher.combine(passphraseProtection) - hasher.combine(initialized) - hasher.combine(needsBackup) - hasher.combine(passphraseEntryCapable) + hasher.combine(walletId) + hasher.combine(txId) + hasher.combine(amountSats) + hasher.combine(inputs) + hasher.combine(outputs) } } -extension TrezorFeatures: Codable {} +extension TransactionDetails: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorFeatures { +public struct FfiConverterTypeTransactionDetails: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetails { return - try TrezorFeatures( - vendor: FfiConverterOptionString.read(from: &buf), - model: FfiConverterOptionString.read(from: &buf), - label: FfiConverterOptionString.read(from: &buf), - deviceId: FfiConverterOptionString.read(from: &buf), - majorVersion: FfiConverterOptionUInt32.read(from: &buf), - minorVersion: FfiConverterOptionUInt32.read(from: &buf), - patchVersion: FfiConverterOptionUInt32.read(from: &buf), - pinProtection: FfiConverterOptionBool.read(from: &buf), - unlocked: FfiConverterOptionBool.read(from: &buf), - passphraseProtection: FfiConverterOptionBool.read(from: &buf), - initialized: FfiConverterOptionBool.read(from: &buf), - needsBackup: FfiConverterOptionBool.read(from: &buf), - passphraseEntryCapable: FfiConverterOptionBool.read(from: &buf) + try TransactionDetails( + walletId: FfiConverterString.read(from: &buf), + txId: FfiConverterString.read(from: &buf), + amountSats: FfiConverterInt64.read(from: &buf), + inputs: FfiConverterSequenceTypeTxInput.read(from: &buf), + outputs: FfiConverterSequenceTypeTxOutput.read(from: &buf) ) } - public static func write(_ value: TrezorFeatures, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.vendor, into: &buf) - FfiConverterOptionString.write(value.model, into: &buf) - FfiConverterOptionString.write(value.label, into: &buf) - FfiConverterOptionString.write(value.deviceId, into: &buf) - FfiConverterOptionUInt32.write(value.majorVersion, into: &buf) - FfiConverterOptionUInt32.write(value.minorVersion, into: &buf) - FfiConverterOptionUInt32.write(value.patchVersion, into: &buf) - FfiConverterOptionBool.write(value.pinProtection, into: &buf) - FfiConverterOptionBool.write(value.unlocked, into: &buf) - FfiConverterOptionBool.write(value.passphraseProtection, into: &buf) - FfiConverterOptionBool.write(value.initialized, into: &buf) - FfiConverterOptionBool.write(value.needsBackup, into: &buf) - FfiConverterOptionBool.write(value.passphraseEntryCapable, into: &buf) + public static func write(_ value: TransactionDetails, into buf: inout [UInt8]) { + FfiConverterString.write(value.walletId, into: &buf) + FfiConverterString.write(value.txId, into: &buf) + FfiConverterInt64.write(value.amountSats, into: &buf) + FfiConverterSequenceTypeTxInput.write(value.inputs, into: &buf) + FfiConverterSequenceTypeTxOutput.write(value.outputs, into: &buf) } } @@ -15657,128 +15866,128 @@ public struct FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorFeatures_lift(_ buf: RustBuffer) throws -> TrezorFeatures { - return try FfiConverterTypeTrezorFeatures.lift(buf) +public func FfiConverterTypeTransactionDetails_lift(_ buf: RustBuffer) throws -> TransactionDetails { + return try FfiConverterTypeTransactionDetails.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorFeatures_lower(_ value: TrezorFeatures) -> RustBuffer { - return FfiConverterTypeTrezorFeatures.lower(value) +public func FfiConverterTypeTransactionDetails_lower(_ value: TransactionDetails) -> RustBuffer { + return FfiConverterTypeTransactionDetails.lower(value) } /** - * Parameters for getting an address from the device. + * Result from querying transaction history for an xpub. */ -public struct TrezorGetAddressParams { +public struct TransactionHistoryResult { /** - * BIP32 path (e.g., "m/84'/0'/0'/0/0") + * All transactions, sorted: unconfirmed first, then by timestamp descending */ - public var path: String + public var transactions: [HistoryTransaction] /** - * Coin network (inferred from the path when omitted) + * Balance breakdown */ - public var coin: TrezorCoinType? + public var balance: WalletBalance /** - * Whether to display the address on the device for confirmation + * Total number of transactions */ - public var showOnTrezor: Bool + public var txCount: UInt32 /** - * Script type (auto-detected from path if not specified) + * Current blockchain tip height */ - public var scriptType: TrezorScriptType? + public var blockHeight: UInt32 /** - * Allow an explicitly selected coin to differ from the path (default: false). + * The detected or specified account type */ - public var crossChain: Bool + public var accountType: AccountType // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * BIP32 path (e.g., "m/84'/0'/0'/0/0") - */path: String, + * All transactions, sorted: unconfirmed first, then by timestamp descending + */transactions: [HistoryTransaction], /** - * Coin network (inferred from the path when omitted) - */coin: TrezorCoinType?, + * Balance breakdown + */balance: WalletBalance, /** - * Whether to display the address on the device for confirmation - */showOnTrezor: Bool, + * Total number of transactions + */txCount: UInt32, /** - * Script type (auto-detected from path if not specified) - */scriptType: TrezorScriptType?, + * Current blockchain tip height + */blockHeight: UInt32, /** - * Allow an explicitly selected coin to differ from the path (default: false). - */crossChain: Bool = false) { - self.path = path - self.coin = coin - self.showOnTrezor = showOnTrezor - self.scriptType = scriptType - self.crossChain = crossChain + * The detected or specified account type + */accountType: AccountType) { + self.transactions = transactions + self.balance = balance + self.txCount = txCount + self.blockHeight = blockHeight + self.accountType = accountType } } #if compiler(>=6) -extension TrezorGetAddressParams: Sendable {} +extension TransactionHistoryResult: Sendable {} #endif -extension TrezorGetAddressParams: Equatable, Hashable { - public static func ==(lhs: TrezorGetAddressParams, rhs: TrezorGetAddressParams) -> Bool { - if lhs.path != rhs.path { +extension TransactionHistoryResult: Equatable, Hashable { + public static func ==(lhs: TransactionHistoryResult, rhs: TransactionHistoryResult) -> Bool { + if lhs.transactions != rhs.transactions { return false } - if lhs.coin != rhs.coin { + if lhs.balance != rhs.balance { return false } - if lhs.showOnTrezor != rhs.showOnTrezor { + if lhs.txCount != rhs.txCount { return false } - if lhs.scriptType != rhs.scriptType { + if lhs.blockHeight != rhs.blockHeight { return false } - if lhs.crossChain != rhs.crossChain { + if lhs.accountType != rhs.accountType { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(coin) - hasher.combine(showOnTrezor) - hasher.combine(scriptType) - hasher.combine(crossChain) - } + hasher.combine(transactions) + hasher.combine(balance) + hasher.combine(txCount) + hasher.combine(blockHeight) + hasher.combine(accountType) + } } -extension TrezorGetAddressParams: Codable {} +extension TransactionHistoryResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetAddressParams { +public struct FfiConverterTypeTransactionHistoryResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionHistoryResult { return - try TrezorGetAddressParams( - path: FfiConverterString.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), - showOnTrezor: FfiConverterBool.read(from: &buf), - scriptType: FfiConverterOptionTypeTrezorScriptType.read(from: &buf), - crossChain: FfiConverterBool.read(from: &buf) + try TransactionHistoryResult( + transactions: FfiConverterSequenceTypeHistoryTransaction.read(from: &buf), + balance: FfiConverterTypeWalletBalance.read(from: &buf), + txCount: FfiConverterUInt32.read(from: &buf), + blockHeight: FfiConverterUInt32.read(from: &buf), + accountType: FfiConverterTypeAccountType.read(from: &buf) ) } - public static func write(_ value: 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) - FfiConverterBool.write(value.crossChain, into: &buf) + public static func write(_ value: TransactionHistoryResult, into buf: inout [UInt8]) { + FfiConverterSequenceTypeHistoryTransaction.write(value.transactions, into: &buf) + FfiConverterTypeWalletBalance.write(value.balance, into: &buf) + FfiConverterUInt32.write(value.txCount, into: &buf) + FfiConverterUInt32.write(value.blockHeight, into: &buf) + FfiConverterTypeAccountType.write(value.accountType, into: &buf) } } @@ -15786,114 +15995,86 @@ public struct FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorGetAddressParams_lift(_ buf: RustBuffer) throws -> TrezorGetAddressParams { - return try FfiConverterTypeTrezorGetAddressParams.lift(buf) +public func FfiConverterTypeTransactionHistoryResult_lift(_ buf: RustBuffer) throws -> TransactionHistoryResult { + return try FfiConverterTypeTransactionHistoryResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorGetAddressParams_lower(_ value: TrezorGetAddressParams) -> RustBuffer { - return FfiConverterTypeTrezorGetAddressParams.lower(value) +public func FfiConverterTypeTransactionHistoryResult_lower(_ value: TransactionHistoryResult) -> RustBuffer { + return FfiConverterTypeTransactionHistoryResult.lower(value) } /** - * Parameters for getting a public key from the device. + * Address response from device. */ -public struct TrezorGetPublicKeyParams { - /** - * BIP32 path (e.g., "m/84'/0'/0'") - */ - public var path: String - /** - * Coin network (inferred from the path when omitted) - */ - public var coin: TrezorCoinType? +public struct TrezorAddressResponse { /** - * Whether to display on device for confirmation + * The Bitcoin address */ - public var showOnTrezor: Bool + public var address: String /** - * Allow an explicitly selected coin to differ from the path (default: false). + * The serialized path (e.g., "m/84'/0'/0'/0/0") */ - public var crossChain: Bool + public var path: String // 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 (inferred from the path when omitted) - */coin: TrezorCoinType?, - /** - * Whether to display on device for confirmation - */showOnTrezor: Bool, + * The Bitcoin address + */address: String, /** - * Allow an explicitly selected coin to differ from the path (default: false). - */crossChain: Bool = false) { + * The serialized path (e.g., "m/84'/0'/0'/0/0") + */path: String) { + self.address = address self.path = path - self.coin = coin - self.showOnTrezor = showOnTrezor - self.crossChain = crossChain } } #if compiler(>=6) -extension TrezorGetPublicKeyParams: Sendable {} +extension TrezorAddressResponse: 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 { +extension TrezorAddressResponse: Equatable, Hashable { + public static func ==(lhs: TrezorAddressResponse, rhs: TrezorAddressResponse) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.crossChain != rhs.crossChain { + if lhs.path != rhs.path { return false } return true } public func hash(into hasher: inout Hasher) { + hasher.combine(address) hasher.combine(path) - hasher.combine(coin) - hasher.combine(showOnTrezor) - hasher.combine(crossChain) } } -extension TrezorGetPublicKeyParams: Codable {} +extension TrezorAddressResponse: 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 { +public struct FfiConverterTypeTrezorAddressResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorAddressResponse { return - try TrezorGetPublicKeyParams( - path: FfiConverterString.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), - showOnTrezor: FfiConverterBool.read(from: &buf), - crossChain: FfiConverterBool.read(from: &buf) + try TrezorAddressResponse( + address: FfiConverterString.read(from: &buf), + path: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: TrezorGetPublicKeyParams, into buf: inout [UInt8]) { + public static func write(_ value: TrezorAddressResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) FfiConverterString.write(value.path, into: &buf) - FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) - FfiConverterBool.write(value.showOnTrezor, into: &buf) - FfiConverterBool.write(value.crossChain, into: &buf) } } @@ -15901,128 +16082,128 @@ public struct FfiConverterTypeTrezorGetPublicKeyParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorGetPublicKeyParams_lift(_ buf: RustBuffer) throws -> TrezorGetPublicKeyParams { - return try FfiConverterTypeTrezorGetPublicKeyParams.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 FfiConverterTypeTrezorGetPublicKeyParams_lower(_ value: TrezorGetPublicKeyParams) -> RustBuffer { - return FfiConverterTypeTrezorGetPublicKeyParams.lower(value) +public func FfiConverterTypeTrezorAddressResponse_lower(_ value: TrezorAddressResponse) -> RustBuffer { + return FfiConverterTypeTrezorAddressResponse.lower(value) } /** - * Previous transaction data (for non-SegWit input verification). + * Result from a high-level message call (for BLE/THP devices) */ -public struct TrezorPrevTx { +public struct TrezorCallMessageResult { /** - * Transaction hash (hex encoded) + * Whether the call succeeded */ - public var hash: String + public var success: Bool /** - * Transaction version + * Response message type */ - public var version: UInt32 + public var messageType: UInt16 /** - * Lock time + * Response protobuf data */ - public var lockTime: UInt32 + public var data: Data /** - * Transaction inputs + * Error message (empty on success) */ - public var inputs: [TrezorPrevTxInput] + public var error: String /** - * Transaction outputs + * Structured error code (None on success or when the native error is generic) */ - public var outputs: [TrezorPrevTxOutput] + public var errorCode: TrezorTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Transaction hash (hex encoded) - */hash: String, + * Whether the call succeeded + */success: Bool, /** - * Transaction version - */version: UInt32, + * Response message type + */messageType: UInt16, /** - * Lock time - */lockTime: UInt32, + * Response protobuf data + */data: Data, /** - * Transaction inputs - */inputs: [TrezorPrevTxInput], + * Error message (empty on success) + */error: String, /** - * Transaction outputs - */outputs: [TrezorPrevTxOutput]) { - self.hash = hash - self.version = version - self.lockTime = lockTime - self.inputs = inputs - self.outputs = outputs + * Structured error code (None on success or when the native error is generic) + */errorCode: TrezorTransportErrorCode?) { + self.success = success + self.messageType = messageType + self.data = data + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension TrezorPrevTx: Sendable {} +extension TrezorCallMessageResult: Sendable {} #endif -extension TrezorPrevTx: Equatable, Hashable { - public static func ==(lhs: TrezorPrevTx, rhs: TrezorPrevTx) -> Bool { - if lhs.hash != rhs.hash { +extension TrezorCallMessageResult: Equatable, Hashable { + public static func ==(lhs: TrezorCallMessageResult, rhs: TrezorCallMessageResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.version != rhs.version { + if lhs.messageType != rhs.messageType { return false } - if lhs.lockTime != rhs.lockTime { + if lhs.data != rhs.data { return false } - if lhs.inputs != rhs.inputs { + if lhs.error != rhs.error { return false } - if lhs.outputs != rhs.outputs { + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(hash) - hasher.combine(version) - hasher.combine(lockTime) - hasher.combine(inputs) - hasher.combine(outputs) + hasher.combine(success) + hasher.combine(messageType) + hasher.combine(data) + hasher.combine(error) + hasher.combine(errorCode) } } -extension TrezorPrevTx: Codable {} +extension TrezorCallMessageResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorPrevTx: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTx { +public struct FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorCallMessageResult { return - try TrezorPrevTx( - hash: FfiConverterString.read(from: &buf), - version: FfiConverterUInt32.read(from: &buf), - lockTime: FfiConverterUInt32.read(from: &buf), - inputs: FfiConverterSequenceTypeTrezorPrevTxInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTrezorPrevTxOutput.read(from: &buf) + try TrezorCallMessageResult( + success: FfiConverterBool.read(from: &buf), + messageType: FfiConverterUInt16.read(from: &buf), + data: FfiConverterData.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: 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) + public static func write(_ value: TrezorCallMessageResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterUInt16.write(value.messageType, into: &buf) + FfiConverterData.write(value.data, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -16030,201 +16211,156 @@ public struct FfiConverterTypeTrezorPrevTx: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTx_lift(_ buf: RustBuffer) throws -> TrezorPrevTx { - return try FfiConverterTypeTrezorPrevTx.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 FfiConverterTypeTrezorPrevTx_lower(_ value: TrezorPrevTx) -> RustBuffer { - return FfiConverterTypeTrezorPrevTx.lower(value) +public func FfiConverterTypeTrezorCallMessageResult_lower(_ value: TrezorCallMessageResult) -> RustBuffer { + return FfiConverterTypeTrezorCallMessageResult.lower(value) } /** - * Input of a previous transaction. + * Device information exposed to FFI. */ -public struct TrezorPrevTxInput { +public struct TrezorDeviceInfo { /** - * Previous transaction hash (hex encoded) + * Unique identifier for the device */ - public var prevHash: String + public var id: String /** - * Previous output index + * Transport type (USB or Bluetooth) */ - public var prevIndex: UInt32 + public var transportType: TrezorTransportType /** - * Script signature (hex encoded) + * Device name (from BLE advertisement or USB descriptor) */ - public var scriptSig: String + public var name: String? /** - * Sequence number + * Transport-specific path (used internally for connection) */ - public var sequence: UInt32 + 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( /** - * Previous transaction hash (hex encoded) - */prevHash: String, + * Unique identifier for the device + */id: String, /** - * Previous output index - */prevIndex: UInt32, + * Transport type (USB or Bluetooth) + */transportType: TrezorTransportType, /** - * Script signature (hex encoded) - */scriptSig: String, + * Device name (from BLE advertisement or USB descriptor) + */name: String?, /** - * Sequence number - */sequence: UInt32) { - self.prevHash = prevHash - self.prevIndex = prevIndex - self.scriptSig = scriptSig - self.sequence = sequence + * 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 TrezorPrevTxInput: Sendable {} +extension TrezorDeviceInfo: Sendable {} #endif -extension TrezorPrevTxInput: Equatable, Hashable { - public static func ==(lhs: TrezorPrevTxInput, rhs: TrezorPrevTxInput) -> Bool { - if lhs.prevHash != rhs.prevHash { +extension TrezorDeviceInfo: Equatable, Hashable { + public static func ==(lhs: TrezorDeviceInfo, rhs: TrezorDeviceInfo) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.prevIndex != rhs.prevIndex { + if lhs.transportType != rhs.transportType { return false } - if lhs.scriptSig != rhs.scriptSig { + if lhs.name != rhs.name { return false } - if lhs.sequence != rhs.sequence { + if lhs.path != rhs.path { return false } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(prevHash) - hasher.combine(prevIndex) - hasher.combine(scriptSig) - hasher.combine(sequence) - } -} - -extension TrezorPrevTxInput: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTrezorPrevTxInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxInput { - return - 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: 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) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorPrevTxInput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxInput { - return try FfiConverterTypeTrezorPrevTxInput.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorPrevTxInput_lower(_ value: TrezorPrevTxInput) -> RustBuffer { - return FfiConverterTypeTrezorPrevTxInput.lower(value) -} - - -/** - * Output of a previous transaction. - */ -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( - /** - * Amount in satoshis - */amount: UInt64, - /** - * Script pubkey (hex encoded) - */scriptPubkey: String) { - self.amount = amount - self.scriptPubkey = scriptPubkey - } -} - -#if compiler(>=6) -extension TrezorPrevTxOutput: Sendable {} -#endif - - -extension TrezorPrevTxOutput: Equatable, Hashable { - public static func ==(lhs: TrezorPrevTxOutput, rhs: TrezorPrevTxOutput) -> Bool { - if lhs.amount != rhs.amount { + if lhs.label != rhs.label { return false } - if lhs.scriptPubkey != rhs.scriptPubkey { + if lhs.model != rhs.model { + return false + } + if lhs.isBootloader != rhs.isBootloader { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(amount) - hasher.combine(scriptPubkey) + hasher.combine(id) + hasher.combine(transportType) + hasher.combine(name) + hasher.combine(path) + hasher.combine(label) + hasher.combine(model) + hasher.combine(isBootloader) } } -extension TrezorPrevTxOutput: Codable {} +extension TrezorDeviceInfo: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxOutput { +public struct FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorDeviceInfo { return - try TrezorPrevTxOutput( - amount: FfiConverterUInt64.read(from: &buf), - scriptPubkey: FfiConverterString.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: TrezorPrevTxOutput, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterString.write(value.scriptPubkey, 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) } } @@ -16232,198 +16368,246 @@ public struct FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTxOutput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxOutput { - return try FfiConverterTypeTrezorPrevTxOutput.lift(buf) +public func FfiConverterTypeTrezorDeviceInfo_lift(_ buf: RustBuffer) throws -> TrezorDeviceInfo { + return try FfiConverterTypeTrezorDeviceInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTxOutput_lower(_ value: TrezorPrevTxOutput) -> RustBuffer { - return FfiConverterTypeTrezorPrevTxOutput.lower(value) +public func FfiConverterTypeTrezorDeviceInfo_lower(_ value: TrezorDeviceInfo) -> RustBuffer { + return FfiConverterTypeTrezorDeviceInfo.lower(value) } /** - * Public key response from device. + * Device features after initialization. */ -public struct TrezorPublicKeyResponse { +public struct TrezorFeatures { /** - * Normalized xpub/tpub. Preserve the selected account type when importing. + * Vendor string */ - public var xpub: String + public var vendor: String? /** - * Firmware SLIP-132 key for BIP-49/BIP-84, or a Taproot descriptor. + * Device model */ - public var xpubSegwit: String? + public var model: String? /** - * Output descriptor returned by the firmware, when available. + * Device label (set by user during device setup) */ - public var descriptor: String? + public var label: String? /** - * Key or descriptor intended for display, not for extended-key import. + * Device ID (unique per device) */ - public var displayablePublicKey: String + public var deviceId: String? /** - * The serialized path (e.g., "m/84'/0'/0'") + * Major firmware version */ - public var path: String + public var majorVersion: UInt32? /** - * Compressed public key (hex encoded) + * Minor firmware version */ - public var publicKey: String + public var minorVersion: UInt32? /** - * Chain code (hex encoded) + * Patch firmware version */ - public var chainCode: String + public var patchVersion: UInt32? /** - * Parent key fingerprint + * Whether PIN protection is enabled */ - public var fingerprint: UInt32 + public var pinProtection: Bool? /** - * Derivation depth + * Whether the device is currently unlocked. When PIN protection is enabled + * and this is `Some(false)`, mobile callers should back off and ask the + * user to unlock the Trezor instead of repeatedly reconnecting. */ - public var depth: UInt32 + public var unlocked: Bool? /** - * Master root fingerprint (from the device's master seed) + * Whether passphrase protection is enabled */ - public var rootFingerprint: UInt32? + public var passphraseProtection: Bool? + /** + * Whether the device is initialized with a seed + */ + public var initialized: Bool? + /** + * Whether the device needs backup + */ + public var needsBackup: Bool? + /** + * Whether the device can accept passphrase entry on the device itself + * (`Capability_PassphraseEntry`). When false/None, use host entry only. + */ + public var passphraseEntryCapable: Bool? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Normalized xpub/tpub. Preserve the selected account type when importing. - */xpub: String, + * Vendor string + */vendor: String?, /** - * Firmware SLIP-132 key for BIP-49/BIP-84, or a Taproot descriptor. - */xpubSegwit: String?, + * Device model + */model: String?, /** - * Output descriptor returned by the firmware, when available. - */descriptor: String?, + * Device label (set by user during device setup) + */label: String?, /** - * Key or descriptor intended for display, not for extended-key import. - */displayablePublicKey: String, + * Device ID (unique per device) + */deviceId: String?, /** - * The serialized path (e.g., "m/84'/0'/0'") - */path: String, + * Major firmware version + */majorVersion: UInt32?, /** - * Compressed public key (hex encoded) - */publicKey: String, + * Minor firmware version + */minorVersion: UInt32?, /** - * Chain code (hex encoded) - */chainCode: String, + * Patch firmware version + */patchVersion: UInt32?, /** - * Parent key fingerprint - */fingerprint: UInt32, + * Whether PIN protection is enabled + */pinProtection: Bool?, /** - * Derivation depth - */depth: UInt32, + * Whether the device is currently unlocked. When PIN protection is enabled + * and this is `Some(false)`, mobile callers should back off and ask the + * user to unlock the Trezor instead of repeatedly reconnecting. + */unlocked: Bool?, /** - * Master root fingerprint (from the device's master seed) - */rootFingerprint: UInt32?) { - self.xpub = xpub - self.xpubSegwit = xpubSegwit - self.descriptor = descriptor - self.displayablePublicKey = displayablePublicKey - self.path = path - self.publicKey = publicKey - self.chainCode = chainCode - self.fingerprint = fingerprint - self.depth = depth - self.rootFingerprint = rootFingerprint + * Whether passphrase protection is enabled + */passphraseProtection: Bool?, + /** + * Whether the device is initialized with a seed + */initialized: Bool?, + /** + * Whether the device needs backup + */needsBackup: Bool?, + /** + * Whether the device can accept passphrase entry on the device itself + * (`Capability_PassphraseEntry`). When false/None, use host entry only. + */passphraseEntryCapable: Bool?) { + self.vendor = vendor + self.model = model + self.label = label + self.deviceId = deviceId + self.majorVersion = majorVersion + self.minorVersion = minorVersion + self.patchVersion = patchVersion + self.pinProtection = pinProtection + self.unlocked = unlocked + self.passphraseProtection = passphraseProtection + self.initialized = initialized + self.needsBackup = needsBackup + self.passphraseEntryCapable = passphraseEntryCapable } } #if compiler(>=6) -extension TrezorPublicKeyResponse: Sendable {} +extension TrezorFeatures: Sendable {} #endif -extension TrezorPublicKeyResponse: Equatable, Hashable { - public static func ==(lhs: TrezorPublicKeyResponse, rhs: TrezorPublicKeyResponse) -> Bool { - if lhs.xpub != rhs.xpub { +extension TrezorFeatures: Equatable, Hashable { + public static func ==(lhs: TrezorFeatures, rhs: TrezorFeatures) -> Bool { + if lhs.vendor != rhs.vendor { return false } - if lhs.xpubSegwit != rhs.xpubSegwit { + if lhs.model != rhs.model { return false } - if lhs.descriptor != rhs.descriptor { + if lhs.label != rhs.label { return false } - if lhs.displayablePublicKey != rhs.displayablePublicKey { + if lhs.deviceId != rhs.deviceId { return false } - if lhs.path != rhs.path { + if lhs.majorVersion != rhs.majorVersion { return false } - if lhs.publicKey != rhs.publicKey { + if lhs.minorVersion != rhs.minorVersion { return false } - if lhs.chainCode != rhs.chainCode { + if lhs.patchVersion != rhs.patchVersion { return false } - if lhs.fingerprint != rhs.fingerprint { + if lhs.pinProtection != rhs.pinProtection { return false } - if lhs.depth != rhs.depth { + if lhs.unlocked != rhs.unlocked { return false } - if lhs.rootFingerprint != rhs.rootFingerprint { + if lhs.passphraseProtection != rhs.passphraseProtection { + return false + } + if lhs.initialized != rhs.initialized { + return false + } + if lhs.needsBackup != rhs.needsBackup { + return false + } + if lhs.passphraseEntryCapable != rhs.passphraseEntryCapable { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(xpub) - hasher.combine(xpubSegwit) - hasher.combine(descriptor) - hasher.combine(displayablePublicKey) - hasher.combine(path) - hasher.combine(publicKey) - hasher.combine(chainCode) - hasher.combine(fingerprint) - hasher.combine(depth) - hasher.combine(rootFingerprint) + hasher.combine(vendor) + hasher.combine(model) + hasher.combine(label) + hasher.combine(deviceId) + hasher.combine(majorVersion) + hasher.combine(minorVersion) + hasher.combine(patchVersion) + hasher.combine(pinProtection) + hasher.combine(unlocked) + hasher.combine(passphraseProtection) + hasher.combine(initialized) + hasher.combine(needsBackup) + hasher.combine(passphraseEntryCapable) } } -extension TrezorPublicKeyResponse: Codable {} +extension TrezorFeatures: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPublicKeyResponse { +public struct FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorFeatures { return - try TrezorPublicKeyResponse( - xpub: FfiConverterString.read(from: &buf), - xpubSegwit: FfiConverterOptionString.read(from: &buf), - descriptor: FfiConverterOptionString.read(from: &buf), - displayablePublicKey: FfiConverterString.read(from: &buf), - path: FfiConverterString.read(from: &buf), - publicKey: FfiConverterString.read(from: &buf), - chainCode: FfiConverterString.read(from: &buf), - fingerprint: FfiConverterUInt32.read(from: &buf), - depth: FfiConverterUInt32.read(from: &buf), - rootFingerprint: FfiConverterOptionUInt32.read(from: &buf) + try TrezorFeatures( + vendor: FfiConverterOptionString.read(from: &buf), + model: FfiConverterOptionString.read(from: &buf), + label: FfiConverterOptionString.read(from: &buf), + deviceId: FfiConverterOptionString.read(from: &buf), + majorVersion: FfiConverterOptionUInt32.read(from: &buf), + minorVersion: FfiConverterOptionUInt32.read(from: &buf), + patchVersion: FfiConverterOptionUInt32.read(from: &buf), + pinProtection: FfiConverterOptionBool.read(from: &buf), + unlocked: FfiConverterOptionBool.read(from: &buf), + passphraseProtection: FfiConverterOptionBool.read(from: &buf), + initialized: FfiConverterOptionBool.read(from: &buf), + needsBackup: FfiConverterOptionBool.read(from: &buf), + passphraseEntryCapable: FfiConverterOptionBool.read(from: &buf) ) } - public static func write(_ value: TrezorPublicKeyResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.xpub, into: &buf) - FfiConverterOptionString.write(value.xpubSegwit, into: &buf) - FfiConverterOptionString.write(value.descriptor, into: &buf) - FfiConverterString.write(value.displayablePublicKey, 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) + public static func write(_ value: TrezorFeatures, into buf: inout [UInt8]) { + FfiConverterOptionString.write(value.vendor, into: &buf) + FfiConverterOptionString.write(value.model, into: &buf) + FfiConverterOptionString.write(value.label, into: &buf) + FfiConverterOptionString.write(value.deviceId, into: &buf) + FfiConverterOptionUInt32.write(value.majorVersion, into: &buf) + FfiConverterOptionUInt32.write(value.minorVersion, into: &buf) + FfiConverterOptionUInt32.write(value.patchVersion, into: &buf) + FfiConverterOptionBool.write(value.pinProtection, into: &buf) + FfiConverterOptionBool.write(value.unlocked, into: &buf) + FfiConverterOptionBool.write(value.passphraseProtection, into: &buf) + FfiConverterOptionBool.write(value.initialized, into: &buf) + FfiConverterOptionBool.write(value.needsBackup, into: &buf) + FfiConverterOptionBool.write(value.passphraseEntryCapable, into: &buf) } } @@ -16431,34 +16615,38 @@ public struct FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPublicKeyResponse_lift(_ buf: RustBuffer) throws -> TrezorPublicKeyResponse { - return try FfiConverterTypeTrezorPublicKeyResponse.lift(buf) +public func FfiConverterTypeTrezorFeatures_lift(_ buf: RustBuffer) throws -> TrezorFeatures { + return try FfiConverterTypeTrezorFeatures.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPublicKeyResponse_lower(_ value: TrezorPublicKeyResponse) -> RustBuffer { - return FfiConverterTypeTrezorPublicKeyResponse.lower(value) +public func FfiConverterTypeTrezorFeatures_lower(_ value: TrezorFeatures) -> RustBuffer { + return FfiConverterTypeTrezorFeatures.lower(value) } /** - * Parameters for signing a message. + * Parameters for getting an address from the device. */ -public struct TrezorSignMessageParams { +public struct TrezorGetAddressParams { /** - * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") + * BIP32 path (e.g., "m/84'/0'/0'/0/0") */ public var path: String - /** - * Message to sign - */ - public var message: String /** * Coin network (inferred from the path when omitted) */ public var coin: TrezorCoinType? + /** + * Whether to display the address on the device for confirmation + */ + public var showOnTrezor: Bool + /** + * Script type (auto-detected from path if not specified) + */ + public var scriptType: TrezorScriptType? /** * Allow an explicitly selected coin to differ from the path (default: false). */ @@ -16468,41 +16656,48 @@ public struct TrezorSignMessageParams { // declare one manually. public init( /** - * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") + * BIP32 path (e.g., "m/84'/0'/0'/0/0") */path: String, - /** - * Message to sign - */message: String, /** * Coin network (inferred from the path when omitted) */coin: TrezorCoinType?, + /** + * Whether to display the address on the device for confirmation + */showOnTrezor: Bool, + /** + * Script type (auto-detected from path if not specified) + */scriptType: TrezorScriptType?, /** * Allow an explicitly selected coin to differ from the path (default: false). */crossChain: Bool = false) { self.path = path - self.message = message self.coin = coin + self.showOnTrezor = showOnTrezor + self.scriptType = scriptType self.crossChain = crossChain } } #if compiler(>=6) -extension TrezorSignMessageParams: Sendable {} +extension TrezorGetAddressParams: Sendable {} #endif -extension TrezorSignMessageParams: Equatable, Hashable { - public static func ==(lhs: TrezorSignMessageParams, rhs: TrezorSignMessageParams) -> Bool { +extension TrezorGetAddressParams: Equatable, Hashable { + public static func ==(lhs: TrezorGetAddressParams, rhs: TrezorGetAddressParams) -> Bool { if lhs.path != rhs.path { return false } - if lhs.message != rhs.message { - return false - } if lhs.coin != rhs.coin { return false } - if lhs.crossChain != rhs.crossChain { + if lhs.showOnTrezor != rhs.showOnTrezor { + return false + } + if lhs.scriptType != rhs.scriptType { + return false + } + if lhs.crossChain != rhs.crossChain { return false } return true @@ -16510,34 +16705,37 @@ extension TrezorSignMessageParams: Equatable, Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(path) - hasher.combine(message) hasher.combine(coin) + hasher.combine(showOnTrezor) + hasher.combine(scriptType) hasher.combine(crossChain) } } -extension TrezorSignMessageParams: Codable {} +extension TrezorGetAddressParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignMessageParams { +public struct FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetAddressParams { return - try TrezorSignMessageParams( + try TrezorGetAddressParams( path: FfiConverterString.read(from: &buf), - message: FfiConverterString.read(from: &buf), coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), + showOnTrezor: FfiConverterBool.read(from: &buf), + scriptType: FfiConverterOptionTypeTrezorScriptType.read(from: &buf), crossChain: FfiConverterBool.read(from: &buf) ) } - public static func write(_ value: TrezorSignMessageParams, into buf: inout [UInt8]) { + public static func write(_ value: TrezorGetAddressParams, into buf: inout [UInt8]) { FfiConverterString.write(value.path, into: &buf) - FfiConverterString.write(value.message, into: &buf) FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + FfiConverterBool.write(value.showOnTrezor, into: &buf) + FfiConverterOptionTypeTrezorScriptType.write(value.scriptType, into: &buf) FfiConverterBool.write(value.crossChain, into: &buf) } } @@ -16546,142 +16744,114 @@ public struct FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignMessageParams_lift(_ buf: RustBuffer) throws -> TrezorSignMessageParams { - return try FfiConverterTypeTrezorSignMessageParams.lift(buf) +public func FfiConverterTypeTrezorGetAddressParams_lift(_ buf: RustBuffer) throws -> TrezorGetAddressParams { + return try FfiConverterTypeTrezorGetAddressParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignMessageParams_lower(_ value: TrezorSignMessageParams) -> RustBuffer { - return FfiConverterTypeTrezorSignMessageParams.lower(value) +public func FfiConverterTypeTrezorGetAddressParams_lower(_ value: TrezorGetAddressParams) -> RustBuffer { + return FfiConverterTypeTrezorGetAddressParams.lower(value) } /** - * Parameters for signing a transaction. + * Parameters for getting a public key from the device. */ -public struct TrezorSignTxParams { - /** - * Transaction inputs - */ - public var inputs: [TrezorTxInput] +public struct TrezorGetPublicKeyParams { /** - * Transaction outputs + * BIP32 path (e.g., "m/84'/0'/0'") */ - public var outputs: [TrezorTxOutput] + public var path: String /** - * Coin network (inferred from input paths when omitted) + * Coin network (inferred from the path when omitted) */ public var coin: TrezorCoinType? /** - * Lock time (default: 0) - */ - public var lockTime: UInt32? - /** - * Version (default: 2) + * Whether to display on device for confirmation */ - public var version: UInt32? + public var showOnTrezor: Bool /** - * Previous transactions (for non-SegWit input verification) + * Allow an explicitly selected coin to differ from the path (default: false). */ - public var prevTxs: [TrezorPrevTx] + public var crossChain: Bool // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Transaction inputs - */inputs: [TrezorTxInput], - /** - * Transaction outputs - */outputs: [TrezorTxOutput], + * BIP32 path (e.g., "m/84'/0'/0'") + */path: String, /** - * Coin network (inferred from input paths when omitted) + * Coin network (inferred from the path when omitted) */coin: TrezorCoinType?, /** - * Lock time (default: 0) - */lockTime: UInt32?, - /** - * Version (default: 2) - */version: UInt32?, + * Whether to display on device for confirmation + */showOnTrezor: Bool, /** - * Previous transactions (for non-SegWit input verification) - */prevTxs: [TrezorPrevTx]) { - self.inputs = inputs - self.outputs = outputs + * Allow an explicitly selected coin to differ from the path (default: false). + */crossChain: Bool = false) { + self.path = path self.coin = coin - self.lockTime = lockTime - self.version = version - self.prevTxs = prevTxs + self.showOnTrezor = showOnTrezor + self.crossChain = crossChain } } #if compiler(>=6) -extension TrezorSignTxParams: Sendable {} +extension TrezorGetPublicKeyParams: Sendable {} #endif -extension TrezorSignTxParams: Equatable, Hashable { - public static func ==(lhs: TrezorSignTxParams, rhs: TrezorSignTxParams) -> Bool { - if lhs.inputs != rhs.inputs { - return false - } - if lhs.outputs != rhs.outputs { +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.lockTime != rhs.lockTime { - return false - } - if lhs.version != rhs.version { + if lhs.showOnTrezor != rhs.showOnTrezor { return false } - if lhs.prevTxs != rhs.prevTxs { + if lhs.crossChain != rhs.crossChain { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(inputs) - hasher.combine(outputs) + hasher.combine(path) hasher.combine(coin) - hasher.combine(lockTime) - hasher.combine(version) - hasher.combine(prevTxs) + hasher.combine(showOnTrezor) + hasher.combine(crossChain) } } -extension TrezorSignTxParams: Codable {} +extension TrezorGetPublicKeyParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignTxParams { +public struct FfiConverterTypeTrezorGetPublicKeyParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetPublicKeyParams { return - try TrezorSignTxParams( - inputs: FfiConverterSequenceTypeTrezorTxInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTrezorTxOutput.read(from: &buf), + try TrezorGetPublicKeyParams( + path: FfiConverterString.read(from: &buf), coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), - lockTime: FfiConverterOptionUInt32.read(from: &buf), - version: FfiConverterOptionUInt32.read(from: &buf), - prevTxs: FfiConverterSequenceTypeTrezorPrevTx.read(from: &buf) + showOnTrezor: FfiConverterBool.read(from: &buf), + crossChain: FfiConverterBool.read(from: &buf) ) } - public static func write(_ value: TrezorSignTxParams, into buf: inout [UInt8]) { - FfiConverterSequenceTypeTrezorTxInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeTrezorTxOutput.write(value.outputs, into: &buf) + public static func write(_ value: TrezorGetPublicKeyParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, 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) + FfiConverterBool.write(value.showOnTrezor, into: &buf) + FfiConverterBool.write(value.crossChain, into: &buf) } } @@ -16689,86 +16859,128 @@ public struct FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignTxParams_lift(_ buf: RustBuffer) throws -> TrezorSignTxParams { - return try FfiConverterTypeTrezorSignTxParams.lift(buf) +public func FfiConverterTypeTrezorGetPublicKeyParams_lift(_ buf: RustBuffer) throws -> TrezorGetPublicKeyParams { + return try FfiConverterTypeTrezorGetPublicKeyParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignTxParams_lower(_ value: TrezorSignTxParams) -> RustBuffer { - return FfiConverterTypeTrezorSignTxParams.lower(value) +public func FfiConverterTypeTrezorGetPublicKeyParams_lower(_ value: TrezorGetPublicKeyParams) -> RustBuffer { + return FfiConverterTypeTrezorGetPublicKeyParams.lower(value) } /** - * Response from signing a message. + * Previous transaction data (for non-SegWit input verification). */ -public struct TrezorSignedMessageResponse { +public struct TrezorPrevTx { /** - * Bitcoin address that signed the message + * Transaction hash (hex encoded) */ - public var address: String + public var hash: String /** - * Signature (base64 encoded) + * Transaction version */ - public var signature: String + public var version: UInt32 + /** + * Lock time + */ + public var lockTime: UInt32 + /** + * Transaction inputs + */ + public var inputs: [TrezorPrevTxInput] + /** + * Transaction outputs + */ + public var outputs: [TrezorPrevTxOutput] // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Bitcoin address that signed the message - */address: String, + * Transaction hash (hex encoded) + */hash: String, /** - * Signature (base64 encoded) - */signature: String) { - self.address = address - self.signature = signature + * Transaction version + */version: UInt32, + /** + * Lock time + */lockTime: UInt32, + /** + * Transaction inputs + */inputs: [TrezorPrevTxInput], + /** + * Transaction outputs + */outputs: [TrezorPrevTxOutput]) { + self.hash = hash + self.version = version + self.lockTime = lockTime + self.inputs = inputs + self.outputs = outputs } } #if compiler(>=6) -extension TrezorSignedMessageResponse: Sendable {} +extension TrezorPrevTx: Sendable {} #endif -extension TrezorSignedMessageResponse: Equatable, Hashable { - public static func ==(lhs: TrezorSignedMessageResponse, rhs: TrezorSignedMessageResponse) -> Bool { - if lhs.address != rhs.address { +extension TrezorPrevTx: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTx, rhs: TrezorPrevTx) -> Bool { + if lhs.hash != rhs.hash { return false } - if lhs.signature != rhs.signature { + if lhs.version != rhs.version { + return false + } + if lhs.lockTime != rhs.lockTime { + return false + } + if lhs.inputs != rhs.inputs { + return false + } + if lhs.outputs != rhs.outputs { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(signature) + hasher.combine(hash) + hasher.combine(version) + hasher.combine(lockTime) + hasher.combine(inputs) + hasher.combine(outputs) } } -extension TrezorSignedMessageResponse: Codable {} +extension TrezorPrevTx: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorSignedMessageResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedMessageResponse { +public struct FfiConverterTypeTrezorPrevTx: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTx { return - try TrezorSignedMessageResponse( - address: FfiConverterString.read(from: &buf), - signature: FfiConverterString.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: TrezorSignedMessageResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.signature, 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) } } @@ -16776,100 +16988,114 @@ public struct FfiConverterTypeTrezorSignedMessageResponse: FfiConverterRustBuffe #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignedMessageResponse_lift(_ buf: RustBuffer) throws -> TrezorSignedMessageResponse { - return try FfiConverterTypeTrezorSignedMessageResponse.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 FfiConverterTypeTrezorSignedMessageResponse_lower(_ value: TrezorSignedMessageResponse) -> RustBuffer { - return FfiConverterTypeTrezorSignedMessageResponse.lower(value) +public func FfiConverterTypeTrezorPrevTx_lower(_ value: TrezorPrevTx) -> RustBuffer { + return FfiConverterTypeTrezorPrevTx.lower(value) } /** - * Signed transaction result. + * Input of a previous transaction. */ -public struct TrezorSignedTx { +public struct TrezorPrevTxInput { /** - * Signatures for each input (hex encoded) + * Previous transaction hash (hex encoded) */ - public var signatures: [String] + public var prevHash: String /** - * Serialized transaction (hex) + * Previous output index */ - public var serializedTx: String + public var prevIndex: UInt32 /** - * Optional upstream transaction ID. Broadcasting is a separate Core operation. + * Script signature (hex encoded) */ - public var txid: String? + 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( /** - * Signatures for each input (hex encoded) - */signatures: [String], + * Previous transaction hash (hex encoded) + */prevHash: String, /** - * Serialized transaction (hex) - */serializedTx: String, + * Previous output index + */prevIndex: UInt32, /** - * Optional upstream transaction ID. Broadcasting is a separate Core operation. - */txid: String?) { - self.signatures = signatures - self.serializedTx = serializedTx - self.txid = txid + * 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 TrezorSignedTx: Sendable {} +extension TrezorPrevTxInput: Sendable {} #endif -extension TrezorSignedTx: Equatable, Hashable { - public static func ==(lhs: TrezorSignedTx, rhs: TrezorSignedTx) -> Bool { - if lhs.signatures != rhs.signatures { +extension TrezorPrevTxInput: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTxInput, rhs: TrezorPrevTxInput) -> Bool { + if lhs.prevHash != rhs.prevHash { return false } - if lhs.serializedTx != rhs.serializedTx { + if lhs.prevIndex != rhs.prevIndex { return false } - if lhs.txid != rhs.txid { + 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(signatures) - hasher.combine(serializedTx) - hasher.combine(txid) + hasher.combine(prevHash) + hasher.combine(prevIndex) + hasher.combine(scriptSig) + hasher.combine(sequence) } } -extension TrezorSignedTx: Codable {} +extension TrezorPrevTxInput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedTx { +public struct FfiConverterTypeTrezorPrevTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxInput { return - try TrezorSignedTx( - signatures: FfiConverterSequenceString.read(from: &buf), - serializedTx: FfiConverterString.read(from: &buf), - txid: FfiConverterOptionString.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: TrezorSignedTx, into buf: inout [UInt8]) { - FfiConverterSequenceString.write(value.signatures, into: &buf) - FfiConverterString.write(value.serializedTx, into: &buf) - FfiConverterOptionString.write(value.txid, into: &buf) + public static func write(_ value: 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) } } @@ -16877,114 +17103,86 @@ public struct FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignedTx_lift(_ buf: RustBuffer) throws -> TrezorSignedTx { - return try FfiConverterTypeTrezorSignedTx.lift(buf) +public func FfiConverterTypeTrezorPrevTxInput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxInput { + return try FfiConverterTypeTrezorPrevTxInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignedTx_lower(_ value: TrezorSignedTx) -> RustBuffer { - return FfiConverterTypeTrezorSignedTx.lower(value) +public func FfiConverterTypeTrezorPrevTxInput_lower(_ value: TrezorPrevTxInput) -> RustBuffer { + return FfiConverterTypeTrezorPrevTxInput.lower(value) } /** - * Result from a transport read operation + * Output of a previous transaction. */ -public struct TrezorTransportReadResult { - /** - * Whether the read succeeded - */ - public var success: Bool - /** - * Data read (empty on failure) - */ - public var data: Data +public struct TrezorPrevTxOutput { /** - * Error message (empty on success) + * Amount in satoshis */ - public var error: String + public var amount: UInt64 /** - * Structured error code (None on success or when the native error is generic) + * Script pubkey (hex encoded) */ - public var errorCode: TrezorTransportErrorCode? + public var scriptPubkey: String // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Whether the read succeeded - */success: Bool, - /** - * Data read (empty on failure) - */data: Data, - /** - * Error message (empty on success) - */error: String, + * Amount in satoshis + */amount: UInt64, /** - * Structured error code (None on success or when the native error is generic) - */errorCode: TrezorTransportErrorCode?) { - self.success = success - self.data = data - self.error = error - self.errorCode = errorCode + * Script pubkey (hex encoded) + */scriptPubkey: String) { + self.amount = amount + self.scriptPubkey = scriptPubkey } } #if compiler(>=6) -extension TrezorTransportReadResult: Sendable {} +extension TrezorPrevTxOutput: Sendable {} #endif -extension TrezorTransportReadResult: Equatable, Hashable { - public static func ==(lhs: TrezorTransportReadResult, rhs: TrezorTransportReadResult) -> Bool { - if lhs.success != rhs.success { - return false - } - if lhs.data != rhs.data { - return false - } - if lhs.error != rhs.error { +extension TrezorPrevTxOutput: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTxOutput, rhs: TrezorPrevTxOutput) -> Bool { + if lhs.amount != rhs.amount { return false } - if lhs.errorCode != rhs.errorCode { + if lhs.scriptPubkey != rhs.scriptPubkey { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(success) - hasher.combine(data) - hasher.combine(error) - hasher.combine(errorCode) + hasher.combine(amount) + hasher.combine(scriptPubkey) } } -extension TrezorTransportReadResult: Codable {} +extension TrezorPrevTxOutput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportReadResult { +public struct FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxOutput { return - try TrezorTransportReadResult( - success: FfiConverterBool.read(from: &buf), - data: FfiConverterData.read(from: &buf), - error: FfiConverterString.read(from: &buf), - errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) + try TrezorPrevTxOutput( + amount: FfiConverterUInt64.read(from: &buf), + scriptPubkey: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: TrezorTransportReadResult, into buf: inout [UInt8]) { - FfiConverterBool.write(value.success, into: &buf) - FfiConverterData.write(value.data, into: &buf) - FfiConverterString.write(value.error, into: &buf) - FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) + public static func write(_ value: TrezorPrevTxOutput, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterString.write(value.scriptPubkey, into: &buf) } } @@ -16992,100 +17190,198 @@ public struct FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportReadResult_lift(_ buf: RustBuffer) throws -> TrezorTransportReadResult { - return try FfiConverterTypeTrezorTransportReadResult.lift(buf) +public func FfiConverterTypeTrezorPrevTxOutput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxOutput { + return try FfiConverterTypeTrezorPrevTxOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportReadResult_lower(_ value: TrezorTransportReadResult) -> RustBuffer { - return FfiConverterTypeTrezorTransportReadResult.lower(value) +public func FfiConverterTypeTrezorPrevTxOutput_lower(_ value: TrezorPrevTxOutput) -> RustBuffer { + return FfiConverterTypeTrezorPrevTxOutput.lower(value) } /** - * Result from a transport write or open operation + * Public key response from device. */ -public struct TrezorTransportWriteResult { +public struct TrezorPublicKeyResponse { /** - * Whether the operation succeeded + * Normalized xpub/tpub. Preserve the selected account type when importing. */ - public var success: Bool + public var xpub: String /** - * Error message (empty on success) + * Firmware SLIP-132 key for BIP-49/BIP-84, or a Taproot descriptor. */ - public var error: String + public var xpubSegwit: String? /** - * Structured error code (None on success or when the native error is generic) + * Output descriptor returned by the firmware, when available. */ - public var errorCode: TrezorTransportErrorCode? + public var descriptor: String? + /** + * Key or descriptor intended for display, not for extended-key import. + */ + public var displayablePublicKey: String + /** + * The serialized path (e.g., "m/84'/0'/0'") + */ + public var path: String + /** + * Compressed public key (hex encoded) + */ + public var publicKey: String + /** + * Chain code (hex encoded) + */ + public var chainCode: String + /** + * Parent key fingerprint + */ + public var fingerprint: UInt32 + /** + * Derivation depth + */ + public var depth: UInt32 + /** + * Master root fingerprint (from the device's master seed) + */ + public var rootFingerprint: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Whether the operation succeeded - */success: Bool, + * Normalized xpub/tpub. Preserve the selected account type when importing. + */xpub: String, /** - * Error message (empty on success) - */error: String, + * Firmware SLIP-132 key for BIP-49/BIP-84, or a Taproot descriptor. + */xpubSegwit: String?, /** - * Structured error code (None on success or when the native error is generic) - */errorCode: TrezorTransportErrorCode?) { - self.success = success - self.error = error - self.errorCode = errorCode - } -} - -#if compiler(>=6) -extension TrezorTransportWriteResult: Sendable {} -#endif - - -extension TrezorTransportWriteResult: Equatable, Hashable { - public static func ==(lhs: TrezorTransportWriteResult, rhs: TrezorTransportWriteResult) -> Bool { - if lhs.success != rhs.success { - return false - } - if lhs.error != rhs.error { + * Output descriptor returned by the firmware, when available. + */descriptor: String?, + /** + * Key or descriptor intended for display, not for extended-key import. + */displayablePublicKey: String, + /** + * The serialized path (e.g., "m/84'/0'/0'") + */path: String, + /** + * Compressed public key (hex encoded) + */publicKey: String, + /** + * Chain code (hex encoded) + */chainCode: String, + /** + * Parent key fingerprint + */fingerprint: UInt32, + /** + * Derivation depth + */depth: UInt32, + /** + * Master root fingerprint (from the device's master seed) + */rootFingerprint: UInt32?) { + self.xpub = xpub + self.xpubSegwit = xpubSegwit + self.descriptor = descriptor + self.displayablePublicKey = displayablePublicKey + self.path = path + self.publicKey = publicKey + self.chainCode = chainCode + self.fingerprint = fingerprint + self.depth = depth + self.rootFingerprint = rootFingerprint + } +} + +#if compiler(>=6) +extension TrezorPublicKeyResponse: Sendable {} +#endif + + +extension TrezorPublicKeyResponse: Equatable, Hashable { + public static func ==(lhs: TrezorPublicKeyResponse, rhs: TrezorPublicKeyResponse) -> Bool { + if lhs.xpub != rhs.xpub { return false } - if lhs.errorCode != rhs.errorCode { + if lhs.xpubSegwit != rhs.xpubSegwit { + return false + } + if lhs.descriptor != rhs.descriptor { + return false + } + if lhs.displayablePublicKey != rhs.displayablePublicKey { + return false + } + if lhs.path != rhs.path { + return false + } + if lhs.publicKey != rhs.publicKey { + return false + } + if lhs.chainCode != rhs.chainCode { + return false + } + if lhs.fingerprint != rhs.fingerprint { + return false + } + if lhs.depth != rhs.depth { + return false + } + if lhs.rootFingerprint != rhs.rootFingerprint { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(success) - hasher.combine(error) - hasher.combine(errorCode) + hasher.combine(xpub) + hasher.combine(xpubSegwit) + hasher.combine(descriptor) + hasher.combine(displayablePublicKey) + hasher.combine(path) + hasher.combine(publicKey) + hasher.combine(chainCode) + hasher.combine(fingerprint) + hasher.combine(depth) + hasher.combine(rootFingerprint) } } -extension TrezorTransportWriteResult: Codable {} +extension TrezorPublicKeyResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportWriteResult { +public struct FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPublicKeyResponse { return - try TrezorTransportWriteResult( - success: FfiConverterBool.read(from: &buf), - error: FfiConverterString.read(from: &buf), - errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) + try TrezorPublicKeyResponse( + xpub: FfiConverterString.read(from: &buf), + xpubSegwit: FfiConverterOptionString.read(from: &buf), + descriptor: FfiConverterOptionString.read(from: &buf), + displayablePublicKey: 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: TrezorTransportWriteResult, into buf: inout [UInt8]) { - FfiConverterBool.write(value.success, into: &buf) - FfiConverterString.write(value.error, into: &buf) - FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) + public static func write(_ value: TrezorPublicKeyResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.xpub, into: &buf) + FfiConverterOptionString.write(value.xpubSegwit, into: &buf) + FfiConverterOptionString.write(value.descriptor, into: &buf) + FfiConverterString.write(value.displayablePublicKey, 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) } } @@ -17093,170 +17389,114 @@ public struct FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportWriteResult_lift(_ buf: RustBuffer) throws -> TrezorTransportWriteResult { - return try FfiConverterTypeTrezorTransportWriteResult.lift(buf) +public func FfiConverterTypeTrezorPublicKeyResponse_lift(_ buf: RustBuffer) throws -> TrezorPublicKeyResponse { + return try FfiConverterTypeTrezorPublicKeyResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportWriteResult_lower(_ value: TrezorTransportWriteResult) -> RustBuffer { - return FfiConverterTypeTrezorTransportWriteResult.lower(value) +public func FfiConverterTypeTrezorPublicKeyResponse_lower(_ value: TrezorPublicKeyResponse) -> RustBuffer { + return FfiConverterTypeTrezorPublicKeyResponse.lower(value) } /** - * Transaction input for signing. + * Parameters for signing a message. */ -public struct TrezorTxInput { - /** - * Previous transaction hash (hex, 32 bytes) - */ - public var prevHash: String - /** - * Previous output index - */ - public var prevIndex: UInt32 +public struct TrezorSignMessageParams { /** - * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") + * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") */ public var path: String /** - * Amount in satoshis - */ - public var amount: UInt64 - /** - * Script type - */ - public var scriptType: TrezorScriptType - /** - * Sequence number (default: 0xFFFFFFFD for RBF) + * Message to sign */ - public var sequence: UInt32? + public var message: String /** - * Original transaction hash for RBF replacement (hex encoded) + * Coin network (inferred from the path when omitted) */ - public var origHash: String? + public var coin: TrezorCoinType? /** - * Original input index for RBF replacement + * Allow an explicitly selected coin to differ from the path (default: false). */ - public var origIndex: UInt32? + public var crossChain: Bool // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Previous transaction hash (hex, 32 bytes) - */prevHash: String, - /** - * Previous output index - */prevIndex: UInt32, - /** - * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") + * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") */path: String, /** - * Amount in satoshis - */amount: UInt64, - /** - * Script type - */scriptType: TrezorScriptType, - /** - * Sequence number (default: 0xFFFFFFFD for RBF) - */sequence: UInt32?, + * Message to sign + */message: String, /** - * Original transaction hash for RBF replacement (hex encoded) - */origHash: String?, + * Coin network (inferred from the path when omitted) + */coin: TrezorCoinType?, /** - * Original input index for RBF replacement - */origIndex: UInt32?) { - self.prevHash = prevHash - self.prevIndex = prevIndex + * Allow an explicitly selected coin to differ from the path (default: false). + */crossChain: Bool = false) { self.path = path - self.amount = amount - self.scriptType = scriptType - self.sequence = sequence - self.origHash = origHash - self.origIndex = origIndex + self.message = message + self.coin = coin + self.crossChain = crossChain } } #if compiler(>=6) -extension TrezorTxInput: Sendable {} +extension TrezorSignMessageParams: Sendable {} #endif -extension TrezorTxInput: Equatable, Hashable { - public static func ==(lhs: TrezorTxInput, rhs: TrezorTxInput) -> Bool { - if lhs.prevHash != rhs.prevHash { - return false - } - if lhs.prevIndex != rhs.prevIndex { - return false - } +extension TrezorSignMessageParams: Equatable, Hashable { + public static func ==(lhs: TrezorSignMessageParams, rhs: TrezorSignMessageParams) -> Bool { if lhs.path != rhs.path { return false } - if lhs.amount != rhs.amount { - return false - } - if lhs.scriptType != rhs.scriptType { - return false - } - if lhs.sequence != rhs.sequence { + if lhs.message != rhs.message { return false } - if lhs.origHash != rhs.origHash { + if lhs.coin != rhs.coin { return false } - if lhs.origIndex != rhs.origIndex { + if lhs.crossChain != rhs.crossChain { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(prevHash) - hasher.combine(prevIndex) hasher.combine(path) - hasher.combine(amount) - hasher.combine(scriptType) - hasher.combine(sequence) - hasher.combine(origHash) - hasher.combine(origIndex) + hasher.combine(message) + hasher.combine(coin) + hasher.combine(crossChain) } } -extension TrezorTxInput: Codable {} +extension TrezorSignMessageParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxInput { +public struct FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignMessageParams { return - try TrezorTxInput( - prevHash: FfiConverterString.read(from: &buf), - prevIndex: FfiConverterUInt32.read(from: &buf), + try TrezorSignMessageParams( 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) + message: FfiConverterString.read(from: &buf), + coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), + crossChain: FfiConverterBool.read(from: &buf) ) } - public static func write(_ value: TrezorTxInput, into buf: inout [UInt8]) { - FfiConverterString.write(value.prevHash, into: &buf) - FfiConverterUInt32.write(value.prevIndex, into: &buf) + public static func write(_ value: TrezorSignMessageParams, into buf: inout [UInt8]) { 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) + FfiConverterString.write(value.message, into: &buf) + FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + FfiConverterBool.write(value.crossChain, into: &buf) } } @@ -17264,156 +17504,142 @@ public struct FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxInput_lift(_ buf: RustBuffer) throws -> TrezorTxInput { - return try FfiConverterTypeTrezorTxInput.lift(buf) +public func FfiConverterTypeTrezorSignMessageParams_lift(_ buf: RustBuffer) throws -> TrezorSignMessageParams { + return try FfiConverterTypeTrezorSignMessageParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxInput_lower(_ value: TrezorTxInput) -> RustBuffer { - return FfiConverterTypeTrezorTxInput.lower(value) +public func FfiConverterTypeTrezorSignMessageParams_lower(_ value: TrezorSignMessageParams) -> RustBuffer { + return FfiConverterTypeTrezorSignMessageParams.lower(value) } /** - * Transaction output for signing. + * Parameters for signing a transaction. */ -public struct TrezorTxOutput { - /** - * Destination address (for external outputs) - */ - public var address: String? +public struct TrezorSignTxParams { /** - * BIP32 path (for change outputs) + * Transaction inputs */ - public var path: String? + public var inputs: [TrezorTxInput] /** - * Amount in satoshis + * Transaction outputs */ - public var amount: UInt64 + public var outputs: [TrezorTxOutput] /** - * Script type (for change outputs) + * Coin network (inferred from input paths when omitted) */ - public var scriptType: TrezorScriptType? + public var coin: TrezorCoinType? /** - * OP_RETURN data (hex encoded, for data outputs) + * Lock time (default: 0) */ - public var opReturnData: String? + public var lockTime: UInt32? /** - * Original transaction hash for RBF replacement (hex encoded) + * Version (default: 2) */ - public var origHash: String? + public var version: UInt32? /** - * Original output index for RBF replacement + * Previous transactions (for non-SegWit input verification) */ - public var origIndex: UInt32? + public var prevTxs: [TrezorPrevTx] // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Destination address (for external outputs) - */address: String?, - /** - * BIP32 path (for change outputs) - */path: String?, + * Transaction inputs + */inputs: [TrezorTxInput], /** - * Amount in satoshis - */amount: UInt64, + * Transaction outputs + */outputs: [TrezorTxOutput], /** - * Script type (for change outputs) - */scriptType: TrezorScriptType?, + * Coin network (inferred from input paths when omitted) + */coin: TrezorCoinType?, /** - * OP_RETURN data (hex encoded, for data outputs) - */opReturnData: String?, + * Lock time (default: 0) + */lockTime: UInt32?, /** - * Original transaction hash for RBF replacement (hex encoded) - */origHash: String?, + * Version (default: 2) + */version: UInt32?, /** - * 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 + * 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 TrezorTxOutput: Sendable {} +extension TrezorSignTxParams: Sendable {} #endif -extension TrezorTxOutput: Equatable, Hashable { - public static func ==(lhs: TrezorTxOutput, rhs: TrezorTxOutput) -> Bool { - if lhs.address != rhs.address { - return false - } - if lhs.path != rhs.path { +extension TrezorSignTxParams: Equatable, Hashable { + public static func ==(lhs: TrezorSignTxParams, rhs: TrezorSignTxParams) -> Bool { + if lhs.inputs != rhs.inputs { return false } - if lhs.amount != rhs.amount { + if lhs.outputs != rhs.outputs { return false } - if lhs.scriptType != rhs.scriptType { + if lhs.coin != rhs.coin { return false } - if lhs.opReturnData != rhs.opReturnData { + if lhs.lockTime != rhs.lockTime { return false } - if lhs.origHash != rhs.origHash { + if lhs.version != rhs.version { return false } - if lhs.origIndex != rhs.origIndex { + if lhs.prevTxs != rhs.prevTxs { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(path) - hasher.combine(amount) - hasher.combine(scriptType) - hasher.combine(opReturnData) - hasher.combine(origHash) - hasher.combine(origIndex) + hasher.combine(inputs) + hasher.combine(outputs) + hasher.combine(coin) + hasher.combine(lockTime) + hasher.combine(version) + hasher.combine(prevTxs) } } -extension TrezorTxOutput: Codable {} +extension TrezorSignTxParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxOutput { +public struct FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignTxParams { return - try TrezorTxOutput( - address: FfiConverterOptionString.read(from: &buf), - path: FfiConverterOptionString.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - scriptType: FfiConverterOptionTypeTrezorScriptType.read(from: &buf), - opReturnData: FfiConverterOptionString.read(from: &buf), - origHash: FfiConverterOptionString.read(from: &buf), - origIndex: FfiConverterOptionUInt32.read(from: &buf) + try 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: TrezorTxOutput, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.address, into: &buf) - FfiConverterOptionString.write(value.path, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterOptionTypeTrezorScriptType.write(value.scriptType, into: &buf) - FfiConverterOptionString.write(value.opReturnData, into: &buf) - FfiConverterOptionString.write(value.origHash, into: &buf) - FfiConverterOptionUInt32.write(value.origIndex, into: &buf) + public static func write(_ value: 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) } } @@ -17421,22 +17647,22 @@ public struct FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxOutput_lift(_ buf: RustBuffer) throws -> TrezorTxOutput { - return try FfiConverterTypeTrezorTxOutput.lift(buf) +public func FfiConverterTypeTrezorSignTxParams_lift(_ buf: RustBuffer) throws -> TrezorSignTxParams { + return try FfiConverterTypeTrezorSignTxParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxOutput_lower(_ value: TrezorTxOutput) -> RustBuffer { - return FfiConverterTypeTrezorTxOutput.lower(value) +public func FfiConverterTypeTrezorSignTxParams_lower(_ value: TrezorSignTxParams) -> RustBuffer { + return FfiConverterTypeTrezorSignTxParams.lower(value) } /** - * Parameters for verifying a message signature. + * Response from signing a message. */ -public struct TrezorVerifyMessageParams { +public struct TrezorSignedMessageResponse { /** * Bitcoin address that signed the message */ @@ -17445,14 +17671,6 @@ public struct TrezorVerifyMessageParams { * Signature (base64 encoded) */ public var signature: String - /** - * Original message - */ - public var message: String - /** - * Coin network (default: Bitcoin) - */ - public var coin: TrezorCoinType? // Default memberwise initializers are never public by default, so we // declare one manually. @@ -17462,73 +17680,53 @@ public struct TrezorVerifyMessageParams { */address: String, /** * Signature (base64 encoded) - */signature: String, - /** - * Original message - */message: String, - /** - * Coin network (default: Bitcoin) - */coin: TrezorCoinType?) { + */signature: String) { self.address = address self.signature = signature - self.message = message - self.coin = coin } } #if compiler(>=6) -extension TrezorVerifyMessageParams: Sendable {} +extension TrezorSignedMessageResponse: Sendable {} #endif -extension TrezorVerifyMessageParams: Equatable, Hashable { - public static func ==(lhs: TrezorVerifyMessageParams, rhs: TrezorVerifyMessageParams) -> Bool { +extension TrezorSignedMessageResponse: Equatable, Hashable { + public static func ==(lhs: TrezorSignedMessageResponse, rhs: TrezorSignedMessageResponse) -> Bool { if lhs.address != rhs.address { return false } if lhs.signature != rhs.signature { return false } - if lhs.message != rhs.message { - return false - } - if lhs.coin != rhs.coin { - return false - } return true } public func hash(into hasher: inout Hasher) { hasher.combine(address) hasher.combine(signature) - hasher.combine(message) - hasher.combine(coin) } } -extension TrezorVerifyMessageParams: Codable {} +extension TrezorSignedMessageResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorVerifyMessageParams { +public struct FfiConverterTypeTrezorSignedMessageResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedMessageResponse { return - try TrezorVerifyMessageParams( + try TrezorSignedMessageResponse( address: FfiConverterString.read(from: &buf), - signature: FfiConverterString.read(from: &buf), - message: FfiConverterString.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf) + signature: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: TrezorVerifyMessageParams, into buf: inout [UInt8]) { + public static func write(_ value: TrezorSignedMessageResponse, 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) } } @@ -17536,128 +17734,100 @@ public struct FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorVerifyMessageParams_lift(_ buf: RustBuffer) throws -> TrezorVerifyMessageParams { - return try FfiConverterTypeTrezorVerifyMessageParams.lift(buf) +public func FfiConverterTypeTrezorSignedMessageResponse_lift(_ buf: RustBuffer) throws -> TrezorSignedMessageResponse { + return try FfiConverterTypeTrezorSignedMessageResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorVerifyMessageParams_lower(_ value: TrezorVerifyMessageParams) -> RustBuffer { - return FfiConverterTypeTrezorVerifyMessageParams.lower(value) +public func FfiConverterTypeTrezorSignedMessageResponse_lower(_ value: TrezorSignedMessageResponse) -> RustBuffer { + return FfiConverterTypeTrezorSignedMessageResponse.lower(value) } /** - * A transaction input with full details. + * Signed transaction result. */ -public struct TxDetailInput { - /** - * Previous output transaction ID (hex) - */ - public var txid: String - /** - * Previous output index - */ - public var vout: UInt32 +public struct TrezorSignedTx { /** - * Sequence number + * Signatures for each input (hex encoded) */ - public var sequence: UInt32 + public var signatures: [String] /** - * Script signature (hex-encoded) + * Serialized transaction (hex) */ - public var scriptSig: String + public var serializedTx: String /** - * Witness stack (each element hex-encoded) + * Optional upstream transaction ID. Broadcasting is a separate Core operation. */ - public var witness: [String] + public var txid: String? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Previous output transaction ID (hex) - */txid: String, + * Signatures for each input (hex encoded) + */signatures: [String], /** - * Previous output index - */vout: UInt32, + * Serialized transaction (hex) + */serializedTx: String, /** - * Sequence number - */sequence: UInt32, - /** - * Script signature (hex-encoded) - */scriptSig: String, - /** - * Witness stack (each element hex-encoded) - */witness: [String]) { + * Optional upstream transaction ID. Broadcasting is a separate Core operation. + */txid: String?) { + self.signatures = signatures + self.serializedTx = serializedTx self.txid = txid - self.vout = vout - self.sequence = sequence - self.scriptSig = scriptSig - self.witness = witness } } #if compiler(>=6) -extension TxDetailInput: Sendable {} +extension TrezorSignedTx: Sendable {} #endif -extension TxDetailInput: Equatable, Hashable { - public static func ==(lhs: TxDetailInput, rhs: TxDetailInput) -> Bool { - if lhs.txid != rhs.txid { - return false - } - if lhs.vout != rhs.vout { - return false - } - if lhs.sequence != rhs.sequence { +extension TrezorSignedTx: Equatable, Hashable { + public static func ==(lhs: TrezorSignedTx, rhs: TrezorSignedTx) -> Bool { + if lhs.signatures != rhs.signatures { return false } - if lhs.scriptSig != rhs.scriptSig { + if lhs.serializedTx != rhs.serializedTx { return false } - if lhs.witness != rhs.witness { + 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) - hasher.combine(vout) - hasher.combine(sequence) - hasher.combine(scriptSig) - hasher.combine(witness) } } -extension TxDetailInput: Codable {} +extension TrezorSignedTx: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxDetailInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailInput { +public struct FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedTx { return - try TxDetailInput( - txid: FfiConverterString.read(from: &buf), - vout: FfiConverterUInt32.read(from: &buf), - sequence: FfiConverterUInt32.read(from: &buf), - scriptSig: FfiConverterString.read(from: &buf), - witness: FfiConverterSequenceString.read(from: &buf) + try TrezorSignedTx( + signatures: FfiConverterSequenceString.read(from: &buf), + serializedTx: FfiConverterString.read(from: &buf), + txid: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: TxDetailInput, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt32.write(value.vout, into: &buf) - FfiConverterUInt32.write(value.sequence, into: &buf) - FfiConverterString.write(value.scriptSig, into: &buf) - FfiConverterSequenceString.write(value.witness, into: &buf) + public static func write(_ value: TrezorSignedTx, into buf: inout [UInt8]) { + FfiConverterSequenceString.write(value.signatures, into: &buf) + FfiConverterString.write(value.serializedTx, into: &buf) + FfiConverterOptionString.write(value.txid, into: &buf) } } @@ -17665,114 +17835,114 @@ public struct FfiConverterTypeTxDetailInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailInput_lift(_ buf: RustBuffer) throws -> TxDetailInput { - return try FfiConverterTypeTxDetailInput.lift(buf) +public func FfiConverterTypeTrezorSignedTx_lift(_ buf: RustBuffer) throws -> TrezorSignedTx { + return try FfiConverterTypeTrezorSignedTx.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailInput_lower(_ value: TxDetailInput) -> RustBuffer { - return FfiConverterTypeTxDetailInput.lower(value) +public func FfiConverterTypeTrezorSignedTx_lower(_ value: TrezorSignedTx) -> RustBuffer { + return FfiConverterTypeTrezorSignedTx.lower(value) } /** - * A transaction output with full details. + * Result from a transport read operation */ -public struct TxDetailOutput { +public struct TrezorTransportReadResult { /** - * Output value in sats + * Whether the read succeeded */ - public var value: UInt64 + public var success: Bool /** - * Script public key (hex-encoded) + * Data read (empty on failure) */ - public var scriptPubkey: String + public var data: Data /** - * Decoded address (None if script is not decodable to an address) + * Error message (empty on success) */ - public var address: String? + public var error: String /** - * Whether this output belongs to the queried wallet + * Structured error code (None on success or when the native error is generic) */ - public var isMine: Bool + public var errorCode: TrezorTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Output value in sats - */value: UInt64, + * Whether the read succeeded + */success: Bool, /** - * Script public key (hex-encoded) - */scriptPubkey: String, + * Data read (empty on failure) + */data: Data, /** - * Decoded address (None if script is not decodable to an address) - */address: String?, + * Error message (empty on success) + */error: String, /** - * Whether this output belongs to the queried wallet - */isMine: Bool) { - self.value = value - self.scriptPubkey = scriptPubkey - self.address = address - self.isMine = isMine + * Structured error code (None on success or when the native error is generic) + */errorCode: TrezorTransportErrorCode?) { + self.success = success + self.data = data + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension TxDetailOutput: Sendable {} +extension TrezorTransportReadResult: Sendable {} #endif -extension TxDetailOutput: Equatable, Hashable { - public static func ==(lhs: TxDetailOutput, rhs: TxDetailOutput) -> Bool { - if lhs.value != rhs.value { +extension TrezorTransportReadResult: Equatable, Hashable { + public static func ==(lhs: TrezorTransportReadResult, rhs: TrezorTransportReadResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.scriptPubkey != rhs.scriptPubkey { + if lhs.data != rhs.data { return false } - if lhs.address != rhs.address { + if lhs.error != rhs.error { return false } - if lhs.isMine != rhs.isMine { + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(value) - hasher.combine(scriptPubkey) - hasher.combine(address) - hasher.combine(isMine) + hasher.combine(success) + hasher.combine(data) + hasher.combine(error) + hasher.combine(errorCode) } } -extension TxDetailOutput: Codable {} +extension TrezorTransportReadResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxDetailOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailOutput { +public struct FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportReadResult { return - try TxDetailOutput( - value: FfiConverterUInt64.read(from: &buf), - scriptPubkey: FfiConverterString.read(from: &buf), - address: FfiConverterOptionString.read(from: &buf), - isMine: FfiConverterBool.read(from: &buf) + try TrezorTransportReadResult( + success: FfiConverterBool.read(from: &buf), + data: FfiConverterData.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: TxDetailOutput, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.value, into: &buf) - FfiConverterString.write(value.scriptPubkey, into: &buf) - FfiConverterOptionString.write(value.address, into: &buf) - FfiConverterBool.write(value.isMine, into: &buf) + public static func write(_ value: TrezorTransportReadResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterData.write(value.data, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -17780,128 +17950,100 @@ public struct FfiConverterTypeTxDetailOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailOutput_lift(_ buf: RustBuffer) throws -> TxDetailOutput { - return try FfiConverterTypeTxDetailOutput.lift(buf) +public func FfiConverterTypeTrezorTransportReadResult_lift(_ buf: RustBuffer) throws -> TrezorTransportReadResult { + return try FfiConverterTypeTrezorTransportReadResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailOutput_lower(_ value: TxDetailOutput) -> RustBuffer { - return FfiConverterTypeTxDetailOutput.lower(value) +public func FfiConverterTypeTrezorTransportReadResult_lower(_ value: TrezorTransportReadResult) -> RustBuffer { + return FfiConverterTypeTrezorTransportReadResult.lower(value) } /** - * Details about a transaction input. + * Result from a transport write or open operation */ -public struct TxInput { - /** - * The transaction ID of the previous output being spent. - */ - public var txid: String - /** - * The output index of the previous output being spent. - */ - public var vout: UInt32 +public struct TrezorTransportWriteResult { /** - * The script signature (hex-encoded). + * Whether the operation succeeded */ - public var scriptsig: String + public var success: Bool /** - * The witness stack (hex-encoded strings). + * Error message (empty on success) */ - public var witness: [String] + public var error: String /** - * The sequence number. + * Structured error code (None on success or when the native error is generic) */ - public var sequence: UInt32 + public var errorCode: TrezorTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * The transaction ID of the previous output being spent. - */txid: String, - /** - * The output index of the previous output being spent. - */vout: UInt32, - /** - * The script signature (hex-encoded). - */scriptsig: String, + * Whether the operation succeeded + */success: Bool, /** - * The witness stack (hex-encoded strings). - */witness: [String], + * Error message (empty on success) + */error: String, /** - * The sequence number. - */sequence: UInt32) { - self.txid = txid - self.vout = vout - self.scriptsig = scriptsig - self.witness = witness - self.sequence = sequence + * Structured error code (None on success or when the native error is generic) + */errorCode: TrezorTransportErrorCode?) { + self.success = success + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension TxInput: Sendable {} +extension TrezorTransportWriteResult: Sendable {} #endif -extension TxInput: Equatable, Hashable { - public static func ==(lhs: TxInput, rhs: TxInput) -> Bool { - if lhs.txid != rhs.txid { - return false - } - if lhs.vout != rhs.vout { - return false - } - if lhs.scriptsig != rhs.scriptsig { +extension TrezorTransportWriteResult: Equatable, Hashable { + public static func ==(lhs: TrezorTransportWriteResult, rhs: TrezorTransportWriteResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.witness != rhs.witness { + if lhs.error != rhs.error { return false } - if lhs.sequence != rhs.sequence { + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(vout) - hasher.combine(scriptsig) - hasher.combine(witness) - hasher.combine(sequence) + hasher.combine(success) + hasher.combine(error) + hasher.combine(errorCode) } } -extension TxInput: Codable {} +extension TrezorTransportWriteResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxInput { +public struct FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportWriteResult { return - try TxInput( - txid: FfiConverterString.read(from: &buf), - vout: FfiConverterUInt32.read(from: &buf), - scriptsig: FfiConverterString.read(from: &buf), - witness: FfiConverterSequenceString.read(from: &buf), - sequence: FfiConverterUInt32.read(from: &buf) + try TrezorTransportWriteResult( + success: FfiConverterBool.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: TxInput, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt32.write(value.vout, into: &buf) - FfiConverterString.write(value.scriptsig, into: &buf) - FfiConverterSequenceString.write(value.witness, into: &buf) - FfiConverterUInt32.write(value.sequence, into: &buf) + public static func write(_ value: TrezorTransportWriteResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -17909,128 +18051,170 @@ public struct FfiConverterTypeTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxInput_lift(_ buf: RustBuffer) throws -> TxInput { - return try FfiConverterTypeTxInput.lift(buf) +public func FfiConverterTypeTrezorTransportWriteResult_lift(_ buf: RustBuffer) throws -> TrezorTransportWriteResult { + return try FfiConverterTypeTrezorTransportWriteResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxInput_lower(_ value: TxInput) -> RustBuffer { - return FfiConverterTypeTxInput.lower(value) +public func FfiConverterTypeTrezorTransportWriteResult_lower(_ value: TrezorTransportWriteResult) -> RustBuffer { + return FfiConverterTypeTrezorTransportWriteResult.lower(value) } /** - * Details about a transaction output. + * Transaction input for signing. */ -public struct TxOutput { +public struct TrezorTxInput { /** - * The script public key (hex-encoded). + * Previous transaction hash (hex, 32 bytes) */ - public var scriptpubkey: String + public var prevHash: String /** - * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + * Previous output index */ - public var scriptpubkeyType: String? + public var prevIndex: UInt32 /** - * The address corresponding to this script (if decodable). + * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") */ - public var scriptpubkeyAddress: String? + public var path: String /** - * The value in satoshis. + * Amount in satoshis */ - public var value: Int64 + public var amount: UInt64 /** - * The output index in the transaction. + * Script type */ - public var n: UInt32 + public var scriptType: TrezorScriptType + /** + * Sequence number (default: 0xFFFFFFFD for RBF) + */ + public var sequence: UInt32? + /** + * Original transaction hash for RBF replacement (hex encoded) + */ + public var origHash: String? + /** + * Original input index for RBF replacement + */ + public var origIndex: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * The script public key (hex-encoded). - */scriptpubkey: String, + * Previous transaction hash (hex, 32 bytes) + */prevHash: String, /** - * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). - */scriptpubkeyType: String?, + * Previous output index + */prevIndex: UInt32, /** - * The address corresponding to this script (if decodable). - */scriptpubkeyAddress: String?, + * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") + */path: String, /** - * The value in satoshis. - */value: Int64, + * Amount in satoshis + */amount: UInt64, /** - * The output index in the transaction. - */n: UInt32) { - self.scriptpubkey = scriptpubkey - self.scriptpubkeyType = scriptpubkeyType - self.scriptpubkeyAddress = scriptpubkeyAddress - self.value = value - self.n = n + * Script type + */scriptType: TrezorScriptType, + /** + * Sequence number (default: 0xFFFFFFFD for RBF) + */sequence: UInt32?, + /** + * Original transaction hash for RBF replacement (hex encoded) + */origHash: String?, + /** + * Original input index for RBF replacement + */origIndex: UInt32?) { + self.prevHash = prevHash + self.prevIndex = prevIndex + self.path = path + self.amount = amount + self.scriptType = scriptType + self.sequence = sequence + self.origHash = origHash + self.origIndex = origIndex } } #if compiler(>=6) -extension TxOutput: Sendable {} +extension TrezorTxInput: Sendable {} #endif -extension TxOutput: Equatable, Hashable { - public static func ==(lhs: TxOutput, rhs: TxOutput) -> Bool { - if lhs.scriptpubkey != rhs.scriptpubkey { +extension TrezorTxInput: Equatable, Hashable { + public static func ==(lhs: TrezorTxInput, rhs: TrezorTxInput) -> Bool { + if lhs.prevHash != rhs.prevHash { return false } - if lhs.scriptpubkeyType != rhs.scriptpubkeyType { + if lhs.prevIndex != rhs.prevIndex { return false } - if lhs.scriptpubkeyAddress != rhs.scriptpubkeyAddress { + if lhs.path != rhs.path { return false } - if lhs.value != rhs.value { + if lhs.amount != rhs.amount { return false } - if lhs.n != rhs.n { + if lhs.scriptType != rhs.scriptType { + return false + } + if lhs.sequence != rhs.sequence { + return false + } + if lhs.origHash != rhs.origHash { + return false + } + if lhs.origIndex != rhs.origIndex { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(scriptpubkey) - hasher.combine(scriptpubkeyType) - hasher.combine(scriptpubkeyAddress) - hasher.combine(value) - hasher.combine(n) + 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 TxOutput: Codable {} +extension TrezorTxInput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxOutput { +public struct FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxInput { return - try TxOutput( - scriptpubkey: FfiConverterString.read(from: &buf), - scriptpubkeyType: FfiConverterOptionString.read(from: &buf), - scriptpubkeyAddress: FfiConverterOptionString.read(from: &buf), - value: FfiConverterInt64.read(from: &buf), - n: FfiConverterUInt32.read(from: &buf) + try 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: TxOutput, into buf: inout [UInt8]) { - FfiConverterString.write(value.scriptpubkey, into: &buf) - FfiConverterOptionString.write(value.scriptpubkeyType, into: &buf) - FfiConverterOptionString.write(value.scriptpubkeyAddress, into: &buf) - FfiConverterInt64.write(value.value, into: &buf) - FfiConverterUInt32.write(value.n, into: &buf) + public static func write(_ value: 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) } } @@ -18038,100 +18222,156 @@ public struct FfiConverterTypeTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxOutput_lift(_ buf: RustBuffer) throws -> TxOutput { - return try FfiConverterTypeTxOutput.lift(buf) +public func FfiConverterTypeTrezorTxInput_lift(_ buf: RustBuffer) throws -> TrezorTxInput { + return try FfiConverterTypeTrezorTxInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxOutput_lower(_ value: TxOutput) -> RustBuffer { - return FfiConverterTypeTxOutput.lower(value) +public func FfiConverterTypeTrezorTxInput_lower(_ value: TrezorTxInput) -> RustBuffer { + return FfiConverterTypeTrezorTxInput.lower(value) } /** - * Current state after accepting a scanned UR frame. + * Transaction output for signing. */ -public struct UrDecoderStatus { +public struct TrezorTxOutput { /** - * Estimated completion from 0.0 through 1.0. + * Destination address (for external outputs) */ - public var progress: Double + public var address: String? /** - * Fountain source-fragment count, or 1 for a single-part UR. + * BIP32 path (for change outputs) */ - public var fragmentCount: UInt32 + public var path: String? /** - * Present once the complete message has been decoded. + * Amount in satoshis */ - public var payload: UrPayload? + public var amount: UInt64 + /** + * Script type (for change outputs) + */ + public var scriptType: TrezorScriptType? + /** + * OP_RETURN data (hex encoded, for data outputs) + */ + 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( /** - * Estimated completion from 0.0 through 1.0. - */progress: Double, + * Destination address (for external outputs) + */address: String?, /** - * Fountain source-fragment count, or 1 for a single-part UR. - */fragmentCount: UInt32, + * BIP32 path (for change outputs) + */path: String?, /** - * Present once the complete message has been decoded. - */payload: UrPayload?) { - self.progress = progress - self.fragmentCount = fragmentCount - self.payload = payload + * Amount in satoshis + */amount: UInt64, + /** + * 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 UrDecoderStatus: Sendable {} +extension TrezorTxOutput: Sendable {} #endif -extension UrDecoderStatus: Equatable, Hashable { - public static func ==(lhs: UrDecoderStatus, rhs: UrDecoderStatus) -> Bool { - if lhs.progress != rhs.progress { +extension TrezorTxOutput: Equatable, Hashable { + public static func ==(lhs: TrezorTxOutput, rhs: TrezorTxOutput) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.fragmentCount != rhs.fragmentCount { + if lhs.path != rhs.path { return false } - if lhs.payload != rhs.payload { + if lhs.amount != rhs.amount { + return false + } + 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(progress) - hasher.combine(fragmentCount) - hasher.combine(payload) + hasher.combine(address) + hasher.combine(path) + hasher.combine(amount) + hasher.combine(scriptType) + hasher.combine(opReturnData) + hasher.combine(origHash) + hasher.combine(origIndex) } } -extension UrDecoderStatus: Codable {} +extension TrezorTxOutput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUrDecoderStatus: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UrDecoderStatus { +public struct FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxOutput { return - try UrDecoderStatus( - progress: FfiConverterDouble.read(from: &buf), - fragmentCount: FfiConverterUInt32.read(from: &buf), - payload: FfiConverterOptionTypeUrPayload.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: UrDecoderStatus, into buf: inout [UInt8]) { - FfiConverterDouble.write(value.progress, into: &buf) - FfiConverterUInt32.write(value.fragmentCount, into: &buf) - FfiConverterOptionTypeUrPayload.write(value.payload, into: &buf) + public static func write(_ value: 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) } } @@ -18139,125 +18379,114 @@ public struct FfiConverterTypeUrDecoderStatus: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUrDecoderStatus_lift(_ buf: RustBuffer) throws -> UrDecoderStatus { - return try FfiConverterTypeUrDecoderStatus.lift(buf) +public func FfiConverterTypeTrezorTxOutput_lift(_ buf: RustBuffer) throws -> TrezorTxOutput { + return try FfiConverterTypeTrezorTxOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUrDecoderStatus_lower(_ value: UrDecoderStatus) -> RustBuffer { - return FfiConverterTypeUrDecoderStatus.lower(value) +public func FfiConverterTypeTrezorTxOutput_lower(_ value: TrezorTxOutput) -> RustBuffer { + return FfiConverterTypeTrezorTxOutput.lower(value) } -public struct UsdtDeposit { - public var id: String - public var network: String - public var asset: String +/** + * Parameters for verifying a message signature. + */ +public struct TrezorVerifyMessageParams { /** - * Observed source amount in millionths of USDT; finer BSC dust is rounded down. + * Bitcoin address that signed the message */ - public var amount: UInt64? - public var sourceTx: String - public var status: String - public var code: String? - public var refundTx: String? + public var address: String + /** + * Signature (base64 encoded) + */ + public var signature: String + /** + * Original message + */ + public var message: String + /** + * Coin network (default: Bitcoin) + */ + public var coin: TrezorCoinType? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, network: String, asset: String, + public init( /** - * Observed source amount in millionths of USDT; finer BSC dust is rounded down. - */amount: UInt64?, sourceTx: String, status: String, code: String?, refundTx: String?) { - self.id = id - self.network = network - self.asset = asset - self.amount = amount - self.sourceTx = sourceTx - self.status = status - self.code = code - self.refundTx = refundTx + * Bitcoin address that signed the message + */address: String, + /** + * Signature (base64 encoded) + */signature: String, + /** + * Original message + */message: String, + /** + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?) { + self.address = address + self.signature = signature + self.message = message + self.coin = coin } } #if compiler(>=6) -extension UsdtDeposit: Sendable {} +extension TrezorVerifyMessageParams: Sendable {} #endif -extension UsdtDeposit: Equatable, Hashable { - public static func ==(lhs: UsdtDeposit, rhs: UsdtDeposit) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.network != rhs.network { - return false - } - if lhs.asset != rhs.asset { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.sourceTx != rhs.sourceTx { +extension TrezorVerifyMessageParams: Equatable, Hashable { + public static func ==(lhs: TrezorVerifyMessageParams, rhs: TrezorVerifyMessageParams) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.status != rhs.status { + if lhs.signature != rhs.signature { return false } - if lhs.code != rhs.code { + if lhs.message != rhs.message { return false } - if lhs.refundTx != rhs.refundTx { + if lhs.coin != rhs.coin { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(network) - hasher.combine(asset) - hasher.combine(amount) - hasher.combine(sourceTx) - hasher.combine(status) - hasher.combine(code) - hasher.combine(refundTx) + hasher.combine(address) + hasher.combine(signature) + hasher.combine(message) + hasher.combine(coin) } } -extension UsdtDeposit: Codable {} +extension TrezorVerifyMessageParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtDeposit: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDeposit { +public struct FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorVerifyMessageParams { return - try UsdtDeposit( - id: FfiConverterString.read(from: &buf), - network: FfiConverterString.read(from: &buf), - asset: FfiConverterString.read(from: &buf), - amount: FfiConverterOptionUInt64.read(from: &buf), - sourceTx: FfiConverterString.read(from: &buf), - status: FfiConverterString.read(from: &buf), - code: FfiConverterOptionString.read(from: &buf), - refundTx: FfiConverterOptionString.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: UsdtDeposit, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.network, into: &buf) - FfiConverterString.write(value.asset, into: &buf) - FfiConverterOptionUInt64.write(value.amount, into: &buf) - FfiConverterString.write(value.sourceTx, into: &buf) - FfiConverterString.write(value.status, into: &buf) - FfiConverterOptionString.write(value.code, into: &buf) - FfiConverterOptionString.write(value.refundTx, 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) } } @@ -18265,133 +18494,128 @@ public struct FfiConverterTypeUsdtDeposit: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDeposit_lift(_ buf: RustBuffer) throws -> UsdtDeposit { - return try FfiConverterTypeUsdtDeposit.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 FfiConverterTypeUsdtDeposit_lower(_ value: UsdtDeposit) -> RustBuffer { - return FfiConverterTypeUsdtDeposit.lower(value) +public func FfiConverterTypeTrezorVerifyMessageParams_lower(_ value: TrezorVerifyMessageParams) -> RustBuffer { + return FfiConverterTypeTrezorVerifyMessageParams.lower(value) } -public struct UsdtDepositAddress { - public var network: UsdtDepositNetwork - public var address: String - public var recipient: String +/** + * A transaction input with full details. + */ +public struct TxDetailInput { /** - * Expected input in millionths of USDT, including for 18-decimal BSC USDT. + * Previous output transaction ID (hex) */ - public var amount: UInt64 - public var estimatedReceived: UInt64 - public var minUsdCents: String? - public var maxUsdCents: String? - public var slippageBps: UInt32 - public var uri: String + public var txid: String + /** + * Previous output index + */ + public var vout: UInt32 + /** + * Sequence number + */ + public var sequence: UInt32 + /** + * Script signature (hex-encoded) + */ + public var scriptSig: String + /** + * Witness stack (each element hex-encoded) + */ + public var witness: [String] // Default memberwise initializers are never public by default, so we // declare one manually. - public init(network: UsdtDepositNetwork, address: String, recipient: String, + public init( /** - * Expected input in millionths of USDT, including for 18-decimal BSC USDT. - */amount: UInt64, estimatedReceived: UInt64, minUsdCents: String?, maxUsdCents: String?, slippageBps: UInt32, uri: String) { - self.network = network - self.address = address - self.recipient = recipient - self.amount = amount - self.estimatedReceived = estimatedReceived - self.minUsdCents = minUsdCents - self.maxUsdCents = maxUsdCents - self.slippageBps = slippageBps - self.uri = uri - } -} - -#if compiler(>=6) -extension UsdtDepositAddress: Sendable {} -#endif + * Previous output transaction ID (hex) + */txid: String, + /** + * Previous output index + */vout: UInt32, + /** + * Sequence number + */sequence: UInt32, + /** + * Script signature (hex-encoded) + */scriptSig: String, + /** + * Witness stack (each element hex-encoded) + */witness: [String]) { + self.txid = txid + self.vout = vout + self.sequence = sequence + self.scriptSig = scriptSig + self.witness = witness + } +} +#if compiler(>=6) +extension TxDetailInput: Sendable {} +#endif -extension UsdtDepositAddress: Equatable, Hashable { - public static func ==(lhs: UsdtDepositAddress, rhs: UsdtDepositAddress) -> Bool { - if lhs.network != rhs.network { - return false - } - if lhs.address != rhs.address { - return false - } - if lhs.recipient != rhs.recipient { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.estimatedReceived != rhs.estimatedReceived { + +extension TxDetailInput: Equatable, Hashable { + public static func ==(lhs: TxDetailInput, rhs: TxDetailInput) -> Bool { + if lhs.txid != rhs.txid { return false } - if lhs.minUsdCents != rhs.minUsdCents { + if lhs.vout != rhs.vout { return false } - if lhs.maxUsdCents != rhs.maxUsdCents { + if lhs.sequence != rhs.sequence { return false } - if lhs.slippageBps != rhs.slippageBps { + if lhs.scriptSig != rhs.scriptSig { return false } - if lhs.uri != rhs.uri { + if lhs.witness != rhs.witness { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(network) - hasher.combine(address) - hasher.combine(recipient) - hasher.combine(amount) - hasher.combine(estimatedReceived) - hasher.combine(minUsdCents) - hasher.combine(maxUsdCents) - hasher.combine(slippageBps) - hasher.combine(uri) + hasher.combine(txid) + hasher.combine(vout) + hasher.combine(sequence) + hasher.combine(scriptSig) + hasher.combine(witness) } } -extension UsdtDepositAddress: Codable {} +extension TxDetailInput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtDepositAddress: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositAddress { +public struct FfiConverterTypeTxDetailInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailInput { return - try UsdtDepositAddress( - network: FfiConverterTypeUsdtDepositNetwork.read(from: &buf), - address: FfiConverterString.read(from: &buf), - recipient: FfiConverterString.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - estimatedReceived: FfiConverterUInt64.read(from: &buf), - minUsdCents: FfiConverterOptionString.read(from: &buf), - maxUsdCents: FfiConverterOptionString.read(from: &buf), - slippageBps: FfiConverterUInt32.read(from: &buf), - uri: FfiConverterString.read(from: &buf) + try TxDetailInput( + txid: FfiConverterString.read(from: &buf), + vout: FfiConverterUInt32.read(from: &buf), + sequence: FfiConverterUInt32.read(from: &buf), + scriptSig: FfiConverterString.read(from: &buf), + witness: FfiConverterSequenceString.read(from: &buf) ) } - public static func write(_ value: UsdtDepositAddress, into buf: inout [UInt8]) { - FfiConverterTypeUsdtDepositNetwork.write(value.network, into: &buf) - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.recipient, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterUInt64.write(value.estimatedReceived, into: &buf) - FfiConverterOptionString.write(value.minUsdCents, into: &buf) - FfiConverterOptionString.write(value.maxUsdCents, into: &buf) - FfiConverterUInt32.write(value.slippageBps, into: &buf) - FfiConverterString.write(value.uri, into: &buf) + public static func write(_ value: TxDetailInput, into buf: inout [UInt8]) { + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt32.write(value.vout, into: &buf) + FfiConverterUInt32.write(value.sequence, into: &buf) + FfiConverterString.write(value.scriptSig, into: &buf) + FfiConverterSequenceString.write(value.witness, into: &buf) } } @@ -18399,71 +18623,114 @@ public struct FfiConverterTypeUsdtDepositAddress: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositAddress_lift(_ buf: RustBuffer) throws -> UsdtDepositAddress { - return try FfiConverterTypeUsdtDepositAddress.lift(buf) +public func FfiConverterTypeTxDetailInput_lift(_ buf: RustBuffer) throws -> TxDetailInput { + return try FfiConverterTypeTxDetailInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositAddress_lower(_ value: UsdtDepositAddress) -> RustBuffer { - return FfiConverterTypeUsdtDepositAddress.lower(value) +public func FfiConverterTypeTxDetailInput_lower(_ value: TxDetailInput) -> RustBuffer { + return FfiConverterTypeTxDetailInput.lower(value) } -public struct UsdtDepositDetail { - public var deposit: UsdtDeposit - public var order: UsdtDepositOrder? +/** + * A transaction output with full details. + */ +public struct TxDetailOutput { + /** + * Output value in sats + */ + public var value: UInt64 + /** + * Script public key (hex-encoded) + */ + public var scriptPubkey: String + /** + * Decoded address (None if script is not decodable to an address) + */ + public var address: String? + /** + * Whether this output belongs to the queried wallet + */ + public var isMine: Bool // Default memberwise initializers are never public by default, so we // declare one manually. - public init(deposit: UsdtDeposit, order: UsdtDepositOrder?) { - self.deposit = deposit - self.order = order + public init( + /** + * Output value in sats + */value: UInt64, + /** + * Script public key (hex-encoded) + */scriptPubkey: String, + /** + * Decoded address (None if script is not decodable to an address) + */address: String?, + /** + * Whether this output belongs to the queried wallet + */isMine: Bool) { + self.value = value + self.scriptPubkey = scriptPubkey + self.address = address + self.isMine = isMine } } #if compiler(>=6) -extension UsdtDepositDetail: Sendable {} +extension TxDetailOutput: Sendable {} #endif -extension UsdtDepositDetail: Equatable, Hashable { - public static func ==(lhs: UsdtDepositDetail, rhs: UsdtDepositDetail) -> Bool { - if lhs.deposit != rhs.deposit { +extension TxDetailOutput: Equatable, Hashable { + public static func ==(lhs: TxDetailOutput, rhs: TxDetailOutput) -> Bool { + if lhs.value != rhs.value { return false } - if lhs.order != rhs.order { + if lhs.scriptPubkey != rhs.scriptPubkey { + return false + } + if lhs.address != rhs.address { + return false + } + if lhs.isMine != rhs.isMine { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(deposit) - hasher.combine(order) + hasher.combine(value) + hasher.combine(scriptPubkey) + hasher.combine(address) + hasher.combine(isMine) } } -extension UsdtDepositDetail: Codable {} +extension TxDetailOutput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtDepositDetail: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositDetail { +public struct FfiConverterTypeTxDetailOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailOutput { return - try UsdtDepositDetail( - deposit: FfiConverterTypeUsdtDeposit.read(from: &buf), - order: FfiConverterOptionTypeUsdtDepositOrder.read(from: &buf) + try TxDetailOutput( + value: FfiConverterUInt64.read(from: &buf), + scriptPubkey: FfiConverterString.read(from: &buf), + address: FfiConverterOptionString.read(from: &buf), + isMine: FfiConverterBool.read(from: &buf) ) } - public static func write(_ value: UsdtDepositDetail, into buf: inout [UInt8]) { - FfiConverterTypeUsdtDeposit.write(value.deposit, into: &buf) - FfiConverterOptionTypeUsdtDepositOrder.write(value.order, into: &buf) + public static func write(_ value: TxDetailOutput, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.value, into: &buf) + FfiConverterString.write(value.scriptPubkey, into: &buf) + FfiConverterOptionString.write(value.address, into: &buf) + FfiConverterBool.write(value.isMine, into: &buf) } } @@ -18471,109 +18738,128 @@ public struct FfiConverterTypeUsdtDepositDetail: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositDetail_lift(_ buf: RustBuffer) throws -> UsdtDepositDetail { - return try FfiConverterTypeUsdtDepositDetail.lift(buf) +public func FfiConverterTypeTxDetailOutput_lift(_ buf: RustBuffer) throws -> TxDetailOutput { + return try FfiConverterTypeTxDetailOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositDetail_lower(_ value: UsdtDepositDetail) -> RustBuffer { - return FfiConverterTypeUsdtDepositDetail.lower(value) +public func FfiConverterTypeTxDetailOutput_lower(_ value: TxDetailOutput) -> RustBuffer { + return FfiConverterTypeTxDetailOutput.lower(value) } -public struct UsdtDepositOrder { - public var status: String +/** + * Details about a transaction input. + */ +public struct TxInput { /** - * Batch input in millionths of USDT, not necessarily this deposit alone. + * The transaction ID of the previous output being spent. */ - public var amountIn: UInt64? - public var amountOut: UInt64? - public var destinationTx: String? - public var refundTx: String? - public var code: String? + public var txid: String + /** + * The output index of the previous output being spent. + */ + public var vout: UInt32 + /** + * The script signature (hex-encoded). + */ + public var scriptsig: String + /** + * The witness stack (hex-encoded strings). + */ + public var witness: [String] + /** + * The sequence number. + */ + public var sequence: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(status: String, + public init( /** - * Batch input in millionths of USDT, not necessarily this deposit alone. - */amountIn: UInt64?, amountOut: UInt64?, destinationTx: String?, refundTx: String?, code: String?) { - self.status = status - self.amountIn = amountIn - self.amountOut = amountOut - self.destinationTx = destinationTx - self.refundTx = refundTx - self.code = code - } -} - -#if compiler(>=6) -extension UsdtDepositOrder: Sendable {} -#endif - - -extension UsdtDepositOrder: Equatable, Hashable { - public static func ==(lhs: UsdtDepositOrder, rhs: UsdtDepositOrder) -> Bool { - if lhs.status != rhs.status { - return false - } - if lhs.amountIn != rhs.amountIn { + * The transaction ID of the previous output being spent. + */txid: String, + /** + * The output index of the previous output being spent. + */vout: UInt32, + /** + * The script signature (hex-encoded). + */scriptsig: String, + /** + * The witness stack (hex-encoded strings). + */witness: [String], + /** + * The sequence number. + */sequence: UInt32) { + self.txid = txid + self.vout = vout + self.scriptsig = scriptsig + self.witness = witness + self.sequence = sequence + } +} + +#if compiler(>=6) +extension TxInput: Sendable {} +#endif + + +extension TxInput: Equatable, Hashable { + public static func ==(lhs: TxInput, rhs: TxInput) -> Bool { + if lhs.txid != rhs.txid { return false } - if lhs.amountOut != rhs.amountOut { + if lhs.vout != rhs.vout { return false } - if lhs.destinationTx != rhs.destinationTx { + if lhs.scriptsig != rhs.scriptsig { return false } - if lhs.refundTx != rhs.refundTx { + if lhs.witness != rhs.witness { return false } - if lhs.code != rhs.code { + if lhs.sequence != rhs.sequence { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(status) - hasher.combine(amountIn) - hasher.combine(amountOut) - hasher.combine(destinationTx) - hasher.combine(refundTx) - hasher.combine(code) + hasher.combine(txid) + hasher.combine(vout) + hasher.combine(scriptsig) + hasher.combine(witness) + hasher.combine(sequence) } } -extension UsdtDepositOrder: Codable {} +extension TxInput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtDepositOrder: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositOrder { +public struct FfiConverterTypeTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxInput { return - try UsdtDepositOrder( - status: FfiConverterString.read(from: &buf), - amountIn: FfiConverterOptionUInt64.read(from: &buf), - amountOut: FfiConverterOptionUInt64.read(from: &buf), - destinationTx: FfiConverterOptionString.read(from: &buf), - refundTx: FfiConverterOptionString.read(from: &buf), - code: FfiConverterOptionString.read(from: &buf) + try TxInput( + txid: FfiConverterString.read(from: &buf), + vout: FfiConverterUInt32.read(from: &buf), + scriptsig: FfiConverterString.read(from: &buf), + witness: FfiConverterSequenceString.read(from: &buf), + sequence: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: UsdtDepositOrder, into buf: inout [UInt8]) { - FfiConverterString.write(value.status, into: &buf) - FfiConverterOptionUInt64.write(value.amountIn, into: &buf) - FfiConverterOptionUInt64.write(value.amountOut, into: &buf) - FfiConverterOptionString.write(value.destinationTx, into: &buf) - FfiConverterOptionString.write(value.refundTx, into: &buf) - FfiConverterOptionString.write(value.code, into: &buf) + public static func write(_ value: TxInput, into buf: inout [UInt8]) { + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt32.write(value.vout, into: &buf) + FfiConverterString.write(value.scriptsig, into: &buf) + FfiConverterSequenceString.write(value.witness, into: &buf) + FfiConverterUInt32.write(value.sequence, into: &buf) } } @@ -18581,71 +18867,128 @@ public struct FfiConverterTypeUsdtDepositOrder: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositOrder_lift(_ buf: RustBuffer) throws -> UsdtDepositOrder { - return try FfiConverterTypeUsdtDepositOrder.lift(buf) +public func FfiConverterTypeTxInput_lift(_ buf: RustBuffer) throws -> TxInput { + return try FfiConverterTypeTxInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositOrder_lower(_ value: UsdtDepositOrder) -> RustBuffer { - return FfiConverterTypeUsdtDepositOrder.lower(value) +public func FfiConverterTypeTxInput_lower(_ value: TxInput) -> RustBuffer { + return FfiConverterTypeTxInput.lower(value) } -public struct UsdtDepositPage { - public var deposits: [UsdtDeposit] - public var nextOffset: UInt32? +/** + * 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(deposits: [UsdtDeposit], nextOffset: UInt32?) { - self.deposits = deposits - self.nextOffset = nextOffset + public init( + /** + * The script public key (hex-encoded). + */scriptpubkey: String, + /** + * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + */scriptpubkeyType: String?, + /** + * The address corresponding to this script (if decodable). + */scriptpubkeyAddress: String?, + /** + * The value in satoshis. + */value: Int64, + /** + * The output index in the transaction. + */n: UInt32) { + self.scriptpubkey = scriptpubkey + self.scriptpubkeyType = scriptpubkeyType + self.scriptpubkeyAddress = scriptpubkeyAddress + self.value = value + self.n = n } } #if compiler(>=6) -extension UsdtDepositPage: Sendable {} +extension TxOutput: Sendable {} #endif -extension UsdtDepositPage: Equatable, Hashable { - public static func ==(lhs: UsdtDepositPage, rhs: UsdtDepositPage) -> Bool { - if lhs.deposits != rhs.deposits { +extension TxOutput: Equatable, Hashable { + public static func ==(lhs: TxOutput, rhs: TxOutput) -> Bool { + if lhs.scriptpubkey != rhs.scriptpubkey { return false } - if lhs.nextOffset != rhs.nextOffset { + if lhs.scriptpubkeyType != rhs.scriptpubkeyType { + return false + } + if lhs.scriptpubkeyAddress != rhs.scriptpubkeyAddress { + return false + } + if lhs.value != rhs.value { + return false + } + if lhs.n != rhs.n { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(deposits) - hasher.combine(nextOffset) + hasher.combine(scriptpubkey) + hasher.combine(scriptpubkeyType) + hasher.combine(scriptpubkeyAddress) + hasher.combine(value) + hasher.combine(n) } } -extension UsdtDepositPage: Codable {} +extension TxOutput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtDepositPage: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositPage { +public struct FfiConverterTypeTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxOutput { return - try UsdtDepositPage( - deposits: FfiConverterSequenceTypeUsdtDeposit.read(from: &buf), - nextOffset: FfiConverterOptionUInt32.read(from: &buf) + try TxOutput( + scriptpubkey: FfiConverterString.read(from: &buf), + scriptpubkeyType: FfiConverterOptionString.read(from: &buf), + scriptpubkeyAddress: FfiConverterOptionString.read(from: &buf), + value: FfiConverterInt64.read(from: &buf), + n: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: UsdtDepositPage, into buf: inout [UInt8]) { - FfiConverterSequenceTypeUsdtDeposit.write(value.deposits, into: &buf) - FfiConverterOptionUInt32.write(value.nextOffset, into: &buf) + public static func write(_ value: TxOutput, into buf: inout [UInt8]) { + FfiConverterString.write(value.scriptpubkey, into: &buf) + FfiConverterOptionString.write(value.scriptpubkeyType, into: &buf) + FfiConverterOptionString.write(value.scriptpubkeyAddress, into: &buf) + FfiConverterInt64.write(value.value, into: &buf) + FfiConverterUInt32.write(value.n, into: &buf) } } @@ -18653,95 +18996,100 @@ public struct FfiConverterTypeUsdtDepositPage: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositPage_lift(_ buf: RustBuffer) throws -> UsdtDepositPage { - return try FfiConverterTypeUsdtDepositPage.lift(buf) +public func FfiConverterTypeTxOutput_lift(_ buf: RustBuffer) throws -> TxOutput { + return try FfiConverterTypeTxOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtDepositPage_lower(_ value: UsdtDepositPage) -> RustBuffer { - return FfiConverterTypeUsdtDepositPage.lower(value) +public func FfiConverterTypeTxOutput_lower(_ value: TxOutput) -> RustBuffer { + return FfiConverterTypeTxOutput.lower(value) } -public struct UsdtOrchestraTransfer { - public var quoteId: String - public var fundingAddress: String - public var destinationTx: String? - public var refundTx: String? - public var refundAmount: UInt64? +/** + * Current state after accepting a scanned UR frame. + */ +public struct UrDecoderStatus { + /** + * Estimated completion from 0.0 through 1.0. + */ + public var progress: Double + /** + * Fountain source-fragment count, or 1 for a single-part UR. + */ + public var fragmentCount: UInt32 + /** + * Present once the complete message has been decoded. + */ + public var payload: UrPayload? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(quoteId: String, fundingAddress: String, destinationTx: String?, refundTx: String?, refundAmount: UInt64?) { - self.quoteId = quoteId - self.fundingAddress = fundingAddress - self.destinationTx = destinationTx - self.refundTx = refundTx - self.refundAmount = refundAmount + public init( + /** + * Estimated completion from 0.0 through 1.0. + */progress: Double, + /** + * Fountain source-fragment count, or 1 for a single-part UR. + */fragmentCount: UInt32, + /** + * Present once the complete message has been decoded. + */payload: UrPayload?) { + self.progress = progress + self.fragmentCount = fragmentCount + self.payload = payload } } #if compiler(>=6) -extension UsdtOrchestraTransfer: Sendable {} +extension UrDecoderStatus: Sendable {} #endif -extension UsdtOrchestraTransfer: Equatable, Hashable { - public static func ==(lhs: UsdtOrchestraTransfer, rhs: UsdtOrchestraTransfer) -> Bool { - if lhs.quoteId != rhs.quoteId { +extension UrDecoderStatus: Equatable, Hashable { + public static func ==(lhs: UrDecoderStatus, rhs: UrDecoderStatus) -> Bool { + if lhs.progress != rhs.progress { return false } - if lhs.fundingAddress != rhs.fundingAddress { + if lhs.fragmentCount != rhs.fragmentCount { return false } - if lhs.destinationTx != rhs.destinationTx { - return false - } - if lhs.refundTx != rhs.refundTx { - return false - } - if lhs.refundAmount != rhs.refundAmount { + if lhs.payload != rhs.payload { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(quoteId) - hasher.combine(fundingAddress) - hasher.combine(destinationTx) - hasher.combine(refundTx) - hasher.combine(refundAmount) + hasher.combine(progress) + hasher.combine(fragmentCount) + hasher.combine(payload) } } -extension UsdtOrchestraTransfer: Codable {} +extension UrDecoderStatus: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtOrchestraTransfer: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtOrchestraTransfer { +public struct FfiConverterTypeUrDecoderStatus: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UrDecoderStatus { return - try UsdtOrchestraTransfer( - quoteId: FfiConverterString.read(from: &buf), - fundingAddress: FfiConverterString.read(from: &buf), - destinationTx: FfiConverterOptionString.read(from: &buf), - refundTx: FfiConverterOptionString.read(from: &buf), - refundAmount: FfiConverterOptionUInt64.read(from: &buf) + try UrDecoderStatus( + progress: FfiConverterDouble.read(from: &buf), + fragmentCount: FfiConverterUInt32.read(from: &buf), + payload: FfiConverterOptionTypeUrPayload.read(from: &buf) ) } - public static func write(_ value: UsdtOrchestraTransfer, into buf: inout [UInt8]) { - FfiConverterString.write(value.quoteId, into: &buf) - FfiConverterString.write(value.fundingAddress, into: &buf) - FfiConverterOptionString.write(value.destinationTx, into: &buf) - FfiConverterOptionString.write(value.refundTx, into: &buf) - FfiConverterOptionUInt64.write(value.refundAmount, into: &buf) + public static func write(_ value: UrDecoderStatus, into buf: inout [UInt8]) { + FfiConverterDouble.write(value.progress, into: &buf) + FfiConverterUInt32.write(value.fragmentCount, into: &buf) + FfiConverterOptionTypeUrPayload.write(value.payload, into: &buf) } } @@ -18749,93 +19097,125 @@ public struct FfiConverterTypeUsdtOrchestraTransfer: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtOrchestraTransfer_lift(_ buf: RustBuffer) throws -> UsdtOrchestraTransfer { - return try FfiConverterTypeUsdtOrchestraTransfer.lift(buf) +public func FfiConverterTypeUrDecoderStatus_lift(_ buf: RustBuffer) throws -> UrDecoderStatus { + return try FfiConverterTypeUrDecoderStatus.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtOrchestraTransfer_lower(_ value: UsdtOrchestraTransfer) -> RustBuffer { - return FfiConverterTypeUsdtOrchestraTransfer.lower(value) +public func FfiConverterTypeUrDecoderStatus_lower(_ value: UrDecoderStatus) -> RustBuffer { + return FfiConverterTypeUrDecoderStatus.lower(value) } -public struct UsdtPaymentProof { - public var chainId: String - public var transactionHash: String +public struct UsdtDeposit { + public var id: String + public var network: String + public var asset: String /** - * Decimal position in the complete receipt logs array, not the block-wide RPC logIndex. + * Observed source amount in millionths of USDT; finer BSC dust is rounded down. */ - public var receiptLogIndex: String - public var signature: String + public var amount: UInt64? + public var sourceTx: String + public var status: String + public var code: String? + public var refundTx: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(chainId: String, transactionHash: String, + public init(id: String, network: String, asset: String, /** - * Decimal position in the complete receipt logs array, not the block-wide RPC logIndex. - */receiptLogIndex: String, signature: String) { - self.chainId = chainId - self.transactionHash = transactionHash - self.receiptLogIndex = receiptLogIndex - self.signature = signature + * Observed source amount in millionths of USDT; finer BSC dust is rounded down. + */amount: UInt64?, sourceTx: String, status: String, code: String?, refundTx: String?) { + self.id = id + self.network = network + self.asset = asset + self.amount = amount + self.sourceTx = sourceTx + self.status = status + self.code = code + self.refundTx = refundTx } } #if compiler(>=6) -extension UsdtPaymentProof: Sendable {} +extension UsdtDeposit: Sendable {} #endif -extension UsdtPaymentProof: Equatable, Hashable { - public static func ==(lhs: UsdtPaymentProof, rhs: UsdtPaymentProof) -> Bool { - if lhs.chainId != rhs.chainId { +extension UsdtDeposit: Equatable, Hashable { + public static func ==(lhs: UsdtDeposit, rhs: UsdtDeposit) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.transactionHash != rhs.transactionHash { + if lhs.network != rhs.network { return false } - if lhs.receiptLogIndex != rhs.receiptLogIndex { + if lhs.asset != rhs.asset { return false } - if lhs.signature != rhs.signature { + if lhs.amount != rhs.amount { + return false + } + if lhs.sourceTx != rhs.sourceTx { + return false + } + if lhs.status != rhs.status { + return false + } + if lhs.code != rhs.code { + return false + } + if lhs.refundTx != rhs.refundTx { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(chainId) - hasher.combine(transactionHash) - hasher.combine(receiptLogIndex) - hasher.combine(signature) + hasher.combine(id) + hasher.combine(network) + hasher.combine(asset) + hasher.combine(amount) + hasher.combine(sourceTx) + hasher.combine(status) + hasher.combine(code) + hasher.combine(refundTx) } } -extension UsdtPaymentProof: Codable {} +extension UsdtDeposit: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtPaymentProof: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtPaymentProof { +public struct FfiConverterTypeUsdtDeposit: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDeposit { return - try UsdtPaymentProof( - chainId: FfiConverterString.read(from: &buf), - transactionHash: FfiConverterString.read(from: &buf), - receiptLogIndex: FfiConverterString.read(from: &buf), - signature: FfiConverterString.read(from: &buf) + try UsdtDeposit( + id: FfiConverterString.read(from: &buf), + network: FfiConverterString.read(from: &buf), + asset: FfiConverterString.read(from: &buf), + amount: FfiConverterOptionUInt64.read(from: &buf), + sourceTx: FfiConverterString.read(from: &buf), + status: FfiConverterString.read(from: &buf), + code: FfiConverterOptionString.read(from: &buf), + refundTx: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: UsdtPaymentProof, into buf: inout [UInt8]) { - FfiConverterString.write(value.chainId, into: &buf) - FfiConverterString.write(value.transactionHash, into: &buf) - FfiConverterString.write(value.receiptLogIndex, into: &buf) - FfiConverterString.write(value.signature, into: &buf) + public static func write(_ value: UsdtDeposit, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.network, into: &buf) + FfiConverterString.write(value.asset, into: &buf) + FfiConverterOptionUInt64.write(value.amount, into: &buf) + FfiConverterString.write(value.sourceTx, into: &buf) + FfiConverterString.write(value.status, into: &buf) + FfiConverterOptionString.write(value.code, into: &buf) + FfiConverterOptionString.write(value.refundTx, into: &buf) } } @@ -18843,131 +19223,133 @@ public struct FfiConverterTypeUsdtPaymentProof: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtPaymentProof_lift(_ buf: RustBuffer) throws -> UsdtPaymentProof { - return try FfiConverterTypeUsdtPaymentProof.lift(buf) +public func FfiConverterTypeUsdtDeposit_lift(_ buf: RustBuffer) throws -> UsdtDeposit { + return try FfiConverterTypeUsdtDeposit.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtPaymentProof_lower(_ value: UsdtPaymentProof) -> RustBuffer { - return FfiConverterTypeUsdtPaymentProof.lower(value) +public func FfiConverterTypeUsdtDeposit_lower(_ value: UsdtDeposit) -> RustBuffer { + return FfiConverterTypeUsdtDeposit.lower(value) } -/** - * Immutable Paykit request fields, using the canonical strings from the accepted request/proof. - * Pubky keys are bare z32; absent period and conversion quote fields are empty strings. - */ -public struct UsdtPaymentProofBinding { - public var payer: String - public var payee: String - public var paymentAppId: String - public var paymentRequestId: String - public var paymentReference: String - public var paymentEndpointIdentifier: String - public var periodStartsAt: String - public var periodEndsAt: String - public var conversionQuoteId: String +public struct UsdtDepositAddress { + public var network: UsdtDepositNetwork + public var address: String + public var recipient: String + /** + * Expected input in millionths of USDT, including for 18-decimal BSC USDT. + */ + public var amount: UInt64 + public var estimatedReceived: UInt64 + public var minUsdCents: String? + public var maxUsdCents: String? + public var slippageBps: UInt32 + public var uri: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(payer: String, payee: String, paymentAppId: String, paymentRequestId: String, paymentReference: String, paymentEndpointIdentifier: String, periodStartsAt: String, periodEndsAt: String, conversionQuoteId: String) { - self.payer = payer - self.payee = payee - self.paymentAppId = paymentAppId - self.paymentRequestId = paymentRequestId - self.paymentReference = paymentReference - self.paymentEndpointIdentifier = paymentEndpointIdentifier - self.periodStartsAt = periodStartsAt - self.periodEndsAt = periodEndsAt - self.conversionQuoteId = conversionQuoteId + public init(network: UsdtDepositNetwork, address: String, recipient: String, + /** + * Expected input in millionths of USDT, including for 18-decimal BSC USDT. + */amount: UInt64, estimatedReceived: UInt64, minUsdCents: String?, maxUsdCents: String?, slippageBps: UInt32, uri: String) { + self.network = network + self.address = address + self.recipient = recipient + self.amount = amount + self.estimatedReceived = estimatedReceived + self.minUsdCents = minUsdCents + self.maxUsdCents = maxUsdCents + self.slippageBps = slippageBps + self.uri = uri } } #if compiler(>=6) -extension UsdtPaymentProofBinding: Sendable {} +extension UsdtDepositAddress: Sendable {} #endif -extension UsdtPaymentProofBinding: Equatable, Hashable { - public static func ==(lhs: UsdtPaymentProofBinding, rhs: UsdtPaymentProofBinding) -> Bool { - if lhs.payer != rhs.payer { +extension UsdtDepositAddress: Equatable, Hashable { + public static func ==(lhs: UsdtDepositAddress, rhs: UsdtDepositAddress) -> Bool { + if lhs.network != rhs.network { return false } - if lhs.payee != rhs.payee { + if lhs.address != rhs.address { return false } - if lhs.paymentAppId != rhs.paymentAppId { + if lhs.recipient != rhs.recipient { return false } - if lhs.paymentRequestId != rhs.paymentRequestId { + if lhs.amount != rhs.amount { return false } - if lhs.paymentReference != rhs.paymentReference { + if lhs.estimatedReceived != rhs.estimatedReceived { return false } - if lhs.paymentEndpointIdentifier != rhs.paymentEndpointIdentifier { + if lhs.minUsdCents != rhs.minUsdCents { return false } - if lhs.periodStartsAt != rhs.periodStartsAt { + if lhs.maxUsdCents != rhs.maxUsdCents { return false } - if lhs.periodEndsAt != rhs.periodEndsAt { + if lhs.slippageBps != rhs.slippageBps { return false } - if lhs.conversionQuoteId != rhs.conversionQuoteId { + if lhs.uri != rhs.uri { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(payer) - hasher.combine(payee) - hasher.combine(paymentAppId) - hasher.combine(paymentRequestId) - hasher.combine(paymentReference) - hasher.combine(paymentEndpointIdentifier) - hasher.combine(periodStartsAt) - hasher.combine(periodEndsAt) - hasher.combine(conversionQuoteId) + hasher.combine(network) + hasher.combine(address) + hasher.combine(recipient) + hasher.combine(amount) + hasher.combine(estimatedReceived) + hasher.combine(minUsdCents) + hasher.combine(maxUsdCents) + hasher.combine(slippageBps) + hasher.combine(uri) } } -extension UsdtPaymentProofBinding: Codable {} +extension UsdtDepositAddress: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtPaymentProofBinding: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtPaymentProofBinding { +public struct FfiConverterTypeUsdtDepositAddress: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositAddress { return - try UsdtPaymentProofBinding( - payer: FfiConverterString.read(from: &buf), - payee: FfiConverterString.read(from: &buf), - paymentAppId: FfiConverterString.read(from: &buf), - paymentRequestId: FfiConverterString.read(from: &buf), - paymentReference: FfiConverterString.read(from: &buf), - paymentEndpointIdentifier: FfiConverterString.read(from: &buf), - periodStartsAt: FfiConverterString.read(from: &buf), - periodEndsAt: FfiConverterString.read(from: &buf), - conversionQuoteId: FfiConverterString.read(from: &buf) + try UsdtDepositAddress( + network: FfiConverterTypeUsdtDepositNetwork.read(from: &buf), + address: FfiConverterString.read(from: &buf), + recipient: FfiConverterString.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + estimatedReceived: FfiConverterUInt64.read(from: &buf), + minUsdCents: FfiConverterOptionString.read(from: &buf), + maxUsdCents: FfiConverterOptionString.read(from: &buf), + slippageBps: FfiConverterUInt32.read(from: &buf), + uri: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: UsdtPaymentProofBinding, into buf: inout [UInt8]) { - FfiConverterString.write(value.payer, into: &buf) - FfiConverterString.write(value.payee, into: &buf) - FfiConverterString.write(value.paymentAppId, into: &buf) - FfiConverterString.write(value.paymentRequestId, into: &buf) - FfiConverterString.write(value.paymentReference, into: &buf) - FfiConverterString.write(value.paymentEndpointIdentifier, into: &buf) - FfiConverterString.write(value.periodStartsAt, into: &buf) - FfiConverterString.write(value.periodEndsAt, into: &buf) - FfiConverterString.write(value.conversionQuoteId, into: &buf) + public static func write(_ value: UsdtDepositAddress, into buf: inout [UInt8]) { + FfiConverterTypeUsdtDepositNetwork.write(value.network, into: &buf) + FfiConverterString.write(value.address, into: &buf) + FfiConverterString.write(value.recipient, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterUInt64.write(value.estimatedReceived, into: &buf) + FfiConverterOptionString.write(value.minUsdCents, into: &buf) + FfiConverterOptionString.write(value.maxUsdCents, into: &buf) + FfiConverterUInt32.write(value.slippageBps, into: &buf) + FfiConverterString.write(value.uri, into: &buf) } } @@ -18975,85 +19357,71 @@ public struct FfiConverterTypeUsdtPaymentProofBinding: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtPaymentProofBinding_lift(_ buf: RustBuffer) throws -> UsdtPaymentProofBinding { - return try FfiConverterTypeUsdtPaymentProofBinding.lift(buf) +public func FfiConverterTypeUsdtDepositAddress_lift(_ buf: RustBuffer) throws -> UsdtDepositAddress { + return try FfiConverterTypeUsdtDepositAddress.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtPaymentProofBinding_lower(_ value: UsdtPaymentProofBinding) -> RustBuffer { - return FfiConverterTypeUsdtPaymentProofBinding.lower(value) +public func FfiConverterTypeUsdtDepositAddress_lower(_ value: UsdtDepositAddress) -> RustBuffer { + return FfiConverterTypeUsdtDepositAddress.lower(value) } -public struct UsdtPaymentRequest { - public var recipient: String - public var amount: UInt64? - /** - * An explicit network in the payment URI; bare addresses have no restriction. - */ - public var chainId: UInt64? +public struct UsdtDepositDetail { + public var deposit: UsdtDeposit + public var order: UsdtDepositOrder? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(recipient: String, amount: UInt64?, - /** - * An explicit network in the payment URI; bare addresses have no restriction. - */chainId: UInt64?) { - self.recipient = recipient - self.amount = amount - self.chainId = chainId + public init(deposit: UsdtDeposit, order: UsdtDepositOrder?) { + self.deposit = deposit + self.order = order } } #if compiler(>=6) -extension UsdtPaymentRequest: Sendable {} +extension UsdtDepositDetail: Sendable {} #endif -extension UsdtPaymentRequest: Equatable, Hashable { - public static func ==(lhs: UsdtPaymentRequest, rhs: UsdtPaymentRequest) -> Bool { - if lhs.recipient != rhs.recipient { - return false - } - if lhs.amount != rhs.amount { +extension UsdtDepositDetail: Equatable, Hashable { + public static func ==(lhs: UsdtDepositDetail, rhs: UsdtDepositDetail) -> Bool { + if lhs.deposit != rhs.deposit { return false } - if lhs.chainId != rhs.chainId { + if lhs.order != rhs.order { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(recipient) - hasher.combine(amount) - hasher.combine(chainId) + hasher.combine(deposit) + hasher.combine(order) } } -extension UsdtPaymentRequest: Codable {} +extension UsdtDepositDetail: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtPaymentRequest: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtPaymentRequest { +public struct FfiConverterTypeUsdtDepositDetail: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositDetail { return - try UsdtPaymentRequest( - recipient: FfiConverterString.read(from: &buf), - amount: FfiConverterOptionUInt64.read(from: &buf), - chainId: FfiConverterOptionUInt64.read(from: &buf) + try UsdtDepositDetail( + deposit: FfiConverterTypeUsdtDeposit.read(from: &buf), + order: FfiConverterOptionTypeUsdtDepositOrder.read(from: &buf) ) } - public static func write(_ value: UsdtPaymentRequest, into buf: inout [UInt8]) { - FfiConverterString.write(value.recipient, into: &buf) - FfiConverterOptionUInt64.write(value.amount, into: &buf) - FfiConverterOptionUInt64.write(value.chainId, into: &buf) + public static func write(_ value: UsdtDepositDetail, into buf: inout [UInt8]) { + FfiConverterTypeUsdtDeposit.write(value.deposit, into: &buf) + FfiConverterOptionTypeUsdtDepositOrder.write(value.order, into: &buf) } } @@ -19061,125 +19429,109 @@ public struct FfiConverterTypeUsdtPaymentRequest: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtPaymentRequest_lift(_ buf: RustBuffer) throws -> UsdtPaymentRequest { - return try FfiConverterTypeUsdtPaymentRequest.lift(buf) +public func FfiConverterTypeUsdtDepositDetail_lift(_ buf: RustBuffer) throws -> UsdtDepositDetail { + return try FfiConverterTypeUsdtDepositDetail.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtPaymentRequest_lower(_ value: UsdtPaymentRequest) -> RustBuffer { - return FfiConverterTypeUsdtPaymentRequest.lower(value) +public func FfiConverterTypeUsdtDepositDetail_lower(_ value: UsdtDepositDetail) -> RustBuffer { + return FfiConverterTypeUsdtDepositDetail.lower(value) } -public struct UsdtQuote { +public struct UsdtDepositOrder { + public var status: String /** - * Absent for a direct Arbitrum payment. The provider is fixed when this quote is approved. + * Batch input in millionths of USDT, not necessarily this deposit alone. */ - public var bridgeProvider: UsdtBridgeProvider? - public var id: String - public var recipient: String - public var destination: UsdtDestination - public var amount: UInt64 - public var receivedAmount: UInt64 - public var maximumFee: UInt64 - public var expiresAt: UInt64 + public var amountIn: UInt64? + public var amountOut: UInt64? + public var destinationTx: String? + public var refundTx: String? + public var code: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( + public init(status: String, /** - * Absent for a direct Arbitrum payment. The provider is fixed when this quote is approved. - */bridgeProvider: UsdtBridgeProvider?, id: String, recipient: String, destination: UsdtDestination, amount: UInt64, receivedAmount: UInt64, maximumFee: UInt64, expiresAt: UInt64) { - self.bridgeProvider = bridgeProvider - self.id = id - self.recipient = recipient - self.destination = destination - self.amount = amount - self.receivedAmount = receivedAmount - self.maximumFee = maximumFee - self.expiresAt = expiresAt + * Batch input in millionths of USDT, not necessarily this deposit alone. + */amountIn: UInt64?, amountOut: UInt64?, destinationTx: String?, refundTx: String?, code: String?) { + self.status = status + self.amountIn = amountIn + self.amountOut = amountOut + self.destinationTx = destinationTx + self.refundTx = refundTx + self.code = code } } #if compiler(>=6) -extension UsdtQuote: Sendable {} +extension UsdtDepositOrder: Sendable {} #endif -extension UsdtQuote: Equatable, Hashable { - public static func ==(lhs: UsdtQuote, rhs: UsdtQuote) -> Bool { - if lhs.bridgeProvider != rhs.bridgeProvider { - return false - } - if lhs.id != rhs.id { - return false - } - if lhs.recipient != rhs.recipient { +extension UsdtDepositOrder: Equatable, Hashable { + public static func ==(lhs: UsdtDepositOrder, rhs: UsdtDepositOrder) -> Bool { + if lhs.status != rhs.status { return false } - if lhs.destination != rhs.destination { + if lhs.amountIn != rhs.amountIn { return false } - if lhs.amount != rhs.amount { + if lhs.amountOut != rhs.amountOut { return false } - if lhs.receivedAmount != rhs.receivedAmount { + if lhs.destinationTx != rhs.destinationTx { return false } - if lhs.maximumFee != rhs.maximumFee { + if lhs.refundTx != rhs.refundTx { return false } - if lhs.expiresAt != rhs.expiresAt { + if lhs.code != rhs.code { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(bridgeProvider) - hasher.combine(id) - hasher.combine(recipient) - hasher.combine(destination) - hasher.combine(amount) - hasher.combine(receivedAmount) - hasher.combine(maximumFee) - hasher.combine(expiresAt) + hasher.combine(status) + hasher.combine(amountIn) + hasher.combine(amountOut) + hasher.combine(destinationTx) + hasher.combine(refundTx) + hasher.combine(code) } } -extension UsdtQuote: Codable {} +extension UsdtDepositOrder: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtQuote: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtQuote { +public struct FfiConverterTypeUsdtDepositOrder: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositOrder { return - try UsdtQuote( - bridgeProvider: FfiConverterOptionTypeUsdtBridgeProvider.read(from: &buf), - id: FfiConverterString.read(from: &buf), - recipient: FfiConverterString.read(from: &buf), - destination: FfiConverterTypeUsdtDestination.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - receivedAmount: FfiConverterUInt64.read(from: &buf), - maximumFee: FfiConverterUInt64.read(from: &buf), - expiresAt: FfiConverterUInt64.read(from: &buf) + try UsdtDepositOrder( + status: FfiConverterString.read(from: &buf), + amountIn: FfiConverterOptionUInt64.read(from: &buf), + amountOut: FfiConverterOptionUInt64.read(from: &buf), + destinationTx: FfiConverterOptionString.read(from: &buf), + refundTx: FfiConverterOptionString.read(from: &buf), + code: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: UsdtQuote, into buf: inout [UInt8]) { - FfiConverterOptionTypeUsdtBridgeProvider.write(value.bridgeProvider, into: &buf) - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.recipient, into: &buf) - FfiConverterTypeUsdtDestination.write(value.destination, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterUInt64.write(value.receivedAmount, into: &buf) - FfiConverterUInt64.write(value.maximumFee, into: &buf) - FfiConverterUInt64.write(value.expiresAt, into: &buf) + public static func write(_ value: UsdtDepositOrder, into buf: inout [UInt8]) { + FfiConverterString.write(value.status, into: &buf) + FfiConverterOptionUInt64.write(value.amountIn, into: &buf) + FfiConverterOptionUInt64.write(value.amountOut, into: &buf) + FfiConverterOptionString.write(value.destinationTx, into: &buf) + FfiConverterOptionString.write(value.refundTx, into: &buf) + FfiConverterOptionString.write(value.code, into: &buf) } } @@ -19187,181 +19539,71 @@ public struct FfiConverterTypeUsdtQuote: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtQuote_lift(_ buf: RustBuffer) throws -> UsdtQuote { - return try FfiConverterTypeUsdtQuote.lift(buf) +public func FfiConverterTypeUsdtDepositOrder_lift(_ buf: RustBuffer) throws -> UsdtDepositOrder { + return try FfiConverterTypeUsdtDepositOrder.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtQuote_lower(_ value: UsdtQuote) -> RustBuffer { - return FfiConverterTypeUsdtQuote.lower(value) +public func FfiConverterTypeUsdtDepositOrder_lower(_ value: UsdtDepositOrder) -> RustBuffer { + return FfiConverterTypeUsdtDepositOrder.lower(value) } -public struct UsdtTransfer { - /** - * Source address on Arbitrum, from the token event or this wallet's signed operation. - * Absent in older history. A bridge contract address does not identify the original depositor. - */ - public var sender: String? - public var id: String - /** - * Source transaction hash, absent until execution is observed. - */ - public var txHash: String? - public var userOperationHash: String? - public var bridgeGuid: String? - public var orchestra: UsdtOrchestraTransfer? - public var recipient: String - public var destination: UsdtDestination - public var amount: UInt64 - public var receivedAmount: UInt64 - public var fee: UInt64? - public var isIncoming: Bool - public var status: UsdtTransferStatus - public var timestamp: UInt64 +public struct UsdtDepositPage { + public var deposits: [UsdtDeposit] + public var nextOffset: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Source address on Arbitrum, from the token event or this wallet's signed operation. - * Absent in older history. A bridge contract address does not identify the original depositor. - */sender: String?, id: String, - /** - * Source transaction hash, absent until execution is observed. - */txHash: String?, userOperationHash: String?, bridgeGuid: String?, orchestra: UsdtOrchestraTransfer?, recipient: String, destination: UsdtDestination, amount: UInt64, receivedAmount: UInt64, fee: UInt64?, isIncoming: Bool, status: UsdtTransferStatus, timestamp: UInt64) { - self.sender = sender - self.id = id - self.txHash = txHash - self.userOperationHash = userOperationHash - self.bridgeGuid = bridgeGuid - self.orchestra = orchestra - self.recipient = recipient - self.destination = destination - self.amount = amount - self.receivedAmount = receivedAmount - self.fee = fee - self.isIncoming = isIncoming - self.status = status - self.timestamp = timestamp + public init(deposits: [UsdtDeposit], nextOffset: UInt32?) { + self.deposits = deposits + self.nextOffset = nextOffset } } #if compiler(>=6) -extension UsdtTransfer: Sendable {} +extension UsdtDepositPage: Sendable {} #endif -extension UsdtTransfer: Equatable, Hashable { - public static func ==(lhs: UsdtTransfer, rhs: UsdtTransfer) -> Bool { - if lhs.sender != rhs.sender { - return false - } - if lhs.id != rhs.id { - return false - } - if lhs.txHash != rhs.txHash { - return false - } - if lhs.userOperationHash != rhs.userOperationHash { - return false - } - if lhs.bridgeGuid != rhs.bridgeGuid { - return false - } - if lhs.orchestra != rhs.orchestra { - return false - } - if lhs.recipient != rhs.recipient { - return false - } - if lhs.destination != rhs.destination { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.receivedAmount != rhs.receivedAmount { - return false - } - if lhs.fee != rhs.fee { - return false - } - if lhs.isIncoming != rhs.isIncoming { - return false - } - if lhs.status != rhs.status { +extension UsdtDepositPage: Equatable, Hashable { + public static func ==(lhs: UsdtDepositPage, rhs: UsdtDepositPage) -> Bool { + if lhs.deposits != rhs.deposits { return false } - if lhs.timestamp != rhs.timestamp { + if lhs.nextOffset != rhs.nextOffset { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(sender) - hasher.combine(id) - hasher.combine(txHash) - hasher.combine(userOperationHash) - hasher.combine(bridgeGuid) - hasher.combine(orchestra) - hasher.combine(recipient) - hasher.combine(destination) - hasher.combine(amount) - hasher.combine(receivedAmount) - hasher.combine(fee) - hasher.combine(isIncoming) - hasher.combine(status) - hasher.combine(timestamp) + hasher.combine(deposits) + hasher.combine(nextOffset) } } -extension UsdtTransfer: Codable {} +extension UsdtDepositPage: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtTransfer: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtTransfer { +public struct FfiConverterTypeUsdtDepositPage: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtDepositPage { return - try UsdtTransfer( - sender: FfiConverterOptionString.read(from: &buf), - id: FfiConverterString.read(from: &buf), - txHash: FfiConverterOptionString.read(from: &buf), - userOperationHash: FfiConverterOptionString.read(from: &buf), - bridgeGuid: FfiConverterOptionString.read(from: &buf), - orchestra: FfiConverterOptionTypeUsdtOrchestraTransfer.read(from: &buf), - recipient: FfiConverterString.read(from: &buf), - destination: FfiConverterTypeUsdtDestination.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - receivedAmount: FfiConverterUInt64.read(from: &buf), - fee: FfiConverterOptionUInt64.read(from: &buf), - isIncoming: FfiConverterBool.read(from: &buf), - status: FfiConverterTypeUsdtTransferStatus.read(from: &buf), - timestamp: FfiConverterUInt64.read(from: &buf) + try UsdtDepositPage( + deposits: FfiConverterSequenceTypeUsdtDeposit.read(from: &buf), + nextOffset: FfiConverterOptionUInt32.read(from: &buf) ) } - public static func write(_ value: UsdtTransfer, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.sender, into: &buf) - FfiConverterString.write(value.id, into: &buf) - FfiConverterOptionString.write(value.txHash, into: &buf) - FfiConverterOptionString.write(value.userOperationHash, into: &buf) - FfiConverterOptionString.write(value.bridgeGuid, into: &buf) - FfiConverterOptionTypeUsdtOrchestraTransfer.write(value.orchestra, into: &buf) - FfiConverterString.write(value.recipient, into: &buf) - FfiConverterTypeUsdtDestination.write(value.destination, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterUInt64.write(value.receivedAmount, into: &buf) - FfiConverterOptionUInt64.write(value.fee, into: &buf) - FfiConverterBool.write(value.isIncoming, into: &buf) - FfiConverterTypeUsdtTransferStatus.write(value.status, into: &buf) - FfiConverterUInt64.write(value.timestamp, into: &buf) + public static func write(_ value: UsdtDepositPage, into buf: inout [UInt8]) { + FfiConverterSequenceTypeUsdtDeposit.write(value.deposits, into: &buf) + FfiConverterOptionUInt32.write(value.nextOffset, into: &buf) } } @@ -19369,115 +19611,95 @@ public struct FfiConverterTypeUsdtTransfer: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtTransfer_lift(_ buf: RustBuffer) throws -> UsdtTransfer { - return try FfiConverterTypeUsdtTransfer.lift(buf) +public func FfiConverterTypeUsdtDepositPage_lift(_ buf: RustBuffer) throws -> UsdtDepositPage { + return try FfiConverterTypeUsdtDepositPage.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtTransfer_lower(_ value: UsdtTransfer) -> RustBuffer { - return FfiConverterTypeUsdtTransfer.lower(value) +public func FfiConverterTypeUsdtDepositPage_lower(_ value: UsdtDepositPage) -> RustBuffer { + return FfiConverterTypeUsdtDepositPage.lower(value) } -public struct UsdtVerifiedPayment { - /** - * Verified chain, transaction and receipt position; claim at most once across requests/periods. - */ - public var paymentId: String - /** - * Existing incoming activity identity (transaction and block-wide log index). - */ - public var transferId: String - public var sender: String - public var recipient: String - public var amount: UInt64 - public var timestamp: UInt64 +public struct UsdtOrchestraTransfer { + public var quoteId: String + public var fundingAddress: String + public var destinationTx: String? + public var refundTx: String? + public var refundAmount: UInt64? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Verified chain, transaction and receipt position; claim at most once across requests/periods. - */paymentId: String, - /** - * Existing incoming activity identity (transaction and block-wide log index). - */transferId: String, sender: String, recipient: String, amount: UInt64, timestamp: UInt64) { - self.paymentId = paymentId - self.transferId = transferId - self.sender = sender - self.recipient = recipient - self.amount = amount - self.timestamp = timestamp + public init(quoteId: String, fundingAddress: String, destinationTx: String?, refundTx: String?, refundAmount: UInt64?) { + self.quoteId = quoteId + self.fundingAddress = fundingAddress + self.destinationTx = destinationTx + self.refundTx = refundTx + self.refundAmount = refundAmount } } #if compiler(>=6) -extension UsdtVerifiedPayment: Sendable {} +extension UsdtOrchestraTransfer: Sendable {} #endif -extension UsdtVerifiedPayment: Equatable, Hashable { - public static func ==(lhs: UsdtVerifiedPayment, rhs: UsdtVerifiedPayment) -> Bool { - if lhs.paymentId != rhs.paymentId { - return false - } - if lhs.transferId != rhs.transferId { +extension UsdtOrchestraTransfer: Equatable, Hashable { + public static func ==(lhs: UsdtOrchestraTransfer, rhs: UsdtOrchestraTransfer) -> Bool { + if lhs.quoteId != rhs.quoteId { return false } - if lhs.sender != rhs.sender { + if lhs.fundingAddress != rhs.fundingAddress { return false } - if lhs.recipient != rhs.recipient { + if lhs.destinationTx != rhs.destinationTx { return false } - if lhs.amount != rhs.amount { + if lhs.refundTx != rhs.refundTx { return false } - if lhs.timestamp != rhs.timestamp { + if lhs.refundAmount != rhs.refundAmount { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(paymentId) - hasher.combine(transferId) - hasher.combine(sender) - hasher.combine(recipient) - hasher.combine(amount) - hasher.combine(timestamp) + hasher.combine(quoteId) + hasher.combine(fundingAddress) + hasher.combine(destinationTx) + hasher.combine(refundTx) + hasher.combine(refundAmount) } } -extension UsdtVerifiedPayment: Codable {} +extension UsdtOrchestraTransfer: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUsdtVerifiedPayment: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtVerifiedPayment { +public struct FfiConverterTypeUsdtOrchestraTransfer: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtOrchestraTransfer { return - try UsdtVerifiedPayment( - paymentId: FfiConverterString.read(from: &buf), - transferId: FfiConverterString.read(from: &buf), - sender: FfiConverterString.read(from: &buf), - recipient: FfiConverterString.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - timestamp: FfiConverterUInt64.read(from: &buf) + try UsdtOrchestraTransfer( + quoteId: FfiConverterString.read(from: &buf), + fundingAddress: FfiConverterString.read(from: &buf), + destinationTx: FfiConverterOptionString.read(from: &buf), + refundTx: FfiConverterOptionString.read(from: &buf), + refundAmount: FfiConverterOptionUInt64.read(from: &buf) ) } - public static func write(_ value: UsdtVerifiedPayment, into buf: inout [UInt8]) { - FfiConverterString.write(value.paymentId, into: &buf) - FfiConverterString.write(value.transferId, into: &buf) - FfiConverterString.write(value.sender, into: &buf) - FfiConverterString.write(value.recipient, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterUInt64.write(value.timestamp, into: &buf) + public static func write(_ value: UsdtOrchestraTransfer, into buf: inout [UInt8]) { + FfiConverterString.write(value.quoteId, into: &buf) + FfiConverterString.write(value.fundingAddress, into: &buf) + FfiConverterOptionString.write(value.destinationTx, into: &buf) + FfiConverterOptionString.write(value.refundTx, into: &buf) + FfiConverterOptionUInt64.write(value.refundAmount, into: &buf) } } @@ -19485,79 +19707,93 @@ public struct FfiConverterTypeUsdtVerifiedPayment: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtVerifiedPayment_lift(_ buf: RustBuffer) throws -> UsdtVerifiedPayment { - return try FfiConverterTypeUsdtVerifiedPayment.lift(buf) +public func FfiConverterTypeUsdtOrchestraTransfer_lift(_ buf: RustBuffer) throws -> UsdtOrchestraTransfer { + return try FfiConverterTypeUsdtOrchestraTransfer.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUsdtVerifiedPayment_lower(_ value: UsdtVerifiedPayment) -> RustBuffer { - return FfiConverterTypeUsdtVerifiedPayment.lower(value) +public func FfiConverterTypeUsdtOrchestraTransfer_lower(_ value: UsdtOrchestraTransfer) -> RustBuffer { + return FfiConverterTypeUsdtOrchestraTransfer.lower(value) } -public struct ValidationResult { - public var address: String - public var network: NetworkType - public var addressType: AddressType +public struct UsdtPaymentProof { + public var chainId: String + public var transactionHash: String + /** + * Decimal position in the complete receipt logs array, not the block-wide RPC logIndex. + */ + public var receiptLogIndex: String + public var signature: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(address: String, network: NetworkType, addressType: AddressType) { - self.address = address - self.network = network - self.addressType = addressType + public init(chainId: String, transactionHash: String, + /** + * Decimal position in the complete receipt logs array, not the block-wide RPC logIndex. + */receiptLogIndex: String, signature: String) { + self.chainId = chainId + self.transactionHash = transactionHash + self.receiptLogIndex = receiptLogIndex + self.signature = signature } } #if compiler(>=6) -extension ValidationResult: Sendable {} +extension UsdtPaymentProof: Sendable {} #endif -extension ValidationResult: Equatable, Hashable { - public static func ==(lhs: ValidationResult, rhs: ValidationResult) -> Bool { - if lhs.address != rhs.address { +extension UsdtPaymentProof: Equatable, Hashable { + public static func ==(lhs: UsdtPaymentProof, rhs: UsdtPaymentProof) -> Bool { + if lhs.chainId != rhs.chainId { return false } - if lhs.network != rhs.network { + if lhs.transactionHash != rhs.transactionHash { return false } - if lhs.addressType != rhs.addressType { + if lhs.receiptLogIndex != rhs.receiptLogIndex { + return false + } + if lhs.signature != rhs.signature { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(network) - hasher.combine(addressType) + hasher.combine(chainId) + hasher.combine(transactionHash) + hasher.combine(receiptLogIndex) + hasher.combine(signature) } } -extension ValidationResult: Codable {} +extension UsdtPaymentProof: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeValidationResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ValidationResult { +public struct FfiConverterTypeUsdtPaymentProof: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtPaymentProof { return - try ValidationResult( - address: FfiConverterString.read(from: &buf), - network: FfiConverterTypeNetworkType.read(from: &buf), - addressType: FfiConverterTypeAddressType.read(from: &buf) + try UsdtPaymentProof( + chainId: FfiConverterString.read(from: &buf), + transactionHash: FfiConverterString.read(from: &buf), + receiptLogIndex: FfiConverterString.read(from: &buf), + signature: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: ValidationResult, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterTypeNetworkType.write(value.network, into: &buf) - FfiConverterTypeAddressType.write(value.addressType, into: &buf) + public static func write(_ value: UsdtPaymentProof, into buf: inout [UInt8]) { + FfiConverterString.write(value.chainId, into: &buf) + FfiConverterString.write(value.transactionHash, into: &buf) + FfiConverterString.write(value.receiptLogIndex, into: &buf) + FfiConverterString.write(value.signature, into: &buf) } } @@ -19565,142 +19801,131 @@ 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 FfiConverterTypeUsdtPaymentProof_lift(_ buf: RustBuffer) throws -> UsdtPaymentProof { + return try FfiConverterTypeUsdtPaymentProof.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeValidationResult_lower(_ value: ValidationResult) -> RustBuffer { - return FfiConverterTypeValidationResult.lower(value) +public func FfiConverterTypeUsdtPaymentProof_lower(_ value: UsdtPaymentProof) -> RustBuffer { + return FfiConverterTypeUsdtPaymentProof.lower(value) } /** - * Balance breakdown from BDK. + * Immutable Paykit request fields, using the canonical strings from the accepted request/proof. + * Pubky keys are bare z32; absent period and conversion quote fields are empty strings. */ -public struct WalletBalance { - /** - * Confirmed and spendable balance (sats) - */ - public var confirmed: UInt64 - /** - * Immature coinbase outputs (sats) - */ - public var immature: UInt64 - /** - * Unconfirmed UTXOs from trusted sources (own change) (sats) - */ - public var trustedPending: UInt64 - /** - * Unconfirmed UTXOs from external sources (sats) - */ - public var untrustedPending: UInt64 - /** - * Total spendable: confirmed + trusted_pending (sats) - */ - public var spendable: UInt64 - /** - * Grand total: all categories (sats) - */ - public var total: UInt64 +public struct UsdtPaymentProofBinding { + public var payer: String + public var payee: String + public var paymentAppId: String + public var paymentRequestId: String + public var paymentReference: String + public var paymentEndpointIdentifier: String + public var periodStartsAt: String + public var periodEndsAt: String + public var conversionQuoteId: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Confirmed and spendable balance (sats) - */confirmed: UInt64, - /** - * Immature coinbase outputs (sats) - */immature: UInt64, - /** - * Unconfirmed UTXOs from trusted sources (own change) (sats) - */trustedPending: UInt64, - /** - * Unconfirmed UTXOs from external sources (sats) - */untrustedPending: UInt64, - /** - * Total spendable: confirmed + trusted_pending (sats) - */spendable: UInt64, - /** - * Grand total: all categories (sats) - */total: UInt64) { - self.confirmed = confirmed - self.immature = immature - self.trustedPending = trustedPending - self.untrustedPending = untrustedPending - self.spendable = spendable - self.total = total + public init(payer: String, payee: String, paymentAppId: String, paymentRequestId: String, paymentReference: String, paymentEndpointIdentifier: String, periodStartsAt: String, periodEndsAt: String, conversionQuoteId: String) { + self.payer = payer + self.payee = payee + self.paymentAppId = paymentAppId + self.paymentRequestId = paymentRequestId + self.paymentReference = paymentReference + self.paymentEndpointIdentifier = paymentEndpointIdentifier + self.periodStartsAt = periodStartsAt + self.periodEndsAt = periodEndsAt + self.conversionQuoteId = conversionQuoteId } } #if compiler(>=6) -extension WalletBalance: Sendable {} +extension UsdtPaymentProofBinding: Sendable {} #endif -extension WalletBalance: Equatable, Hashable { - public static func ==(lhs: WalletBalance, rhs: WalletBalance) -> Bool { - if lhs.confirmed != rhs.confirmed { +extension UsdtPaymentProofBinding: Equatable, Hashable { + public static func ==(lhs: UsdtPaymentProofBinding, rhs: UsdtPaymentProofBinding) -> Bool { + if lhs.payer != rhs.payer { return false } - if lhs.immature != rhs.immature { + if lhs.payee != rhs.payee { return false } - if lhs.trustedPending != rhs.trustedPending { + if lhs.paymentAppId != rhs.paymentAppId { return false } - if lhs.untrustedPending != rhs.untrustedPending { + if lhs.paymentRequestId != rhs.paymentRequestId { return false } - if lhs.spendable != rhs.spendable { + if lhs.paymentReference != rhs.paymentReference { return false } - if lhs.total != rhs.total { + if lhs.paymentEndpointIdentifier != rhs.paymentEndpointIdentifier { + return false + } + if lhs.periodStartsAt != rhs.periodStartsAt { + return false + } + if lhs.periodEndsAt != rhs.periodEndsAt { + return false + } + if lhs.conversionQuoteId != rhs.conversionQuoteId { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(confirmed) - hasher.combine(immature) - hasher.combine(trustedPending) - hasher.combine(untrustedPending) - hasher.combine(spendable) - hasher.combine(total) + hasher.combine(payer) + hasher.combine(payee) + hasher.combine(paymentAppId) + hasher.combine(paymentRequestId) + hasher.combine(paymentReference) + hasher.combine(paymentEndpointIdentifier) + hasher.combine(periodStartsAt) + hasher.combine(periodEndsAt) + hasher.combine(conversionQuoteId) } } -extension WalletBalance: Codable {} +extension UsdtPaymentProofBinding: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeWalletBalance: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletBalance { +public struct FfiConverterTypeUsdtPaymentProofBinding: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtPaymentProofBinding { return - try WalletBalance( - confirmed: FfiConverterUInt64.read(from: &buf), - immature: FfiConverterUInt64.read(from: &buf), - trustedPending: FfiConverterUInt64.read(from: &buf), - untrustedPending: FfiConverterUInt64.read(from: &buf), - spendable: FfiConverterUInt64.read(from: &buf), - total: FfiConverterUInt64.read(from: &buf) + try UsdtPaymentProofBinding( + payer: FfiConverterString.read(from: &buf), + payee: FfiConverterString.read(from: &buf), + paymentAppId: FfiConverterString.read(from: &buf), + paymentRequestId: FfiConverterString.read(from: &buf), + paymentReference: FfiConverterString.read(from: &buf), + paymentEndpointIdentifier: FfiConverterString.read(from: &buf), + periodStartsAt: FfiConverterString.read(from: &buf), + periodEndsAt: FfiConverterString.read(from: &buf), + conversionQuoteId: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: WalletBalance, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.confirmed, into: &buf) - FfiConverterUInt64.write(value.immature, into: &buf) - FfiConverterUInt64.write(value.trustedPending, into: &buf) - FfiConverterUInt64.write(value.untrustedPending, into: &buf) - FfiConverterUInt64.write(value.spendable, into: &buf) - FfiConverterUInt64.write(value.total, into: &buf) + public static func write(_ value: UsdtPaymentProofBinding, into buf: inout [UInt8]) { + FfiConverterString.write(value.payer, into: &buf) + FfiConverterString.write(value.payee, into: &buf) + FfiConverterString.write(value.paymentAppId, into: &buf) + FfiConverterString.write(value.paymentRequestId, into: &buf) + FfiConverterString.write(value.paymentReference, into: &buf) + FfiConverterString.write(value.paymentEndpointIdentifier, into: &buf) + FfiConverterString.write(value.periodStartsAt, into: &buf) + FfiConverterString.write(value.periodEndsAt, into: &buf) + FfiConverterString.write(value.conversionQuoteId, into: &buf) } } @@ -19708,128 +19933,85 @@ public struct FfiConverterTypeWalletBalance: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletBalance_lift(_ buf: RustBuffer) throws -> WalletBalance { - return try FfiConverterTypeWalletBalance.lift(buf) +public func FfiConverterTypeUsdtPaymentProofBinding_lift(_ buf: RustBuffer) throws -> UsdtPaymentProofBinding { + return try FfiConverterTypeUsdtPaymentProofBinding.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletBalance_lower(_ value: WalletBalance) -> RustBuffer { - return FfiConverterTypeWalletBalance.lower(value) +public func FfiConverterTypeUsdtPaymentProofBinding_lower(_ value: UsdtPaymentProofBinding) -> RustBuffer { + return FfiConverterTypeUsdtPaymentProofBinding.lower(value) } -/** - * Common parameters for creating and syncing a watch-only BDK wallet. - */ -public struct WalletParams { - /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) - */ - public var extendedKey: String - /** - * Electrum server URL for wallet sync - */ - public var electrumUrl: String +public struct UsdtPaymentRequest { + public var recipient: String + public var amount: UInt64? /** - * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + * An explicit network in the payment URI; bare addresses have no restriction. */ - public var fingerprint: String? - /** - * Bitcoin network (auto-detected from key prefix if not specified) - */ - public var network: Network? - /** - * Override account type for ambiguous key prefixes (xpub/tpub) - */ - public var accountType: AccountType? + public var chainId: UInt64? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) - */extendedKey: String, - /** - * Electrum server URL for wallet sync - */electrumUrl: String, - /** - * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. - */fingerprint: String?, - /** - * Bitcoin network (auto-detected from key prefix if not specified) - */network: Network?, + public init(recipient: String, amount: UInt64?, /** - * Override account type for ambiguous key prefixes (xpub/tpub) - */accountType: AccountType?) { - self.extendedKey = extendedKey - self.electrumUrl = electrumUrl - self.fingerprint = fingerprint - self.network = network - self.accountType = accountType + * An explicit network in the payment URI; bare addresses have no restriction. + */chainId: UInt64?) { + self.recipient = recipient + self.amount = amount + self.chainId = chainId } } #if compiler(>=6) -extension WalletParams: Sendable {} +extension UsdtPaymentRequest: Sendable {} #endif -extension WalletParams: Equatable, Hashable { - public static func ==(lhs: WalletParams, rhs: WalletParams) -> Bool { - if lhs.extendedKey != rhs.extendedKey { - return false - } - if lhs.electrumUrl != rhs.electrumUrl { - return false - } - if lhs.fingerprint != rhs.fingerprint { +extension UsdtPaymentRequest: Equatable, Hashable { + public static func ==(lhs: UsdtPaymentRequest, rhs: UsdtPaymentRequest) -> Bool { + if lhs.recipient != rhs.recipient { return false } - if lhs.network != rhs.network { + if lhs.amount != rhs.amount { return false } - if lhs.accountType != rhs.accountType { + if lhs.chainId != rhs.chainId { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(extendedKey) - hasher.combine(electrumUrl) - hasher.combine(fingerprint) - hasher.combine(network) - hasher.combine(accountType) + hasher.combine(recipient) + hasher.combine(amount) + hasher.combine(chainId) } } -extension WalletParams: Codable {} +extension UsdtPaymentRequest: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeWalletParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletParams { +public struct FfiConverterTypeUsdtPaymentRequest: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtPaymentRequest { return - try WalletParams( - extendedKey: FfiConverterString.read(from: &buf), - electrumUrl: FfiConverterString.read(from: &buf), - fingerprint: FfiConverterOptionString.read(from: &buf), - network: FfiConverterOptionTypeNetwork.read(from: &buf), - accountType: FfiConverterOptionTypeAccountType.read(from: &buf) + try UsdtPaymentRequest( + recipient: FfiConverterString.read(from: &buf), + amount: FfiConverterOptionUInt64.read(from: &buf), + chainId: FfiConverterOptionUInt64.read(from: &buf) ) } - public static func write(_ value: WalletParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.extendedKey, into: &buf) - FfiConverterString.write(value.electrumUrl, into: &buf) - FfiConverterOptionString.write(value.fingerprint, into: &buf) - FfiConverterOptionTypeNetwork.write(value.network, into: &buf) - FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) + public static func write(_ value: UsdtPaymentRequest, into buf: inout [UInt8]) { + FfiConverterString.write(value.recipient, into: &buf) + FfiConverterOptionUInt64.write(value.amount, into: &buf) + FfiConverterOptionUInt64.write(value.chainId, into: &buf) } } @@ -19837,160 +20019,125 @@ public struct FfiConverterTypeWalletParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletParams_lift(_ buf: RustBuffer) throws -> WalletParams { - return try FfiConverterTypeWalletParams.lift(buf) +public func FfiConverterTypeUsdtPaymentRequest_lift(_ buf: RustBuffer) throws -> UsdtPaymentRequest { + return try FfiConverterTypeUsdtPaymentRequest.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletParams_lower(_ value: WalletParams) -> RustBuffer { - return FfiConverterTypeWalletParams.lower(value) +public func FfiConverterTypeUsdtPaymentRequest_lower(_ value: UsdtPaymentRequest) -> RustBuffer { + return FfiConverterTypeUsdtPaymentRequest.lower(value) } -/** - * Parameters for starting an xpub transaction watcher. - */ -public struct WatcherParams { - /** - * Caller-supplied identifier for this watcher. - */ - public var watcherId: String - /** - * Wallet id that scopes the activities this watcher emits. Apps may use - * one wallet id for several account watchers and merge their snapshots. - */ - public var walletId: String - /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). - */ - public var extendedKey: String - /** - * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). - */ - public var electrumUrl: String - /** - * Bitcoin network override (auto-detected from key prefix if None). - */ - public var network: Network? - /** - * Account type override (auto-detected from key prefix if None). - */ - public var accountType: AccountType? +public struct UsdtQuote { /** - * Number of unused addresses to monitor beyond the last used - * (defaults to `DEFAULT_GAP_LIMIT` when None). + * Absent for a direct Arbitrum payment. The provider is fixed when this quote is approved. */ - public var gapLimit: UInt32? + public var bridgeProvider: UsdtBridgeProvider? + public var id: String + public var recipient: String + public var destination: UsdtDestination + public var amount: UInt64 + public var receivedAmount: UInt64 + public var maximumFee: UInt64 + public var expiresAt: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Caller-supplied identifier for this watcher. - */watcherId: String, - /** - * Wallet id that scopes the activities this watcher emits. Apps may use - * one wallet id for several account watchers and merge their snapshots. - */walletId: String, - /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). - */extendedKey: String, - /** - * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). - */electrumUrl: String, - /** - * Bitcoin network override (auto-detected from key prefix if None). - */network: Network?, - /** - * Account type override (auto-detected from key prefix if None). - */accountType: AccountType?, - /** - * Number of unused addresses to monitor beyond the last used - * (defaults to `DEFAULT_GAP_LIMIT` when None). - */gapLimit: UInt32?) { - self.watcherId = watcherId - self.walletId = walletId - self.extendedKey = extendedKey - self.electrumUrl = electrumUrl - self.network = network - self.accountType = accountType - self.gapLimit = gapLimit + * Absent for a direct Arbitrum payment. The provider is fixed when this quote is approved. + */bridgeProvider: UsdtBridgeProvider?, id: String, recipient: String, destination: UsdtDestination, amount: UInt64, receivedAmount: UInt64, maximumFee: UInt64, expiresAt: UInt64) { + self.bridgeProvider = bridgeProvider + self.id = id + self.recipient = recipient + self.destination = destination + self.amount = amount + self.receivedAmount = receivedAmount + self.maximumFee = maximumFee + self.expiresAt = expiresAt } } #if compiler(>=6) -extension WatcherParams: Sendable {} +extension UsdtQuote: Sendable {} #endif -extension WatcherParams: Equatable, Hashable { - public static func ==(lhs: WatcherParams, rhs: WatcherParams) -> Bool { - if lhs.watcherId != rhs.watcherId { +extension UsdtQuote: Equatable, Hashable { + public static func ==(lhs: UsdtQuote, rhs: UsdtQuote) -> Bool { + if lhs.bridgeProvider != rhs.bridgeProvider { return false } - if lhs.walletId != rhs.walletId { + if lhs.id != rhs.id { return false } - if lhs.extendedKey != rhs.extendedKey { + if lhs.recipient != rhs.recipient { return false } - if lhs.electrumUrl != rhs.electrumUrl { + if lhs.destination != rhs.destination { return false } - if lhs.network != rhs.network { + if lhs.amount != rhs.amount { return false } - if lhs.accountType != rhs.accountType { + if lhs.receivedAmount != rhs.receivedAmount { return false } - if lhs.gapLimit != rhs.gapLimit { + if lhs.maximumFee != rhs.maximumFee { + return false + } + if lhs.expiresAt != rhs.expiresAt { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(watcherId) - hasher.combine(walletId) - hasher.combine(extendedKey) - hasher.combine(electrumUrl) - hasher.combine(network) - hasher.combine(accountType) - hasher.combine(gapLimit) + hasher.combine(bridgeProvider) + hasher.combine(id) + hasher.combine(recipient) + hasher.combine(destination) + hasher.combine(amount) + hasher.combine(receivedAmount) + hasher.combine(maximumFee) + hasher.combine(expiresAt) } } -extension WatcherParams: Codable {} +extension UsdtQuote: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeWatcherParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WatcherParams { +public struct FfiConverterTypeUsdtQuote: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtQuote { return - try WatcherParams( - watcherId: FfiConverterString.read(from: &buf), - walletId: FfiConverterString.read(from: &buf), - extendedKey: FfiConverterString.read(from: &buf), - electrumUrl: FfiConverterString.read(from: &buf), - network: FfiConverterOptionTypeNetwork.read(from: &buf), - accountType: FfiConverterOptionTypeAccountType.read(from: &buf), - gapLimit: FfiConverterOptionUInt32.read(from: &buf) + try UsdtQuote( + bridgeProvider: FfiConverterOptionTypeUsdtBridgeProvider.read(from: &buf), + id: FfiConverterString.read(from: &buf), + recipient: FfiConverterString.read(from: &buf), + destination: FfiConverterTypeUsdtDestination.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + receivedAmount: FfiConverterUInt64.read(from: &buf), + maximumFee: FfiConverterUInt64.read(from: &buf), + expiresAt: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: WatcherParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.watcherId, into: &buf) - FfiConverterString.write(value.walletId, into: &buf) - FfiConverterString.write(value.extendedKey, into: &buf) - FfiConverterString.write(value.electrumUrl, into: &buf) - FfiConverterOptionTypeNetwork.write(value.network, into: &buf) - FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) - FfiConverterOptionUInt32.write(value.gapLimit, into: &buf) + public static func write(_ value: UsdtQuote, into buf: inout [UInt8]) { + FfiConverterOptionTypeUsdtBridgeProvider.write(value.bridgeProvider, into: &buf) + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.recipient, into: &buf) + FfiConverterTypeUsdtDestination.write(value.destination, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterUInt64.write(value.receivedAmount, into: &buf) + FfiConverterUInt64.write(value.maximumFee, into: &buf) + FfiConverterUInt64.write(value.expiresAt, into: &buf) } } @@ -19998,74 +20145,1228 @@ public struct FfiConverterTypeWatcherParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWatcherParams_lift(_ buf: RustBuffer) throws -> WatcherParams { - return try FfiConverterTypeWatcherParams.lift(buf) +public func FfiConverterTypeUsdtQuote_lift(_ buf: RustBuffer) throws -> UsdtQuote { + return try FfiConverterTypeUsdtQuote.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeUsdtQuote_lower(_ value: UsdtQuote) -> RustBuffer { + return FfiConverterTypeUsdtQuote.lower(value) +} + + +public struct UsdtTransfer { + /** + * Source address on Arbitrum, from the token event or this wallet's signed operation. + * Absent in older history. A bridge contract address does not identify the original depositor. + */ + public var sender: String? + public var id: String + /** + * Source transaction hash, absent until execution is observed. + */ + public var txHash: String? + public var userOperationHash: String? + public var bridgeGuid: String? + public var orchestra: UsdtOrchestraTransfer? + public var recipient: String + public var destination: UsdtDestination + public var amount: UInt64 + public var receivedAmount: UInt64 + public var fee: UInt64? + public var isIncoming: Bool + public var status: UsdtTransferStatus + public var timestamp: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Source address on Arbitrum, from the token event or this wallet's signed operation. + * Absent in older history. A bridge contract address does not identify the original depositor. + */sender: String?, id: String, + /** + * Source transaction hash, absent until execution is observed. + */txHash: String?, userOperationHash: String?, bridgeGuid: String?, orchestra: UsdtOrchestraTransfer?, recipient: String, destination: UsdtDestination, amount: UInt64, receivedAmount: UInt64, fee: UInt64?, isIncoming: Bool, status: UsdtTransferStatus, timestamp: UInt64) { + self.sender = sender + self.id = id + self.txHash = txHash + self.userOperationHash = userOperationHash + self.bridgeGuid = bridgeGuid + self.orchestra = orchestra + self.recipient = recipient + self.destination = destination + self.amount = amount + self.receivedAmount = receivedAmount + self.fee = fee + self.isIncoming = isIncoming + self.status = status + self.timestamp = timestamp + } +} + +#if compiler(>=6) +extension UsdtTransfer: Sendable {} +#endif + + +extension UsdtTransfer: Equatable, Hashable { + public static func ==(lhs: UsdtTransfer, rhs: UsdtTransfer) -> Bool { + if lhs.sender != rhs.sender { + return false + } + if lhs.id != rhs.id { + return false + } + if lhs.txHash != rhs.txHash { + return false + } + if lhs.userOperationHash != rhs.userOperationHash { + return false + } + if lhs.bridgeGuid != rhs.bridgeGuid { + return false + } + if lhs.orchestra != rhs.orchestra { + return false + } + if lhs.recipient != rhs.recipient { + return false + } + if lhs.destination != rhs.destination { + return false + } + if lhs.amount != rhs.amount { + return false + } + if lhs.receivedAmount != rhs.receivedAmount { + return false + } + if lhs.fee != rhs.fee { + return false + } + if lhs.isIncoming != rhs.isIncoming { + return false + } + if lhs.status != rhs.status { + return false + } + if lhs.timestamp != rhs.timestamp { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(sender) + hasher.combine(id) + hasher.combine(txHash) + hasher.combine(userOperationHash) + hasher.combine(bridgeGuid) + hasher.combine(orchestra) + hasher.combine(recipient) + hasher.combine(destination) + hasher.combine(amount) + hasher.combine(receivedAmount) + hasher.combine(fee) + hasher.combine(isIncoming) + hasher.combine(status) + hasher.combine(timestamp) + } +} + +extension UsdtTransfer: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeUsdtTransfer: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtTransfer { + return + try UsdtTransfer( + sender: FfiConverterOptionString.read(from: &buf), + id: FfiConverterString.read(from: &buf), + txHash: FfiConverterOptionString.read(from: &buf), + userOperationHash: FfiConverterOptionString.read(from: &buf), + bridgeGuid: FfiConverterOptionString.read(from: &buf), + orchestra: FfiConverterOptionTypeUsdtOrchestraTransfer.read(from: &buf), + recipient: FfiConverterString.read(from: &buf), + destination: FfiConverterTypeUsdtDestination.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + receivedAmount: FfiConverterUInt64.read(from: &buf), + fee: FfiConverterOptionUInt64.read(from: &buf), + isIncoming: FfiConverterBool.read(from: &buf), + status: FfiConverterTypeUsdtTransferStatus.read(from: &buf), + timestamp: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: UsdtTransfer, into buf: inout [UInt8]) { + FfiConverterOptionString.write(value.sender, into: &buf) + FfiConverterString.write(value.id, into: &buf) + FfiConverterOptionString.write(value.txHash, into: &buf) + FfiConverterOptionString.write(value.userOperationHash, into: &buf) + FfiConverterOptionString.write(value.bridgeGuid, into: &buf) + FfiConverterOptionTypeUsdtOrchestraTransfer.write(value.orchestra, into: &buf) + FfiConverterString.write(value.recipient, into: &buf) + FfiConverterTypeUsdtDestination.write(value.destination, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterUInt64.write(value.receivedAmount, into: &buf) + FfiConverterOptionUInt64.write(value.fee, into: &buf) + FfiConverterBool.write(value.isIncoming, into: &buf) + FfiConverterTypeUsdtTransferStatus.write(value.status, into: &buf) + FfiConverterUInt64.write(value.timestamp, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeUsdtTransfer_lift(_ buf: RustBuffer) throws -> UsdtTransfer { + return try FfiConverterTypeUsdtTransfer.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeUsdtTransfer_lower(_ value: UsdtTransfer) -> RustBuffer { + return FfiConverterTypeUsdtTransfer.lower(value) +} + + +public struct UsdtVerifiedPayment { + /** + * Verified chain, transaction and receipt position; claim at most once across requests/periods. + */ + public var paymentId: String + /** + * Existing incoming activity identity (transaction and block-wide log index). + */ + public var transferId: String + public var sender: String + public var recipient: String + public var amount: UInt64 + public var timestamp: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Verified chain, transaction and receipt position; claim at most once across requests/periods. + */paymentId: String, + /** + * Existing incoming activity identity (transaction and block-wide log index). + */transferId: String, sender: String, recipient: String, amount: UInt64, timestamp: UInt64) { + self.paymentId = paymentId + self.transferId = transferId + self.sender = sender + self.recipient = recipient + self.amount = amount + self.timestamp = timestamp + } +} + +#if compiler(>=6) +extension UsdtVerifiedPayment: Sendable {} +#endif + + +extension UsdtVerifiedPayment: Equatable, Hashable { + public static func ==(lhs: UsdtVerifiedPayment, rhs: UsdtVerifiedPayment) -> Bool { + if lhs.paymentId != rhs.paymentId { + return false + } + if lhs.transferId != rhs.transferId { + return false + } + if lhs.sender != rhs.sender { + return false + } + if lhs.recipient != rhs.recipient { + return false + } + if lhs.amount != rhs.amount { + return false + } + if lhs.timestamp != rhs.timestamp { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(paymentId) + hasher.combine(transferId) + hasher.combine(sender) + hasher.combine(recipient) + hasher.combine(amount) + hasher.combine(timestamp) + } +} + +extension UsdtVerifiedPayment: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeUsdtVerifiedPayment: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UsdtVerifiedPayment { + return + try UsdtVerifiedPayment( + paymentId: FfiConverterString.read(from: &buf), + transferId: FfiConverterString.read(from: &buf), + sender: FfiConverterString.read(from: &buf), + recipient: FfiConverterString.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + timestamp: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: UsdtVerifiedPayment, into buf: inout [UInt8]) { + FfiConverterString.write(value.paymentId, into: &buf) + FfiConverterString.write(value.transferId, into: &buf) + FfiConverterString.write(value.sender, into: &buf) + FfiConverterString.write(value.recipient, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterUInt64.write(value.timestamp, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeUsdtVerifiedPayment_lift(_ buf: RustBuffer) throws -> UsdtVerifiedPayment { + return try FfiConverterTypeUsdtVerifiedPayment.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeUsdtVerifiedPayment_lower(_ value: UsdtVerifiedPayment) -> RustBuffer { + return FfiConverterTypeUsdtVerifiedPayment.lower(value) +} + + +public struct ValidationResult { + public var address: String + public var network: NetworkType + public var addressType: AddressType + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(address: String, network: NetworkType, addressType: AddressType) { + self.address = address + self.network = network + self.addressType = addressType + } +} + +#if compiler(>=6) +extension ValidationResult: Sendable {} +#endif + + +extension ValidationResult: Equatable, Hashable { + public static func ==(lhs: ValidationResult, rhs: ValidationResult) -> Bool { + if lhs.address != rhs.address { + return false + } + if lhs.network != rhs.network { + return false + } + if lhs.addressType != rhs.addressType { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(address) + hasher.combine(network) + hasher.combine(addressType) + } +} + +extension ValidationResult: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeValidationResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ValidationResult { + return + try ValidationResult( + address: FfiConverterString.read(from: &buf), + network: FfiConverterTypeNetworkType.read(from: &buf), + addressType: FfiConverterTypeAddressType.read(from: &buf) + ) + } + + public static func write(_ value: ValidationResult, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterTypeNetworkType.write(value.network, into: &buf) + FfiConverterTypeAddressType.write(value.addressType, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeValidationResult_lift(_ buf: RustBuffer) throws -> ValidationResult { + return try FfiConverterTypeValidationResult.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeValidationResult_lower(_ value: ValidationResult) -> RustBuffer { + return FfiConverterTypeValidationResult.lower(value) +} + + +/** + * Balance breakdown from BDK. + */ +public struct WalletBalance { + /** + * Confirmed and spendable balance (sats) + */ + public var confirmed: UInt64 + /** + * Immature coinbase outputs (sats) + */ + public var immature: UInt64 + /** + * Unconfirmed UTXOs from trusted sources (own change) (sats) + */ + public var trustedPending: UInt64 + /** + * Unconfirmed UTXOs from external sources (sats) + */ + public var untrustedPending: UInt64 + /** + * Total spendable: confirmed + trusted_pending (sats) + */ + public var spendable: UInt64 + /** + * Grand total: all categories (sats) + */ + public var total: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Confirmed and spendable balance (sats) + */confirmed: UInt64, + /** + * Immature coinbase outputs (sats) + */immature: UInt64, + /** + * Unconfirmed UTXOs from trusted sources (own change) (sats) + */trustedPending: UInt64, + /** + * Unconfirmed UTXOs from external sources (sats) + */untrustedPending: UInt64, + /** + * Total spendable: confirmed + trusted_pending (sats) + */spendable: UInt64, + /** + * Grand total: all categories (sats) + */total: UInt64) { + self.confirmed = confirmed + self.immature = immature + self.trustedPending = trustedPending + self.untrustedPending = untrustedPending + self.spendable = spendable + self.total = total + } +} + +#if compiler(>=6) +extension WalletBalance: Sendable {} +#endif + + +extension WalletBalance: Equatable, Hashable { + public static func ==(lhs: WalletBalance, rhs: WalletBalance) -> Bool { + if lhs.confirmed != rhs.confirmed { + return false + } + if lhs.immature != rhs.immature { + return false + } + if lhs.trustedPending != rhs.trustedPending { + return false + } + if lhs.untrustedPending != rhs.untrustedPending { + return false + } + if lhs.spendable != rhs.spendable { + return false + } + if lhs.total != rhs.total { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(confirmed) + hasher.combine(immature) + hasher.combine(trustedPending) + hasher.combine(untrustedPending) + hasher.combine(spendable) + hasher.combine(total) + } +} + +extension WalletBalance: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeWalletBalance: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletBalance { + return + try WalletBalance( + confirmed: FfiConverterUInt64.read(from: &buf), + immature: FfiConverterUInt64.read(from: &buf), + trustedPending: FfiConverterUInt64.read(from: &buf), + untrustedPending: FfiConverterUInt64.read(from: &buf), + spendable: FfiConverterUInt64.read(from: &buf), + total: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: WalletBalance, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.confirmed, into: &buf) + FfiConverterUInt64.write(value.immature, into: &buf) + FfiConverterUInt64.write(value.trustedPending, into: &buf) + FfiConverterUInt64.write(value.untrustedPending, into: &buf) + FfiConverterUInt64.write(value.spendable, into: &buf) + FfiConverterUInt64.write(value.total, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletBalance_lift(_ buf: RustBuffer) throws -> WalletBalance { + return try FfiConverterTypeWalletBalance.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletBalance_lower(_ value: WalletBalance) -> RustBuffer { + return FfiConverterTypeWalletBalance.lower(value) +} + + +/** + * Common parameters for creating and syncing a watch-only BDK wallet. + */ +public struct WalletParams { + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) + */ + public var extendedKey: String + /** + * Electrum server URL for wallet sync + */ + public var electrumUrl: String + /** + * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + */ + public var fingerprint: String? + /** + * Bitcoin network (auto-detected from key prefix if not specified) + */ + public var network: Network? + /** + * Override account type for ambiguous key prefixes (xpub/tpub) + */ + public var accountType: AccountType? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) + */extendedKey: String, + /** + * Electrum server URL for wallet sync + */electrumUrl: String, + /** + * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + */fingerprint: String?, + /** + * Bitcoin network (auto-detected from key prefix if not specified) + */network: Network?, + /** + * Override account type for ambiguous key prefixes (xpub/tpub) + */accountType: AccountType?) { + self.extendedKey = extendedKey + self.electrumUrl = electrumUrl + self.fingerprint = fingerprint + self.network = network + self.accountType = accountType + } +} + +#if compiler(>=6) +extension WalletParams: Sendable {} +#endif + + +extension WalletParams: Equatable, Hashable { + public static func ==(lhs: WalletParams, rhs: WalletParams) -> Bool { + if lhs.extendedKey != rhs.extendedKey { + return false + } + if lhs.electrumUrl != rhs.electrumUrl { + return false + } + if lhs.fingerprint != rhs.fingerprint { + return false + } + if lhs.network != rhs.network { + return false + } + if lhs.accountType != rhs.accountType { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(extendedKey) + hasher.combine(electrumUrl) + hasher.combine(fingerprint) + hasher.combine(network) + hasher.combine(accountType) + } +} + +extension WalletParams: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeWalletParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletParams { + return + try WalletParams( + extendedKey: FfiConverterString.read(from: &buf), + electrumUrl: FfiConverterString.read(from: &buf), + fingerprint: FfiConverterOptionString.read(from: &buf), + network: FfiConverterOptionTypeNetwork.read(from: &buf), + accountType: FfiConverterOptionTypeAccountType.read(from: &buf) + ) + } + + public static func write(_ value: WalletParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.extendedKey, into: &buf) + FfiConverterString.write(value.electrumUrl, into: &buf) + FfiConverterOptionString.write(value.fingerprint, into: &buf) + FfiConverterOptionTypeNetwork.write(value.network, into: &buf) + FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletParams_lift(_ buf: RustBuffer) throws -> WalletParams { + return try FfiConverterTypeWalletParams.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletParams_lower(_ value: WalletParams) -> RustBuffer { + return FfiConverterTypeWalletParams.lower(value) +} + + +/** + * Parameters for starting an xpub transaction watcher. + */ +public struct WatcherParams { + /** + * Caller-supplied identifier for this watcher. + */ + public var watcherId: String + /** + * Wallet id that scopes the activities this watcher emits. Apps may use + * one wallet id for several account watchers and merge their snapshots. + */ + public var walletId: String + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). + */ + public var extendedKey: String + /** + * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). + */ + public var electrumUrl: String + /** + * Bitcoin network override (auto-detected from key prefix if None). + */ + public var network: Network? + /** + * Account type override (auto-detected from key prefix if None). + */ + public var accountType: AccountType? + /** + * Number of unused addresses to monitor beyond the last used + * (defaults to `DEFAULT_GAP_LIMIT` when None). + */ + public var gapLimit: UInt32? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Caller-supplied identifier for this watcher. + */watcherId: String, + /** + * Wallet id that scopes the activities this watcher emits. Apps may use + * one wallet id for several account watchers and merge their snapshots. + */walletId: String, + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). + */extendedKey: String, + /** + * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). + */electrumUrl: String, + /** + * Bitcoin network override (auto-detected from key prefix if None). + */network: Network?, + /** + * Account type override (auto-detected from key prefix if None). + */accountType: AccountType?, + /** + * Number of unused addresses to monitor beyond the last used + * (defaults to `DEFAULT_GAP_LIMIT` when None). + */gapLimit: UInt32?) { + self.watcherId = watcherId + self.walletId = walletId + self.extendedKey = extendedKey + self.electrumUrl = electrumUrl + self.network = network + self.accountType = accountType + self.gapLimit = gapLimit + } +} + +#if compiler(>=6) +extension WatcherParams: Sendable {} +#endif + + +extension WatcherParams: Equatable, Hashable { + public static func ==(lhs: WatcherParams, rhs: WatcherParams) -> Bool { + if lhs.watcherId != rhs.watcherId { + return false + } + if lhs.walletId != rhs.walletId { + return false + } + if lhs.extendedKey != rhs.extendedKey { + return false + } + if lhs.electrumUrl != rhs.electrumUrl { + return false + } + if lhs.network != rhs.network { + return false + } + if lhs.accountType != rhs.accountType { + return false + } + if lhs.gapLimit != rhs.gapLimit { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(watcherId) + hasher.combine(walletId) + hasher.combine(extendedKey) + hasher.combine(electrumUrl) + hasher.combine(network) + hasher.combine(accountType) + hasher.combine(gapLimit) + } +} + +extension WatcherParams: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeWatcherParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WatcherParams { + return + try WatcherParams( + watcherId: FfiConverterString.read(from: &buf), + walletId: FfiConverterString.read(from: &buf), + extendedKey: FfiConverterString.read(from: &buf), + electrumUrl: FfiConverterString.read(from: &buf), + network: FfiConverterOptionTypeNetwork.read(from: &buf), + accountType: FfiConverterOptionTypeAccountType.read(from: &buf), + gapLimit: FfiConverterOptionUInt32.read(from: &buf) + ) + } + + public static func write(_ value: WatcherParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.watcherId, into: &buf) + FfiConverterString.write(value.walletId, into: &buf) + FfiConverterString.write(value.extendedKey, into: &buf) + FfiConverterString.write(value.electrumUrl, into: &buf) + FfiConverterOptionTypeNetwork.write(value.network, into: &buf) + FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) + FfiConverterOptionUInt32.write(value.gapLimit, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWatcherParams_lift(_ buf: RustBuffer) throws -> WatcherParams { + return try FfiConverterTypeWatcherParams.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWatcherParams_lower(_ value: WatcherParams) -> RustBuffer { + return FfiConverterTypeWatcherParams.lower(value) +} + + +/** + * Errors specific to account info operations (BDK/Electrum-based). + */ +public enum AccountInfoError: Swift.Error { + + + + /** + * The provided extended public key is invalid or cannot be parsed + */ + case InvalidExtendedKey(errorDetails: String + ) + /** + * The provided address is invalid + */ + case InvalidAddress(errorDetails: String + ) + /** + * Electrum connection or query failed + */ + case ElectrumError(errorDetails: String + ) + /** + * BDK wallet creation or operation error + */ + case WalletError(errorDetails: String + ) + /** + * Wallet sync with Electrum failed + */ + case SyncError(errorDetails: String + ) + /** + * The key type/prefix is not recognized + */ + case UnsupportedKeyType(errorDetails: String + ) + /** + * Network mismatch between key prefix and specified network + */ + case NetworkMismatch(errorDetails: String + ) + /** + * Invalid transaction ID provided + */ + case InvalidTxid(errorDetails: String + ) + /** + * A valid transaction ID was not found in the wallet + */ + case TransactionNotFound(errorDetails: String + ) + /** + * Watcher lifecycle or subscription error + */ + case WatcherError(errorDetails: String + ) +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAccountInfoError: FfiConverterRustBuffer { + typealias SwiftType = AccountInfoError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountInfoError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .InvalidExtendedKey( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .InvalidAddress( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 3: return .ElectrumError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 4: return .WalletError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 5: return .SyncError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 6: return .UnsupportedKeyType( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 7: return .NetworkMismatch( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 8: return .InvalidTxid( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 9: return .TransactionNotFound( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 10: return .WatcherError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AccountInfoError, into buf: inout [UInt8]) { + switch value { + + + + + + case let .InvalidExtendedKey(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InvalidAddress(errorDetails): + writeInt(&buf, Int32(2)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .ElectrumError(errorDetails): + writeInt(&buf, Int32(3)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .WalletError(errorDetails): + writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .SyncError(errorDetails): + writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .UnsupportedKeyType(errorDetails): + writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .NetworkMismatch(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InvalidTxid(errorDetails): + writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .TransactionNotFound(errorDetails): + writeInt(&buf, Int32(9)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .WatcherError(errorDetails): + writeInt(&buf, Int32(10)) + FfiConverterString.write(errorDetails, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAccountInfoError_lift(_ buf: RustBuffer) throws -> AccountInfoError { + return try FfiConverterTypeAccountInfoError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWatcherParams_lower(_ value: WatcherParams) -> RustBuffer { - return FfiConverterTypeWatcherParams.lower(value) +public func FfiConverterTypeAccountInfoError_lower(_ value: AccountInfoError) -> RustBuffer { + return FfiConverterTypeAccountInfoError.lower(value) +} + + +extension AccountInfoError: Equatable, Hashable {} + +extension AccountInfoError: Codable {} + + + + +extension AccountInfoError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } } + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. /** - * Errors specific to account info operations (BDK/Electrum-based). + * Account type classification for extended public keys. + * + * Determines the BIP standard, derivation path purpose, and script type. */ -public enum AccountInfoError: Swift.Error { - +public enum AccountType { /** - * The provided extended public key is invalid or cannot be parsed + * BIP44 legacy (P2PKH) — xpub/tpub prefix */ - case InvalidExtendedKey(errorDetails: String - ) + case legacy /** - * The provided address is invalid + * BIP49 wrapped segwit (P2SH-P2WPKH) — ypub/upub prefix */ - case InvalidAddress(errorDetails: String - ) + case wrappedSegwit /** - * Electrum connection or query failed + * BIP84 native segwit (P2WPKH) — zpub/vpub prefix */ - case ElectrumError(errorDetails: String - ) + case nativeSegwit /** - * BDK wallet creation or operation error + * BIP86 taproot (P2TR) */ - case WalletError(errorDetails: String + case taproot +} + + +#if compiler(>=6) +extension AccountType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAccountType: FfiConverterRustBuffer { + typealias SwiftType = AccountType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .legacy + + case 2: return .wrappedSegwit + + case 3: return .nativeSegwit + + case 4: return .taproot + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AccountType, into buf: inout [UInt8]) { + switch value { + + + case .legacy: + writeInt(&buf, Int32(1)) + + + case .wrappedSegwit: + writeInt(&buf, Int32(2)) + + + case .nativeSegwit: + writeInt(&buf, Int32(3)) + + + case .taproot: + writeInt(&buf, Int32(4)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAccountType_lift(_ buf: RustBuffer) throws -> AccountType { + return try FfiConverterTypeAccountType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAccountType_lower(_ value: AccountType) -> RustBuffer { + return FfiConverterTypeAccountType.lower(value) +} + + +extension AccountType: Equatable, Hashable {} + +extension AccountType: Codable {} + + + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum Activity { + + case onchain(OnchainActivity ) - /** - * Wallet sync with Electrum failed - */ - case SyncError(errorDetails: String + case lightning(LightningActivity ) - /** - * The key type/prefix is not recognized - */ - case UnsupportedKeyType(errorDetails: String +} + + +#if compiler(>=6) +extension Activity: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivity: FfiConverterRustBuffer { + typealias SwiftType = Activity + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Activity { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .onchain(try FfiConverterTypeOnchainActivity.read(from: &buf) + ) + + case 2: return .lightning(try FfiConverterTypeLightningActivity.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Activity, into buf: inout [UInt8]) { + switch value { + + + case let .onchain(v1): + writeInt(&buf, Int32(1)) + FfiConverterTypeOnchainActivity.write(v1, into: &buf) + + + case let .lightning(v1): + writeInt(&buf, Int32(2)) + FfiConverterTypeLightningActivity.write(v1, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivity_lift(_ buf: RustBuffer) throws -> Activity { + return try FfiConverterTypeActivity.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivity_lower(_ value: Activity) -> RustBuffer { + return FfiConverterTypeActivity.lower(value) +} + + +extension Activity: Equatable, Hashable {} + +extension Activity: Codable {} + + + + + + + +public enum ActivityError: Swift.Error { + + + + case InvalidActivity(errorDetails: String ) - /** - * Network mismatch between key prefix and specified network - */ - case NetworkMismatch(errorDetails: String + case InitializationError(errorDetails: String ) - /** - * Invalid transaction ID provided - */ - case InvalidTxid(errorDetails: String + case InsertError(errorDetails: String ) - /** - * A valid transaction ID was not found in the wallet - */ - case TransactionNotFound(errorDetails: String + case RetrievalError(errorDetails: String ) - /** - * Watcher lifecycle or subscription error - */ - case WatcherError(errorDetails: String + case DataError(errorDetails: String + ) + case ConnectionError(errorDetails: String + ) + case SerializationError(errorDetails: String ) } @@ -20073,44 +21374,35 @@ public enum AccountInfoError: Swift.Error { #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAccountInfoError: FfiConverterRustBuffer { - typealias SwiftType = AccountInfoError +public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { + typealias SwiftType = ActivityError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountInfoError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InvalidExtendedKey( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .InvalidAddress( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .ElectrumError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .WalletError( + case 1: return .InvalidActivity( errorDetails: try FfiConverterString.read(from: &buf) ) - case 5: return .SyncError( + case 2: return .InitializationError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 6: return .UnsupportedKeyType( + case 3: return .InsertError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 7: return .NetworkMismatch( + case 4: return .RetrievalError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 8: return .InvalidTxid( + case 5: return .DataError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 9: return .TransactionNotFound( + case 6: return .ConnectionError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 10: return .WatcherError( + case 7: return .SerializationError( errorDetails: try FfiConverterString.read(from: &buf) ) @@ -20118,62 +21410,47 @@ public struct FfiConverterTypeAccountInfoError: FfiConverterRustBuffer { } } - public static func write(_ value: AccountInfoError, into buf: inout [UInt8]) { + public static func write(_ value: ActivityError, into buf: inout [UInt8]) { switch value { - case let .InvalidExtendedKey(errorDetails): + case let .InvalidActivity(errorDetails): writeInt(&buf, Int32(1)) FfiConverterString.write(errorDetails, into: &buf) - case let .InvalidAddress(errorDetails): + case let .InitializationError(errorDetails): writeInt(&buf, Int32(2)) FfiConverterString.write(errorDetails, into: &buf) - case let .ElectrumError(errorDetails): + case let .InsertError(errorDetails): writeInt(&buf, Int32(3)) FfiConverterString.write(errorDetails, into: &buf) - case let .WalletError(errorDetails): + case let .RetrievalError(errorDetails): writeInt(&buf, Int32(4)) FfiConverterString.write(errorDetails, into: &buf) - case let .SyncError(errorDetails): + case let .DataError(errorDetails): writeInt(&buf, Int32(5)) FfiConverterString.write(errorDetails, into: &buf) - case let .UnsupportedKeyType(errorDetails): + case let .ConnectionError(errorDetails): writeInt(&buf, Int32(6)) FfiConverterString.write(errorDetails, into: &buf) - case let .NetworkMismatch(errorDetails): + case let .SerializationError(errorDetails): writeInt(&buf, Int32(7)) FfiConverterString.write(errorDetails, into: &buf) - - case let .InvalidTxid(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .TransactionNotFound(errorDetails): - writeInt(&buf, Int32(9)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .WatcherError(errorDetails): - writeInt(&buf, Int32(10)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -20182,26 +21459,26 @@ public struct FfiConverterTypeAccountInfoError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountInfoError_lift(_ buf: RustBuffer) throws -> AccountInfoError { - return try FfiConverterTypeAccountInfoError.lift(buf) +public func FfiConverterTypeActivityError_lift(_ buf: RustBuffer) throws -> ActivityError { + return try FfiConverterTypeActivityError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountInfoError_lower(_ value: AccountInfoError) -> RustBuffer { - return FfiConverterTypeAccountInfoError.lower(value) +public func FfiConverterTypeActivityError_lower(_ value: ActivityError) -> RustBuffer { + return FfiConverterTypeActivityError.lower(value) } -extension AccountInfoError: Equatable, Hashable {} +extension ActivityError: Equatable, Hashable {} -extension AccountInfoError: Codable {} +extension ActivityError: Codable {} -extension AccountInfoError: Foundation.LocalizedError { +extension ActivityError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -20212,78 +21489,223 @@ extension AccountInfoError: Foundation.LocalizedError { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Account type classification for extended public keys. - * - * Determines the BIP standard, derivation path purpose, and script type. - */ -public enum AccountType { +public enum ActivityFilter { - /** - * BIP44 legacy (P2PKH) — xpub/tpub prefix - */ - case legacy - /** - * BIP49 wrapped segwit (P2SH-P2WPKH) — ypub/upub prefix - */ - case wrappedSegwit - /** - * BIP84 native segwit (P2WPKH) — zpub/vpub prefix - */ - case nativeSegwit - /** - * BIP86 taproot (P2TR) - */ - case taproot + case all + case lightning + case onchain } #if compiler(>=6) -extension AccountType: Sendable {} +extension ActivityFilter: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAccountType: FfiConverterRustBuffer { - typealias SwiftType = AccountType +public struct FfiConverterTypeActivityFilter: FfiConverterRustBuffer { + typealias SwiftType = ActivityFilter - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityFilter { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .legacy + case 1: return .all - case 2: return .wrappedSegwit + case 2: return .lightning - case 3: return .nativeSegwit + case 3: return .onchain - case 4: return .taproot + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ActivityFilter, into buf: inout [UInt8]) { + switch value { + + + case .all: + writeInt(&buf, Int32(1)) + + + case .lightning: + writeInt(&buf, Int32(2)) + + + case .onchain: + writeInt(&buf, Int32(3)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityFilter_lift(_ buf: RustBuffer) throws -> ActivityFilter { + return try FfiConverterTypeActivityFilter.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityFilter_lower(_ value: ActivityFilter) -> RustBuffer { + return FfiConverterTypeActivityFilter.lower(value) +} + + +extension ActivityFilter: Equatable, Hashable {} + +extension ActivityFilter: Codable {} + + + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum ActivityType { + + case onchain + case lightning +} + + +#if compiler(>=6) +extension ActivityType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivityType: FfiConverterRustBuffer { + typealias SwiftType = ActivityType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .onchain + + case 2: return .lightning default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AccountType, into buf: inout [UInt8]) { + public static func write(_ value: ActivityType, into buf: inout [UInt8]) { + switch value { + + + case .onchain: + writeInt(&buf, Int32(1)) + + + case .lightning: + writeInt(&buf, Int32(2)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityType_lift(_ buf: RustBuffer) throws -> ActivityType { + return try FfiConverterTypeActivityType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityType_lower(_ value: ActivityType) -> RustBuffer { + return FfiConverterTypeActivityType.lower(value) +} + + +extension ActivityType: Equatable, Hashable {} + +extension ActivityType: Codable {} + + + + + + + +public enum AddressError: Swift.Error { + + + + case InvalidAddress + case InvalidNetwork + case MnemonicGenerationFailed + case InvalidMnemonic + case InvalidEntropy + case AddressDerivationFailed +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { + typealias SwiftType = AddressError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .InvalidAddress + case 2: return .InvalidNetwork + case 3: return .MnemonicGenerationFailed + case 4: return .InvalidMnemonic + case 5: return .InvalidEntropy + case 6: return .AddressDerivationFailed + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AddressError, into buf: inout [UInt8]) { switch value { + + + - case .legacy: + case .InvalidAddress: writeInt(&buf, Int32(1)) - case .wrappedSegwit: + case .InvalidNetwork: writeInt(&buf, Int32(2)) - case .nativeSegwit: + case .MnemonicGenerationFailed: writeInt(&buf, Int32(3)) - case .taproot: + case .InvalidMnemonic: writeInt(&buf, Int32(4)) + + case .InvalidEntropy: + writeInt(&buf, Int32(5)) + + + case .AddressDerivationFailed: + writeInt(&buf, Int32(6)) + } } } @@ -20292,76 +21714,105 @@ public struct FfiConverterTypeAccountType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountType_lift(_ buf: RustBuffer) throws -> AccountType { - return try FfiConverterTypeAccountType.lift(buf) +public func FfiConverterTypeAddressError_lift(_ buf: RustBuffer) throws -> AddressError { + return try FfiConverterTypeAddressError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountType_lower(_ value: AccountType) -> RustBuffer { - return FfiConverterTypeAccountType.lower(value) +public func FfiConverterTypeAddressError_lower(_ value: AddressError) -> RustBuffer { + return FfiConverterTypeAddressError.lower(value) } -extension AccountType: Equatable, Hashable {} +extension AddressError: Equatable, Hashable {} -extension AccountType: Codable {} +extension AddressError: Codable {} +extension AddressError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} + + // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum Activity { +public enum AddressType { - case onchain(OnchainActivity - ) - case lightning(LightningActivity - ) + case p2pkh + case p2sh + case p2wpkh + case p2wsh + case p2tr + case unknown } #if compiler(>=6) -extension Activity: Sendable {} +extension AddressType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivity: FfiConverterRustBuffer { - typealias SwiftType = Activity +public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { + typealias SwiftType = AddressType - 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 -> AddressType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .onchain(try FfiConverterTypeOnchainActivity.read(from: &buf) - ) + case 1: return .p2pkh - case 2: return .lightning(try FfiConverterTypeLightningActivity.read(from: &buf) - ) + case 2: return .p2sh + + case 3: return .p2wpkh + + case 4: return .p2wsh + + case 5: return .p2tr + + case 6: return .unknown default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: Activity, into buf: inout [UInt8]) { + public static func write(_ value: AddressType, into buf: inout [UInt8]) { switch value { - case let .onchain(v1): + case .p2pkh: writeInt(&buf, Int32(1)) - FfiConverterTypeOnchainActivity.write(v1, into: &buf) - - case let .lightning(v1): + + case .p2sh: writeInt(&buf, Int32(2)) - FfiConverterTypeLightningActivity.write(v1, into: &buf) - + + + case .p2wpkh: + writeInt(&buf, Int32(3)) + + + case .p2wsh: + writeInt(&buf, Int32(4)) + + + case .p2tr: + writeInt(&buf, Int32(5)) + + + case .unknown: + writeInt(&buf, Int32(6)) + } } } @@ -20370,21 +21821,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 FfiConverterTypeAddressType_lift(_ buf: RustBuffer) throws -> AddressType { + return try FfiConverterTypeAddressType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivity_lower(_ value: Activity) -> RustBuffer { - return FfiConverterTypeActivity.lower(value) +public func FfiConverterTypeAddressType_lower(_ value: AddressType) -> RustBuffer { + return FfiConverterTypeAddressType.lower(value) } -extension Activity: Equatable, Hashable {} +extension AddressType: Equatable, Hashable {} -extension Activity: Codable {} +extension AddressType: Codable {} @@ -20392,23 +21843,27 @@ extension Activity: Codable {} -public enum ActivityError: Swift.Error { +/** + * Errors surfaced by the Arkade module. + */ +public enum ArkadeError: Swift.Error { - case InvalidActivity(errorDetails: String + case NotStarted + case InvalidInput(errorDetails: String ) - case InitializationError(errorDetails: String + case ArkError(errorDetails: String ) - case InsertError(errorDetails: String + case LnurlError(errorDetails: String ) - case RetrievalError(errorDetails: String + case SwapError(errorDetails: String ) - case DataError(errorDetails: String + case NetworkError(errorDetails: String ) - case ConnectionError(errorDetails: String + case DatabaseError(errorDetails: String ) - case SerializationError(errorDetails: String + case InternalError(errorDetails: String ) } @@ -20416,35 +21871,36 @@ public enum ActivityError: Swift.Error { #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { - typealias SwiftType = ActivityError +public struct FfiConverterTypeArkadeError: FfiConverterRustBuffer { + typealias SwiftType = ArkadeError - 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 -> ArkadeError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InvalidActivity( + case 1: return .NotStarted + case 2: return .InvalidInput( errorDetails: try FfiConverterString.read(from: &buf) ) - case 2: return .InitializationError( + case 3: return .ArkError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 3: return .InsertError( + case 4: return .LnurlError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 4: return .RetrievalError( + case 5: return .SwapError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 5: return .DataError( + case 6: return .NetworkError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 6: return .ConnectionError( + case 7: return .DatabaseError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 7: return .SerializationError( + case 8: return .InternalError( errorDetails: try FfiConverterString.read(from: &buf) ) @@ -20452,133 +21908,51 @@ public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { } } - public static func write(_ value: ActivityError, into buf: inout [UInt8]) { + public static func write(_ value: ArkadeError, into buf: inout [UInt8]) { switch value { - case let .InvalidActivity(errorDetails): + case .NotStarted: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InitializationError(errorDetails): + + case let .InvalidInput(errorDetails): writeInt(&buf, Int32(2)) FfiConverterString.write(errorDetails, into: &buf) - case let .InsertError(errorDetails): + case let .ArkError(errorDetails): writeInt(&buf, Int32(3)) FfiConverterString.write(errorDetails, into: &buf) - case let .RetrievalError(errorDetails): + case let .LnurlError(errorDetails): writeInt(&buf, Int32(4)) FfiConverterString.write(errorDetails, into: &buf) - case let .DataError(errorDetails): + case let .SwapError(errorDetails): writeInt(&buf, Int32(5)) FfiConverterString.write(errorDetails, into: &buf) - case let .ConnectionError(errorDetails): + case let .NetworkError(errorDetails): writeInt(&buf, Int32(6)) FfiConverterString.write(errorDetails, into: &buf) - case let .SerializationError(errorDetails): + case let .DatabaseError(errorDetails): writeInt(&buf, Int32(7)) FfiConverterString.write(errorDetails, into: &buf) - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActivityError_lift(_ buf: RustBuffer) throws -> ActivityError { - return try FfiConverterTypeActivityError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActivityError_lower(_ value: ActivityError) -> RustBuffer { - return FfiConverterTypeActivityError.lower(value) -} - - -extension ActivityError: Equatable, Hashable {} - -extension ActivityError: Codable {} - - - - -extension ActivityError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. - -public enum ActivityFilter { - - case all - case lightning - case onchain -} - - -#if compiler(>=6) -extension ActivityFilter: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeActivityFilter: FfiConverterRustBuffer { - typealias SwiftType = ActivityFilter - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityFilter { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .all - - case 2: return .lightning - - case 3: return .onchain - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ActivityFilter, into buf: inout [UInt8]) { - switch value { - - - case .all: - writeInt(&buf, Int32(1)) - - - case .lightning: - writeInt(&buf, Int32(2)) - - - case .onchain: - writeInt(&buf, Int32(3)) + case let .InternalError(errorDetails): + writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -20587,23 +21961,30 @@ 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 FfiConverterTypeArkadeError_lift(_ buf: RustBuffer) throws -> ArkadeError { + return try FfiConverterTypeArkadeError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityFilter_lower(_ value: ActivityFilter) -> RustBuffer { - return FfiConverterTypeActivityFilter.lower(value) +public func FfiConverterTypeArkadeError_lower(_ value: ArkadeError) -> RustBuffer { + return FfiConverterTypeArkadeError.lower(value) } -extension ActivityFilter: Equatable, Hashable {} +extension ArkadeError: Equatable, Hashable {} + +extension ArkadeError: Codable {} + -extension ActivityFilter: Codable {} +extension ArkadeError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} @@ -20611,46 +21992,65 @@ 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 ArkadeNetwork { - case onchain - case lightning + /** + * Mainnet, against Ark Labs' operator. + */ + case bitcoin + /** + * Arkade's signet, for dev builds. + */ + case mutinynet + /** + * A local regtest stack (operator, esplora, solver, LNURL server), for dev builds and tests. + */ + case regtest(endpoints: ArkadeRegtestEndpoints + ) } #if compiler(>=6) -extension ActivityType: Sendable {} +extension ArkadeNetwork: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivityType: FfiConverterRustBuffer { - typealias SwiftType = ActivityType +public struct FfiConverterTypeArkadeNetwork: FfiConverterRustBuffer { + typealias SwiftType = ArkadeNetwork - 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 -> ArkadeNetwork { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .onchain + case 1: return .bitcoin - case 2: return .lightning + case 2: return .mutinynet + + case 3: return .regtest(endpoints: try FfiConverterTypeArkadeRegtestEndpoints.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ActivityType, into buf: inout [UInt8]) { + public static func write(_ value: ArkadeNetwork, into buf: inout [UInt8]) { switch value { - case .onchain: + case .bitcoin: writeInt(&buf, Int32(1)) - case .lightning: + case .mutinynet: writeInt(&buf, Int32(2)) + + case let .regtest(endpoints): + writeInt(&buf, Int32(3)) + FfiConverterTypeArkadeRegtestEndpoints.write(endpoints, into: &buf) + } } } @@ -20659,95 +22059,84 @@ 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 FfiConverterTypeArkadeNetwork_lift(_ buf: RustBuffer) throws -> ArkadeNetwork { + return try FfiConverterTypeArkadeNetwork.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityType_lower(_ value: ActivityType) -> RustBuffer { - return FfiConverterTypeActivityType.lower(value) +public func FfiConverterTypeArkadeNetwork_lower(_ value: ArkadeNetwork) -> RustBuffer { + return FfiConverterTypeArkadeNetwork.lower(value) } -extension ActivityType: Equatable, Hashable {} - -extension ActivityType: Codable {} +extension ArkadeNetwork: Equatable, Hashable {} +extension ArkadeNetwork: Codable {} -public enum AddressError: 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 BitcoinNetworkEnum { - - case InvalidAddress - case InvalidNetwork - case MnemonicGenerationFailed - case InvalidMnemonic - case InvalidEntropy - case AddressDerivationFailed + case mainnet + case testnet + case signet + case regtest } +#if compiler(>=6) +extension BitcoinNetworkEnum: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { - typealias SwiftType = AddressError +public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { + typealias SwiftType = BitcoinNetworkEnum - 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 -> BitcoinNetworkEnum { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .mainnet - 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 + case 2: return .testnet + + case 3: return .signet + + case 4: return .regtest + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AddressError, into buf: inout [UInt8]) { + public static func write(_ value: BitcoinNetworkEnum, into buf: inout [UInt8]) { switch value { - - - - case .InvalidAddress: + case .mainnet: writeInt(&buf, Int32(1)) - case .InvalidNetwork: + case .testnet: writeInt(&buf, Int32(2)) - case .MnemonicGenerationFailed: + case .signet: writeInt(&buf, Int32(3)) - case .InvalidMnemonic: + case .regtest: writeInt(&buf, Int32(4)) - - case .InvalidEntropy: - writeInt(&buf, Int32(5)) - - - case .AddressDerivationFailed: - writeInt(&buf, Int32(6)) - } } } @@ -20756,105 +22145,191 @@ public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressError_lift(_ buf: RustBuffer) throws -> AddressError { - return try FfiConverterTypeAddressError.lift(buf) +public func FfiConverterTypeBitcoinNetworkEnum_lift(_ buf: RustBuffer) throws -> BitcoinNetworkEnum { + return try FfiConverterTypeBitcoinNetworkEnum.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressError_lower(_ value: AddressError) -> RustBuffer { - return FfiConverterTypeAddressError.lower(value) +public func FfiConverterTypeBitcoinNetworkEnum_lower(_ value: BitcoinNetworkEnum) -> RustBuffer { + return FfiConverterTypeBitcoinNetworkEnum.lower(value) } -extension AddressError: Equatable, Hashable {} - -extension AddressError: Codable {} +extension BitcoinNetworkEnum: Equatable, Hashable {} +extension BitcoinNetworkEnum: Codable {} -extension AddressError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum BlocktankError: Swift.Error { -public enum AddressType { - case p2pkh - case p2sh - case p2wpkh - case p2wsh - case p2tr - case unknown + + 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 compiler(>=6) -extension AddressType: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { - typealias SwiftType = AddressType +public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { + typealias SwiftType = BlocktankError - 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 -> BlocktankError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .p2pkh - - case 2: return .p2sh - - case 3: return .p2wpkh - - case 4: return .p2wsh - - case 5: return .p2tr - - case 6: return .unknown + - default: throw UniffiInternalError.unexpectedEnumCase + 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: AddressType, into buf: inout [UInt8]) { + public static func write(_ value: BlocktankError, into buf: inout [UInt8]) { switch value { + + - case .p2pkh: - writeInt(&buf, Int32(1)) + case let .HttpClient(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + - case .p2sh: + case let .BlocktankClient(errorDetails): writeInt(&buf, Int32(2)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .p2wpkh: + case let .InvalidBlocktank(errorDetails): writeInt(&buf, Int32(3)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .p2wsh: + case let .InitializationError(errorDetails): writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .p2tr: + case let .InsertError(errorDetails): writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .unknown: + 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) + } } } @@ -20863,49 +22338,59 @@ 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 FfiConverterTypeBlocktankError_lift(_ buf: RustBuffer) throws -> BlocktankError { + return try FfiConverterTypeBlocktankError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressType_lower(_ value: AddressType) -> RustBuffer { - return FfiConverterTypeAddressType.lower(value) +public func FfiConverterTypeBlocktankError_lower(_ value: BlocktankError) -> RustBuffer { + return FfiConverterTypeBlocktankError.lower(value) } -extension AddressType: Equatable, Hashable {} +extension BlocktankError: Equatable, Hashable {} + +extension BlocktankError: Codable {} -extension AddressType: Codable {} +extension BlocktankError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} + /** - * Errors surfaced by the Arkade module. + * Errors surfaced by the Boltz swaps module. */ -public enum ArkadeError: Swift.Error { +public enum BoltzError: Swift.Error { - case NotStarted - case InvalidInput(errorDetails: String + case InitializationError(errorDetails: String ) - case ArkError(errorDetails: String + case ConnectionError(errorDetails: String ) - case LnurlError(errorDetails: String + case DatabaseError(errorDetails: String + ) + case ApiError(errorDetails: String ) case SwapError(errorDetails: String ) - case NetworkError(errorDetails: String + case BroadcastError(errorDetails: String ) - case DatabaseError(errorDetails: String + case InvalidInput(errorDetails: String ) - case InternalError(errorDetails: String + case SerializationError(errorDetails: String + ) + case NotFound(errorDetails: String ) } @@ -20913,36 +22398,41 @@ public enum ArkadeError: Swift.Error { #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeArkadeError: FfiConverterRustBuffer { - typealias SwiftType = ArkadeError +public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { + typealias SwiftType = BoltzError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ArkadeError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .NotStarted - case 2: return .InvalidInput( + case 1: return .InitializationError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 3: return .ArkError( + case 2: return .ConnectionError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 4: return .LnurlError( + case 3: return .DatabaseError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 4: return .ApiError( errorDetails: try FfiConverterString.read(from: &buf) ) case 5: return .SwapError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 6: return .NetworkError( + case 6: return .BroadcastError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 7: return .DatabaseError( + case 7: return .InvalidInput( errorDetails: try FfiConverterString.read(from: &buf) ) - case 8: return .InternalError( + case 8: return .SerializationError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 9: return .NotFound( errorDetails: try FfiConverterString.read(from: &buf) ) @@ -20950,28 +22440,29 @@ public struct FfiConverterTypeArkadeError: FfiConverterRustBuffer { } } - public static func write(_ value: ArkadeError, into buf: inout [UInt8]) { + public static func write(_ value: BoltzError, into buf: inout [UInt8]) { switch value { - case .NotStarted: + case let .InitializationError(errorDetails): writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + - - case let .InvalidInput(errorDetails): + case let .ConnectionError(errorDetails): writeInt(&buf, Int32(2)) FfiConverterString.write(errorDetails, into: &buf) - case let .ArkError(errorDetails): + case let .DatabaseError(errorDetails): writeInt(&buf, Int32(3)) FfiConverterString.write(errorDetails, into: &buf) - case let .LnurlError(errorDetails): + case let .ApiError(errorDetails): writeInt(&buf, Int32(4)) FfiConverterString.write(errorDetails, into: &buf) @@ -20981,20 +22472,115 @@ public struct FfiConverterTypeArkadeError: FfiConverterRustBuffer { FfiConverterString.write(errorDetails, into: &buf) - case let .NetworkError(errorDetails): - writeInt(&buf, Int32(6)) - FfiConverterString.write(errorDetails, into: &buf) - + case let .BroadcastError(errorDetails): + writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InvalidInput(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .SerializationError(errorDetails): + writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .NotFound(errorDetails): + writeInt(&buf, Int32(9)) + FfiConverterString.write(errorDetails, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeBoltzError_lift(_ buf: RustBuffer) throws -> BoltzError { + return try FfiConverterTypeBoltzError.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeBoltzError_lower(_ value: BoltzError) -> RustBuffer { + return FfiConverterTypeBoltzError.lower(value) +} + + +extension BoltzError: Equatable, Hashable {} + +extension BoltzError: Codable {} + + + + +extension BoltzError: 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 network selection for Boltz swaps. Maps to the networks Boltz + * operates on (mainnet, testnet, regtest). + */ + +public enum BoltzNetwork { + + case mainnet + case testnet + case regtest +} + + +#if compiler(>=6) +extension BoltzNetwork: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeBoltzNetwork: FfiConverterRustBuffer { + typealias SwiftType = BoltzNetwork + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzNetwork { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .mainnet + + case 2: return .testnet + + case 3: return .regtest + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: BoltzNetwork, into buf: inout [UInt8]) { + switch value { + + + case .mainnet: + writeInt(&buf, Int32(1)) + + + case .testnet: + writeInt(&buf, Int32(2)) + - case let .DatabaseError(errorDetails): - writeInt(&buf, Int32(7)) - FfiConverterString.write(errorDetails, into: &buf) - + case .regtest: + writeInt(&buf, Int32(3)) - case let .InternalError(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -21003,95 +22589,115 @@ public struct FfiConverterTypeArkadeError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeArkadeError_lift(_ buf: RustBuffer) throws -> ArkadeError { - return try FfiConverterTypeArkadeError.lift(buf) +public func FfiConverterTypeBoltzNetwork_lift(_ buf: RustBuffer) throws -> BoltzNetwork { + return try FfiConverterTypeBoltzNetwork.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeArkadeError_lower(_ value: ArkadeError) -> RustBuffer { - return FfiConverterTypeArkadeError.lower(value) +public func FfiConverterTypeBoltzNetwork_lower(_ value: BoltzNetwork) -> RustBuffer { + return FfiConverterTypeBoltzNetwork.lower(value) } -extension ArkadeError: Equatable, Hashable {} - -extension ArkadeError: Codable {} - +extension BoltzNetwork: Equatable, Hashable {} +extension BoltzNetwork: Codable {} -extension ArkadeError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Events emitted to a registered [`crate::modules::boltz::BoltzEventListener`] + * as swaps progress through their lifecycle. + */ -public enum ArkadeNetwork { +public enum BoltzSwapEvent { /** - * Mainnet, against Ark Labs' operator. + * The swap transitioned to a new status. */ - case bitcoin + case statusUpdate(swapId: String, status: BoltzSwapStatus + ) /** - * Arkade's signet, for dev builds. + * A reverse swap was claimed onchain. `txid` is the claim transaction. */ - case mutinynet + case claimed(swapId: String, txid: String + ) /** - * A local regtest stack (operator, esplora, solver, LNURL server), for dev builds and tests. + * A submarine swap was refunded onchain. `txid` is the refund transaction. */ - case regtest(endpoints: ArkadeRegtestEndpoints + case refunded(swapId: String, txid: String + ) + /** + * An error occurred while processing the swap (e.g. an auto-claim failed). + */ + case error(swapId: String, message: String ) } #if compiler(>=6) -extension ArkadeNetwork: Sendable {} +extension BoltzSwapEvent: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeArkadeNetwork: FfiConverterRustBuffer { - typealias SwiftType = ArkadeNetwork +public struct FfiConverterTypeBoltzSwapEvent: FfiConverterRustBuffer { + typealias SwiftType = BoltzSwapEvent - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ArkadeNetwork { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapEvent { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .bitcoin + case 1: return .statusUpdate(swapId: try FfiConverterString.read(from: &buf), status: try FfiConverterTypeBoltzSwapStatus.read(from: &buf) + ) - case 2: return .mutinynet + case 2: return .claimed(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) + ) - case 3: return .regtest(endpoints: try FfiConverterTypeArkadeRegtestEndpoints.read(from: &buf) + case 3: return .refunded(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) + ) + + case 4: return .error(swapId: try FfiConverterString.read(from: &buf), message: try FfiConverterString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ArkadeNetwork, into buf: inout [UInt8]) { + public static func write(_ value: BoltzSwapEvent, into buf: inout [UInt8]) { switch value { - case .bitcoin: + case let .statusUpdate(swapId,status): writeInt(&buf, Int32(1)) + FfiConverterString.write(swapId, into: &buf) + FfiConverterTypeBoltzSwapStatus.write(status, into: &buf) + - - case .mutinynet: + case let .claimed(swapId,txid): writeInt(&buf, Int32(2)) + FfiConverterString.write(swapId, into: &buf) + FfiConverterString.write(txid, into: &buf) + - - case let .regtest(endpoints): + case let .refunded(swapId,txid): writeInt(&buf, Int32(3)) - FfiConverterTypeArkadeRegtestEndpoints.write(endpoints, into: &buf) + FfiConverterString.write(swapId, into: &buf) + FfiConverterString.write(txid, into: &buf) + + + case let .error(swapId,message): + writeInt(&buf, Int32(4)) + FfiConverterString.write(swapId, into: &buf) + FfiConverterString.write(message, into: &buf) } } @@ -21101,21 +22707,21 @@ public struct FfiConverterTypeArkadeNetwork: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeArkadeNetwork_lift(_ buf: RustBuffer) throws -> ArkadeNetwork { - return try FfiConverterTypeArkadeNetwork.lift(buf) +public func FfiConverterTypeBoltzSwapEvent_lift(_ buf: RustBuffer) throws -> BoltzSwapEvent { + return try FfiConverterTypeBoltzSwapEvent.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeArkadeNetwork_lower(_ value: ArkadeNetwork) -> RustBuffer { - return FfiConverterTypeArkadeNetwork.lower(value) +public func FfiConverterTypeBoltzSwapEvent_lower(_ value: BoltzSwapEvent) -> RustBuffer { + return FfiConverterTypeBoltzSwapEvent.lower(value) } -extension ArkadeNetwork: Equatable, Hashable {} +extension BoltzSwapEvent: Equatable, Hashable {} -extension ArkadeNetwork: Codable {} +extension BoltzSwapEvent: Codable {} @@ -21124,61 +22730,202 @@ extension ArkadeNetwork: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Typed view of the Boltz swap lifecycle. `Unknown` carries the raw status so + * new server-side states don't break the bindings. + * + * See . + */ -public enum BitcoinNetworkEnum { +public enum BoltzSwapStatus { - case mainnet - case testnet - case signet - case regtest + /** + * `swap.created` — initial state. + */ + case swapCreated + /** + * `invoice.set` — invoice attached to a submarine swap. + */ + case invoiceSet + /** + * `transaction.mempool` — a lockup transaction is in the mempool. + */ + case transactionMempool + /** + * `transaction.confirmed` — a lockup transaction confirmed. + */ + case transactionConfirmed + /** + * `invoice.pending` — Boltz is paying the submarine swap invoice. + */ + case invoicePending + /** + * `invoice.paid` — submarine swap invoice paid by Boltz. + */ + case invoicePaid + /** + * `invoice.settled` — reverse swap invoice settled (preimage revealed). + */ + case invoiceSettled + /** + * `invoice.failedToPay` — submarine swap invoice could not be paid; refund. + */ + case invoiceFailedToPay + /** + * `invoice.expired` — reverse swap invoice expired before payment. + */ + case invoiceExpired + /** + * `transaction.claim.pending` — Boltz ready for a cooperative claim. + */ + case transactionClaimPending + /** + * `transaction.claimed` — onchain funds claimed. + */ + case transactionClaimed + /** + * `transaction.refunded` — onchain funds refunded. + */ + case transactionRefunded + /** + * `transaction.lockupFailed` — wrong amount locked; can refund. + */ + case transactionLockupFailed + /** + * `transaction.failed` — Boltz failed to lock the agreed funds. + */ + case transactionFailed + /** + * `swap.expired` — swap expired without completing. + */ + case swapExpired + /** + * Any status not yet modelled. `raw` holds the verbatim Boltz status. + */ + case unknown(raw: String + ) } #if compiler(>=6) -extension BitcoinNetworkEnum: Sendable {} +extension BoltzSwapStatus: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { - typealias SwiftType = BitcoinNetworkEnum +public struct FfiConverterTypeBoltzSwapStatus: FfiConverterRustBuffer { + typealias SwiftType = BoltzSwapStatus - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BitcoinNetworkEnum { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapStatus { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .mainnet + case 1: return .swapCreated + + case 2: return .invoiceSet + + case 3: return .transactionMempool + + case 4: return .transactionConfirmed + + case 5: return .invoicePending + + case 6: return .invoicePaid + + case 7: return .invoiceSettled + + case 8: return .invoiceFailedToPay + + case 9: return .invoiceExpired + + case 10: return .transactionClaimPending + + case 11: return .transactionClaimed + + case 12: return .transactionRefunded + + case 13: return .transactionLockupFailed + + case 14: return .transactionFailed + + case 15: return .swapExpired + + case 16: return .unknown(raw: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: BoltzSwapStatus, into buf: inout [UInt8]) { + switch value { + + + case .swapCreated: + writeInt(&buf, Int32(1)) + + + case .invoiceSet: + writeInt(&buf, Int32(2)) + + + case .transactionMempool: + writeInt(&buf, Int32(3)) + + + case .transactionConfirmed: + writeInt(&buf, Int32(4)) + - case 2: return .testnet + case .invoicePending: + writeInt(&buf, Int32(5)) - case 3: return .signet - case 4: return .regtest + case .invoicePaid: + writeInt(&buf, Int32(6)) - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: BitcoinNetworkEnum, into buf: inout [UInt8]) { - switch value { + + case .invoiceSettled: + writeInt(&buf, Int32(7)) - case .mainnet: - writeInt(&buf, Int32(1)) + case .invoiceFailedToPay: + writeInt(&buf, Int32(8)) - case .testnet: - writeInt(&buf, Int32(2)) + case .invoiceExpired: + writeInt(&buf, Int32(9)) - case .signet: - writeInt(&buf, Int32(3)) + case .transactionClaimPending: + writeInt(&buf, Int32(10)) - case .regtest: - writeInt(&buf, Int32(4)) + case .transactionClaimed: + writeInt(&buf, Int32(11)) + + + case .transactionRefunded: + writeInt(&buf, Int32(12)) + + + case .transactionLockupFailed: + writeInt(&buf, Int32(13)) + + + case .transactionFailed: + writeInt(&buf, Int32(14)) + + + case .swapExpired: + writeInt(&buf, Int32(15)) + + case let .unknown(raw): + writeInt(&buf, Int32(16)) + FfiConverterString.write(raw, into: &buf) + } } } @@ -21187,191 +22934,78 @@ public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBitcoinNetworkEnum_lift(_ buf: RustBuffer) throws -> BitcoinNetworkEnum { - return try FfiConverterTypeBitcoinNetworkEnum.lift(buf) +public func FfiConverterTypeBoltzSwapStatus_lift(_ buf: RustBuffer) throws -> BoltzSwapStatus { + return try FfiConverterTypeBoltzSwapStatus.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBitcoinNetworkEnum_lower(_ value: BitcoinNetworkEnum) -> RustBuffer { - return FfiConverterTypeBitcoinNetworkEnum.lower(value) +public func FfiConverterTypeBoltzSwapStatus_lower(_ value: BoltzSwapStatus) -> RustBuffer { + return FfiConverterTypeBoltzSwapStatus.lower(value) } -extension BitcoinNetworkEnum: Equatable, Hashable {} - -extension BitcoinNetworkEnum: Codable {} +extension BoltzSwapStatus: Equatable, Hashable {} +extension BoltzSwapStatus: Codable {} -public enum BlocktankError: Swift.Error { +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * The direction of a Boltz swap. + * + * - `Submarine`: onchain Bitcoin -> Lightning (the user locks onchain funds, + * Boltz pays a Lightning invoice). + * - `Reverse`: Lightning -> onchain Bitcoin (the user pays a Boltz hold + * invoice, Boltz locks onchain funds the user then claims). + */ +public enum BoltzSwapType { - - case HttpClient(errorDetails: String - ) - case BlocktankClient(errorDetails: String - ) - case InvalidBlocktank(errorDetails: String - ) - case InitializationError(errorDetails: String - ) - case InsertError(errorDetails: String - ) - case RetrievalError(errorDetails: String - ) - case DataError(errorDetails: String - ) - case ConnectionError(errorDetails: String - ) - case SerializationError(errorDetails: String - ) - case ChannelOpen(errorType: BtChannelOrderErrorType, errorDetails: String - ) - case OrderState(errorDetails: String - ) - case InvalidParameter(errorDetails: String - ) - case DatabaseError(errorDetails: String - ) + case submarine + case reverse } +#if compiler(>=6) +extension BoltzSwapType: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { - typealias SwiftType = BlocktankError +public struct FfiConverterTypeBoltzSwapType: FfiConverterRustBuffer { + typealias SwiftType = BoltzSwapType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BlocktankError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapType { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .submarine - case 1: return .HttpClient( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .BlocktankClient( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .InvalidBlocktank( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .InitializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 5: return .InsertError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 6: return .RetrievalError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 7: return .DataError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 8: return .ConnectionError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 9: return .SerializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 10: return .ChannelOpen( - errorType: try FfiConverterTypeBtChannelOrderErrorType.read(from: &buf), - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 11: return .OrderState( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 12: return .InvalidParameter( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 13: return .DatabaseError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .reverse + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BlocktankError, into buf: inout [UInt8]) { + public static func write(_ value: BoltzSwapType, into buf: inout [UInt8]) { switch value { - - - - case let .HttpClient(errorDetails): + case .submarine: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .BlocktankClient(errorDetails): - writeInt(&buf, Int32(2)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InvalidBlocktank(errorDetails): - writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InitializationError(errorDetails): - writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InsertError(errorDetails): - writeInt(&buf, Int32(5)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .RetrievalError(errorDetails): - writeInt(&buf, Int32(6)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .DataError(errorDetails): - writeInt(&buf, Int32(7)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .ConnectionError(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .SerializationError(errorDetails): - writeInt(&buf, Int32(9)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .ChannelOpen(errorType,errorDetails): - writeInt(&buf, Int32(10)) - FfiConverterTypeBtChannelOrderErrorType.write(errorType, into: &buf) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .OrderState(errorDetails): - writeInt(&buf, Int32(11)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InvalidParameter(errorDetails): - writeInt(&buf, Int32(12)) - FfiConverterString.write(errorDetails, into: &buf) - + case .reverse: + writeInt(&buf, Int32(2)) - case let .DatabaseError(errorDetails): - writeInt(&buf, Int32(13)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -21380,59 +23014,39 @@ public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBlocktankError_lift(_ buf: RustBuffer) throws -> BlocktankError { - return try FfiConverterTypeBlocktankError.lift(buf) +public func FfiConverterTypeBoltzSwapType_lift(_ buf: RustBuffer) throws -> BoltzSwapType { + return try FfiConverterTypeBoltzSwapType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBlocktankError_lower(_ value: BlocktankError) -> RustBuffer { - return FfiConverterTypeBlocktankError.lower(value) +public func FfiConverterTypeBoltzSwapType_lower(_ value: BoltzSwapType) -> RustBuffer { + return FfiConverterTypeBoltzSwapType.lower(value) } -extension BlocktankError: Equatable, Hashable {} - -extension BlocktankError: Codable {} - - +extension BoltzSwapType: Equatable, Hashable {} +extension BoltzSwapType: Codable {} -extension BlocktankError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} -/** - * Errors surfaced by the Boltz swaps module. - */ -public enum BoltzError: Swift.Error { + +public enum BroadcastError: Swift.Error { - case InitializationError(errorDetails: String - ) - case ConnectionError(errorDetails: String - ) - case DatabaseError(errorDetails: String - ) - case ApiError(errorDetails: String - ) - case SwapError(errorDetails: String - ) - case BroadcastError(errorDetails: String + case InvalidHex(errorDetails: String ) - case InvalidInput(errorDetails: String + case InvalidTransaction(errorDetails: String ) - case SerializationError(errorDetails: String + case ElectrumError(errorDetails: String ) - case NotFound(errorDetails: String + case TaskError(errorDetails: String ) } @@ -21440,41 +23054,26 @@ public enum BoltzError: Swift.Error { #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { - typealias SwiftType = BoltzError +public struct FfiConverterTypeBroadcastError: FfiConverterRustBuffer { + typealias SwiftType = BroadcastError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BroadcastError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InitializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .ConnectionError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .DatabaseError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .ApiError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 5: return .SwapError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 6: return .BroadcastError( + case 1: return .InvalidHex( errorDetails: try FfiConverterString.read(from: &buf) ) - case 7: return .InvalidInput( + case 2: return .InvalidTransaction( errorDetails: try FfiConverterString.read(from: &buf) ) - case 8: return .SerializationError( + case 3: return .ElectrumError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 9: return .NotFound( + case 4: return .TaskError( errorDetails: try FfiConverterString.read(from: &buf) ) @@ -21482,57 +23081,32 @@ public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { } } - public static func write(_ value: BoltzError, into buf: inout [UInt8]) { + public static func write(_ value: BroadcastError, into buf: inout [UInt8]) { switch value { - case let .InitializationError(errorDetails): + case let .InvalidHex(errorDetails): writeInt(&buf, Int32(1)) FfiConverterString.write(errorDetails, into: &buf) - case let .ConnectionError(errorDetails): + case let .InvalidTransaction(errorDetails): writeInt(&buf, Int32(2)) FfiConverterString.write(errorDetails, into: &buf) - case let .DatabaseError(errorDetails): + case let .ElectrumError(errorDetails): writeInt(&buf, Int32(3)) FfiConverterString.write(errorDetails, into: &buf) - case let .ApiError(errorDetails): + case let .TaskError(errorDetails): writeInt(&buf, Int32(4)) FfiConverterString.write(errorDetails, into: &buf) - - case let .SwapError(errorDetails): - writeInt(&buf, Int32(5)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .BroadcastError(errorDetails): - writeInt(&buf, Int32(6)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InvalidInput(errorDetails): - writeInt(&buf, Int32(7)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .SerializationError(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .NotFound(errorDetails): - writeInt(&buf, Int32(9)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -21541,26 +23115,26 @@ public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzError_lift(_ buf: RustBuffer) throws -> BoltzError { - return try FfiConverterTypeBoltzError.lift(buf) +public func FfiConverterTypeBroadcastError_lift(_ buf: RustBuffer) throws -> BroadcastError { + return try FfiConverterTypeBroadcastError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzError_lower(_ value: BoltzError) -> RustBuffer { - return FfiConverterTypeBoltzError.lower(value) +public func FfiConverterTypeBroadcastError_lower(_ value: BroadcastError) -> RustBuffer { + return FfiConverterTypeBroadcastError.lower(value) } -extension BoltzError: Equatable, Hashable {} +extension BroadcastError: Equatable, Hashable {} -extension BoltzError: Codable {} +extension BroadcastError: Codable {} -extension BoltzError: Foundation.LocalizedError { +extension BroadcastError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -21571,176 +23145,61 @@ extension BoltzError: Foundation.LocalizedError { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Bitcoin network selection for Boltz swaps. Maps to the networks Boltz - * operates on (mainnet, testnet, regtest). - */ -public enum BoltzNetwork { +public enum BtBolt11InvoiceState { - case mainnet - case testnet - case regtest + case pending + case holding + case paid + case canceled } #if compiler(>=6) -extension BoltzNetwork: Sendable {} +extension BtBolt11InvoiceState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzNetwork: FfiConverterRustBuffer { - typealias SwiftType = BoltzNetwork +public struct FfiConverterTypeBtBolt11InvoiceState: FfiConverterRustBuffer { + typealias SwiftType = BtBolt11InvoiceState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzNetwork { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtBolt11InvoiceState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .mainnet + case 1: return .pending - case 2: return .testnet + case 2: return .holding - case 3: return .regtest + case 3: return .paid + + case 4: return .canceled default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BoltzNetwork, into buf: inout [UInt8]) { + public static func write(_ value: BtBolt11InvoiceState, into buf: inout [UInt8]) { switch value { - case .mainnet: + case .pending: writeInt(&buf, Int32(1)) - case .testnet: + case .holding: writeInt(&buf, Int32(2)) - case .regtest: + case .paid: writeInt(&buf, Int32(3)) - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBoltzNetwork_lift(_ buf: RustBuffer) throws -> BoltzNetwork { - return try FfiConverterTypeBoltzNetwork.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeBoltzNetwork_lower(_ value: BoltzNetwork) -> RustBuffer { - return FfiConverterTypeBoltzNetwork.lower(value) -} - - -extension BoltzNetwork: Equatable, Hashable {} - -extension BoltzNetwork: Codable {} - - - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Events emitted to a registered [`crate::modules::boltz::BoltzEventListener`] - * as swaps progress through their lifecycle. - */ - -public enum BoltzSwapEvent { - - /** - * The swap transitioned to a new status. - */ - case statusUpdate(swapId: String, status: BoltzSwapStatus - ) - /** - * A reverse swap was claimed onchain. `txid` is the claim transaction. - */ - case claimed(swapId: String, txid: String - ) - /** - * A submarine swap was refunded onchain. `txid` is the refund transaction. - */ - case refunded(swapId: String, txid: String - ) - /** - * An error occurred while processing the swap (e.g. an auto-claim failed). - */ - case error(swapId: String, message: String - ) -} - - -#if compiler(>=6) -extension BoltzSwapEvent: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeBoltzSwapEvent: FfiConverterRustBuffer { - typealias SwiftType = BoltzSwapEvent - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapEvent { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .statusUpdate(swapId: try FfiConverterString.read(from: &buf), status: try FfiConverterTypeBoltzSwapStatus.read(from: &buf) - ) - - case 2: return .claimed(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) - ) - - case 3: return .refunded(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) - ) - - case 4: return .error(swapId: try FfiConverterString.read(from: &buf), message: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: BoltzSwapEvent, into buf: inout [UInt8]) { - switch value { - - - case let .statusUpdate(swapId,status): - writeInt(&buf, Int32(1)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterTypeBoltzSwapStatus.write(status, into: &buf) - - - case let .claimed(swapId,txid): - writeInt(&buf, Int32(2)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterString.write(txid, into: &buf) - - - case let .refunded(swapId,txid): - writeInt(&buf, Int32(3)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterString.write(txid, into: &buf) - - case let .error(swapId,message): - writeInt(&buf, Int32(4)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterString.write(message, into: &buf) - + case .canceled: + writeInt(&buf, Int32(4)) + } } } @@ -21749,21 +23208,21 @@ public struct FfiConverterTypeBoltzSwapEvent: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapEvent_lift(_ buf: RustBuffer) throws -> BoltzSwapEvent { - return try FfiConverterTypeBoltzSwapEvent.lift(buf) +public func FfiConverterTypeBtBolt11InvoiceState_lift(_ buf: RustBuffer) throws -> BtBolt11InvoiceState { + return try FfiConverterTypeBtBolt11InvoiceState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapEvent_lower(_ value: BoltzSwapEvent) -> RustBuffer { - return FfiConverterTypeBoltzSwapEvent.lower(value) +public func FfiConverterTypeBtBolt11InvoiceState_lower(_ value: BtBolt11InvoiceState) -> RustBuffer { + return FfiConverterTypeBtBolt11InvoiceState.lower(value) } -extension BoltzSwapEvent: Equatable, Hashable {} +extension BtBolt11InvoiceState: Equatable, Hashable {} -extension BoltzSwapEvent: Codable {} +extension BtBolt11InvoiceState: Codable {} @@ -21772,202 +23231,68 @@ extension BoltzSwapEvent: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Typed view of the Boltz swap lifecycle. `Unknown` carries the raw status so - * new server-side states don't break the bindings. - * - * See . - */ -public enum BoltzSwapStatus { +public enum BtChannelOrderErrorType { - /** - * `swap.created` — initial state. - */ - case swapCreated - /** - * `invoice.set` — invoice attached to a submarine swap. - */ - case invoiceSet - /** - * `transaction.mempool` — a lockup transaction is in the mempool. - */ - case transactionMempool - /** - * `transaction.confirmed` — a lockup transaction confirmed. - */ - case transactionConfirmed - /** - * `invoice.pending` — Boltz is paying the submarine swap invoice. - */ - case invoicePending - /** - * `invoice.paid` — submarine swap invoice paid by Boltz. - */ - case invoicePaid - /** - * `invoice.settled` — reverse swap invoice settled (preimage revealed). - */ - case invoiceSettled - /** - * `invoice.failedToPay` — submarine swap invoice could not be paid; refund. - */ - case invoiceFailedToPay - /** - * `invoice.expired` — reverse swap invoice expired before payment. - */ - case invoiceExpired - /** - * `transaction.claim.pending` — Boltz ready for a cooperative claim. - */ - case transactionClaimPending - /** - * `transaction.claimed` — onchain funds claimed. - */ - case transactionClaimed - /** - * `transaction.refunded` — onchain funds refunded. - */ - case transactionRefunded - /** - * `transaction.lockupFailed` — wrong amount locked; can refund. - */ - case transactionLockupFailed - /** - * `transaction.failed` — Boltz failed to lock the agreed funds. - */ - case transactionFailed - /** - * `swap.expired` — swap expired without completing. - */ - case swapExpired - /** - * Any status not yet modelled. `raw` holds the verbatim Boltz status. - */ - case unknown(raw: String - ) + case wrongOrderState + case peerNotReachable + case channelRejectedByDestination + case channelRejectedByLsp + case blocktankNotReady } #if compiler(>=6) -extension BoltzSwapStatus: Sendable {} +extension BtChannelOrderErrorType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzSwapStatus: FfiConverterRustBuffer { - typealias SwiftType = BoltzSwapStatus +public struct FfiConverterTypeBtChannelOrderErrorType: FfiConverterRustBuffer { + typealias SwiftType = BtChannelOrderErrorType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapStatus { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtChannelOrderErrorType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .swapCreated - - case 2: return .invoiceSet - - case 3: return .transactionMempool - - case 4: return .transactionConfirmed - - case 5: return .invoicePending - - case 6: return .invoicePaid - - case 7: return .invoiceSettled - - case 8: return .invoiceFailedToPay - - case 9: return .invoiceExpired - - case 10: return .transactionClaimPending - - case 11: return .transactionClaimed - - case 12: return .transactionRefunded + case 1: return .wrongOrderState - case 13: return .transactionLockupFailed + case 2: return .peerNotReachable - case 14: return .transactionFailed + case 3: return .channelRejectedByDestination - case 15: return .swapExpired + case 4: return .channelRejectedByLsp - case 16: return .unknown(raw: try FfiConverterString.read(from: &buf) - ) + case 5: return .blocktankNotReady default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BoltzSwapStatus, into buf: inout [UInt8]) { + public static func write(_ value: BtChannelOrderErrorType, into buf: inout [UInt8]) { switch value { - case .swapCreated: + case .wrongOrderState: writeInt(&buf, Int32(1)) - case .invoiceSet: + case .peerNotReachable: writeInt(&buf, Int32(2)) - case .transactionMempool: + case .channelRejectedByDestination: writeInt(&buf, Int32(3)) - case .transactionConfirmed: + case .channelRejectedByLsp: writeInt(&buf, Int32(4)) - case .invoicePending: + case .blocktankNotReady: writeInt(&buf, Int32(5)) - - case .invoicePaid: - writeInt(&buf, Int32(6)) - - - case .invoiceSettled: - writeInt(&buf, Int32(7)) - - - case .invoiceFailedToPay: - writeInt(&buf, Int32(8)) - - - case .invoiceExpired: - writeInt(&buf, Int32(9)) - - - case .transactionClaimPending: - writeInt(&buf, Int32(10)) - - - case .transactionClaimed: - writeInt(&buf, Int32(11)) - - - case .transactionRefunded: - writeInt(&buf, Int32(12)) - - - case .transactionLockupFailed: - writeInt(&buf, Int32(13)) - - - case .transactionFailed: - writeInt(&buf, Int32(14)) - - - case .swapExpired: - writeInt(&buf, Int32(15)) - - - case let .unknown(raw): - writeInt(&buf, Int32(16)) - FfiConverterString.write(raw, into: &buf) - } } } @@ -21976,21 +23301,21 @@ public struct FfiConverterTypeBoltzSwapStatus: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapStatus_lift(_ buf: RustBuffer) throws -> BoltzSwapStatus { - return try FfiConverterTypeBoltzSwapStatus.lift(buf) +public func FfiConverterTypeBtChannelOrderErrorType_lift(_ buf: RustBuffer) throws -> BtChannelOrderErrorType { + return try FfiConverterTypeBtChannelOrderErrorType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapStatus_lower(_ value: BoltzSwapStatus) -> RustBuffer { - return FfiConverterTypeBoltzSwapStatus.lower(value) +public func FfiConverterTypeBtChannelOrderErrorType_lower(_ value: BtChannelOrderErrorType) -> RustBuffer { + return FfiConverterTypeBtChannelOrderErrorType.lower(value) } -extension BoltzSwapStatus: Equatable, Hashable {} +extension BtChannelOrderErrorType: Equatable, Hashable {} -extension BoltzSwapStatus: Codable {} +extension BtChannelOrderErrorType: Codable {} @@ -21999,55 +23324,54 @@ extension BoltzSwapStatus: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * The direction of a Boltz swap. - * - * - `Submarine`: onchain Bitcoin -> Lightning (the user locks onchain funds, - * Boltz pays a Lightning invoice). - * - `Reverse`: Lightning -> onchain Bitcoin (the user pays a Boltz hold - * invoice, Boltz locks onchain funds the user then claims). - */ -public enum BoltzSwapType { +public enum BtOpenChannelState { - case submarine - case reverse + case opening + case `open` + case closed } #if compiler(>=6) -extension BoltzSwapType: Sendable {} +extension BtOpenChannelState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzSwapType: FfiConverterRustBuffer { - typealias SwiftType = BoltzSwapType +public struct FfiConverterTypeBtOpenChannelState: FfiConverterRustBuffer { + typealias SwiftType = BtOpenChannelState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOpenChannelState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .submarine + case 1: return .opening - case 2: return .reverse + case 2: return .`open` + + case 3: return .closed default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BoltzSwapType, into buf: inout [UInt8]) { + public static func write(_ value: BtOpenChannelState, into buf: inout [UInt8]) { switch value { - case .submarine: + case .opening: writeInt(&buf, Int32(1)) - case .reverse: + case .`open`: writeInt(&buf, Int32(2)) + + case .closed: + writeInt(&buf, Int32(3)) + } } } @@ -22056,99 +23380,84 @@ public struct FfiConverterTypeBoltzSwapType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapType_lift(_ buf: RustBuffer) throws -> BoltzSwapType { - return try FfiConverterTypeBoltzSwapType.lift(buf) +public func FfiConverterTypeBtOpenChannelState_lift(_ buf: RustBuffer) throws -> BtOpenChannelState { + return try FfiConverterTypeBtOpenChannelState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapType_lower(_ value: BoltzSwapType) -> RustBuffer { - return FfiConverterTypeBoltzSwapType.lower(value) +public func FfiConverterTypeBtOpenChannelState_lower(_ value: BtOpenChannelState) -> RustBuffer { + return FfiConverterTypeBtOpenChannelState.lower(value) } -extension BoltzSwapType: Equatable, Hashable {} - -extension BoltzSwapType: Codable {} +extension BtOpenChannelState: Equatable, Hashable {} +extension BtOpenChannelState: Codable {} -public enum BroadcastError: Swift.Error { +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum BtOrderState { - - case InvalidHex(errorDetails: String - ) - case InvalidTransaction(errorDetails: String - ) - case ElectrumError(errorDetails: String - ) - case TaskError(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 FfiConverterTypeBroadcastError: FfiConverterRustBuffer { - typealias SwiftType = BroadcastError +public struct FfiConverterTypeBtOrderState: FfiConverterRustBuffer { + typealias SwiftType = BtOrderState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BroadcastError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOrderState { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .created - case 1: return .InvalidHex( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .InvalidTransaction( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .ElectrumError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .TaskError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .expired + + case 3: return .`open` + + case 4: return .closed + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BroadcastError, into buf: inout [UInt8]) { + public static func write(_ value: BtOrderState, into buf: inout [UInt8]) { switch value { - - - - case let .InvalidHex(errorDetails): + case .created: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InvalidTransaction(errorDetails): + + case .expired: writeInt(&buf, Int32(2)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .ElectrumError(errorDetails): + + case .`open`: writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .TaskError(errorDetails): + + case .closed: writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - + } } } @@ -22157,30 +23466,23 @@ public struct FfiConverterTypeBroadcastError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBroadcastError_lift(_ buf: RustBuffer) throws -> BroadcastError { - return try FfiConverterTypeBroadcastError.lift(buf) +public func FfiConverterTypeBtOrderState_lift(_ buf: RustBuffer) throws -> BtOrderState { + return try FfiConverterTypeBtOrderState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBroadcastError_lower(_ value: BroadcastError) -> RustBuffer { - return FfiConverterTypeBroadcastError.lower(value) +public func FfiConverterTypeBtOrderState_lower(_ value: BtOrderState) -> RustBuffer { + return FfiConverterTypeBtOrderState.lower(value) } -extension BroadcastError: Equatable, Hashable {} - -extension BroadcastError: Codable {} - +extension BtOrderState: Equatable, Hashable {} +extension BtOrderState: Codable {} -extension BroadcastError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} @@ -22188,58 +23490,58 @@ extension BroadcastError: Foundation.LocalizedError { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum BtBolt11InvoiceState { +public enum 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)) } @@ -22250,21 +23552,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 {} @@ -22274,65 +23576,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)) } @@ -22343,21 +23645,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 {} @@ -22367,53 +23669,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 + + 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)) + } } } @@ -22422,21 +23738,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 {} @@ -22446,42 +23762,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 { @@ -22489,15 +23805,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)) } @@ -22508,21 +23824,21 @@ 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 {} @@ -22531,61 +23847,66 @@ extension BtOrderState: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Coin selection strategy for transaction composition. + */ -public enum BtOrderState2 { +public enum CoinSelection { - case created - case expired - case executed - case paid + /** + * Branch-and-bound (default). Minimizes change by searching for exact matches. + */ + case branchAndBound + /** + * Selects largest UTXOs first. Useful for UTXO consolidation. + */ + case largestFirst + /** + * Selects oldest UTXOs first. Maximizes coin-age spending. + */ + case oldestFirst } #if compiler(>=6) -extension BtOrderState2: Sendable {} +extension CoinSelection: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtOrderState2: FfiConverterRustBuffer { - typealias SwiftType = BtOrderState2 +public struct FfiConverterTypeCoinSelection: FfiConverterRustBuffer { + typealias SwiftType = CoinSelection - 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 -> CoinSelection { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .created - - case 2: return .expired + case 1: return .branchAndBound - case 3: return .executed + case 2: return .largestFirst - case 4: return .paid + case 3: return .oldestFirst default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtOrderState2, into buf: inout [UInt8]) { + public static func write(_ value: CoinSelection, into buf: inout [UInt8]) { switch value { - case .created: + case .branchAndBound: writeInt(&buf, Int32(1)) - case .expired: + case .largestFirst: writeInt(&buf, Int32(2)) - case .executed: + case .oldestFirst: writeInt(&buf, Int32(3)) - - case .paid: - writeInt(&buf, Int32(4)) - } } } @@ -22594,21 +23915,21 @@ 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 FfiConverterTypeCoinSelection_lift(_ buf: RustBuffer) throws -> CoinSelection { + return try FfiConverterTypeCoinSelection.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOrderState2_lower(_ value: BtOrderState2) -> RustBuffer { - return FfiConverterTypeBtOrderState2.lower(value) +public func FfiConverterTypeCoinSelection_lower(_ value: CoinSelection) -> RustBuffer { + return FfiConverterTypeCoinSelection.lower(value) } -extension BtOrderState2: Equatable, Hashable {} +extension CoinSelection: Equatable, Hashable {} -extension BtOrderState2: Codable {} +extension CoinSelection: Codable {} @@ -22617,68 +23938,76 @@ extension BtOrderState2: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Output specification for transaction composition. + */ -public enum BtPaymentState { +public enum ComposeOutput { - case created - case partiallyPaid - case paid - case refunded - case refundAvailable + /** + * Payment to a specific address with a fixed amount (satoshis) + */ + case payment(address: String, amountSats: UInt64 + ) + /** + * Send all remaining funds (after fees) to an address + */ + case sendMax(address: String + ) + /** + * OP_RETURN data output (hex-encoded payload) + */ + case opReturn(dataHex: String + ) } #if compiler(>=6) -extension BtPaymentState: Sendable {} +extension ComposeOutput: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtPaymentState: FfiConverterRustBuffer { - typealias SwiftType = BtPaymentState +public struct FfiConverterTypeComposeOutput: FfiConverterRustBuffer { + typealias SwiftType = ComposeOutput - 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 -> ComposeOutput { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .created - - case 2: return .partiallyPaid - - case 3: return .paid + case 1: return .payment(address: try FfiConverterString.read(from: &buf), amountSats: try FfiConverterUInt64.read(from: &buf) + ) - case 4: return .refunded + case 2: return .sendMax(address: try FfiConverterString.read(from: &buf) + ) - case 5: return .refundAvailable + case 3: return .opReturn(dataHex: try FfiConverterString.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtPaymentState, into buf: inout [UInt8]) { + public static func write(_ value: ComposeOutput, into buf: inout [UInt8]) { switch value { - case .created: + case let .payment(address,amountSats): writeInt(&buf, Int32(1)) + FfiConverterString.write(address, into: &buf) + FfiConverterUInt64.write(amountSats, into: &buf) + - - case .partiallyPaid: + case let .sendMax(address): writeInt(&buf, Int32(2)) + FfiConverterString.write(address, into: &buf) + - - case .paid: + case let .opReturn(dataHex): writeInt(&buf, Int32(3)) - - - case .refunded: - writeInt(&buf, Int32(4)) - - - case .refundAvailable: - writeInt(&buf, Int32(5)) - + FfiConverterString.write(dataHex, into: &buf) + } } } @@ -22687,21 +24016,21 @@ public struct FfiConverterTypeBtPaymentState: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState_lift(_ buf: RustBuffer) throws -> BtPaymentState { - return try FfiConverterTypeBtPaymentState.lift(buf) +public func FfiConverterTypeComposeOutput_lift(_ buf: RustBuffer) throws -> ComposeOutput { + return try FfiConverterTypeComposeOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState_lower(_ value: BtPaymentState) -> RustBuffer { - return FfiConverterTypeBtPaymentState.lower(value) +public func FfiConverterTypeComposeOutput_lower(_ value: ComposeOutput) -> RustBuffer { + return FfiConverterTypeComposeOutput.lower(value) } -extension BtPaymentState: Equatable, Hashable {} +extension ComposeOutput: Equatable, Hashable {} -extension BtPaymentState: Codable {} +extension ComposeOutput: Codable {} @@ -22710,68 +24039,79 @@ extension BtPaymentState: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Result of composing a transaction at a single fee rate. + */ -public enum BtPaymentState2 { +public enum ComposeResult { - case created - case paid - case refunded - case refundAvailable - case canceled + /** + * Successfully built a signable PSBT + */ + case success( + /** + * Base64-encoded PSBT ready for signing + */psbt: String, + /** + * Total fee in satoshis + */fee: UInt64, + /** + * Target fee rate in sat/vB (actual may differ slightly due to rounding) + */feeRate: Float, + /** + * Total value spent (payments + fee, excluding change). + * Uses BDK's `sent - received` semantics, which may undercount for + * self-transfers where the destination is also owned by the wallet. + */totalSpent: UInt64 + ) + /** + * Composition failed (e.g. insufficient funds) + */ + case error(error: String + ) } #if compiler(>=6) -extension BtPaymentState2: Sendable {} +extension ComposeResult: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtPaymentState2: FfiConverterRustBuffer { - typealias SwiftType = BtPaymentState2 +public struct FfiConverterTypeComposeResult: FfiConverterRustBuffer { + typealias SwiftType = ComposeResult - 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 -> ComposeResult { 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 1: return .success(psbt: try FfiConverterString.read(from: &buf), fee: try FfiConverterUInt64.read(from: &buf), feeRate: try FfiConverterFloat.read(from: &buf), totalSpent: try FfiConverterUInt64.read(from: &buf) + ) - case 5: return .canceled + case 2: return .error(error: try FfiConverterString.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtPaymentState2, into buf: inout [UInt8]) { + public static func write(_ value: ComposeResult, into buf: inout [UInt8]) { switch value { - case .created: + case let .success(psbt,fee,feeRate,totalSpent): writeInt(&buf, Int32(1)) + FfiConverterString.write(psbt, into: &buf) + FfiConverterUInt64.write(fee, into: &buf) + FfiConverterFloat.write(feeRate, into: &buf) + FfiConverterUInt64.write(totalSpent, into: &buf) + - - case .paid: - writeInt(&buf, Int32(2)) - - - case .refunded: - writeInt(&buf, Int32(3)) - - - case .refundAvailable: - writeInt(&buf, Int32(4)) - - - case .canceled: - writeInt(&buf, Int32(5)) - + case let .error(error): + writeInt(&buf, Int32(2)) + FfiConverterString.write(error, into: &buf) + } } } @@ -22780,84 +24120,99 @@ 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 FfiConverterTypeComposeResult_lift(_ buf: RustBuffer) throws -> ComposeResult { + return try FfiConverterTypeComposeResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState2_lower(_ value: BtPaymentState2) -> RustBuffer { - return FfiConverterTypeBtPaymentState2.lower(value) +public func FfiConverterTypeComposeResult_lower(_ value: ComposeResult) -> RustBuffer { + return FfiConverterTypeComposeResult.lower(value) } -extension BtPaymentState2: Equatable, Hashable {} +extension ComposeResult: Equatable, Hashable {} -extension BtPaymentState2: Codable {} +extension ComposeResult: Codable {} -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum CJitStateEnum { +public enum DbError: Swift.Error { + - case created - case completed - case expired - case failed + + case DbActivityError(errorDetails: ActivityError + ) + case DbBlocktankError(errorDetails: BlocktankError + ) + case DbBoltzError(errorDetails: BoltzError + ) + case InitializationError(errorDetails: String + ) } -#if compiler(>=6) -extension CJitStateEnum: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { - typealias SwiftType = CJitStateEnum +public struct FfiConverterTypeDbError: FfiConverterRustBuffer { + typealias SwiftType = DbError - 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 -> DbError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .created - - case 2: return .completed - - case 3: return .expired - - case 4: return .failed + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .DbActivityError( + errorDetails: try FfiConverterTypeActivityError.read(from: &buf) + ) + case 2: return .DbBlocktankError( + errorDetails: try FfiConverterTypeBlocktankError.read(from: &buf) + ) + case 3: return .DbBoltzError( + errorDetails: try FfiConverterTypeBoltzError.read(from: &buf) + ) + case 4: return .InitializationError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: CJitStateEnum, into buf: inout [UInt8]) { + public static func write(_ value: DbError, into buf: inout [UInt8]) { switch value { + + - case .created: - writeInt(&buf, Int32(1)) + case let .DbActivityError(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterTypeActivityError.write(errorDetails, into: &buf) + - case .completed: + case let .DbBlocktankError(errorDetails): writeInt(&buf, Int32(2)) + FfiConverterTypeBlocktankError.write(errorDetails, into: &buf) + - - case .expired: + case let .DbBoltzError(errorDetails): writeInt(&buf, Int32(3)) + FfiConverterTypeBoltzError.write(errorDetails, into: &buf) + - - case .failed: + case let .InitializationError(errorDetails): writeInt(&buf, Int32(4)) - + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -22866,89 +24221,150 @@ 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 FfiConverterTypeDbError_lift(_ buf: RustBuffer) throws -> DbError { + return try FfiConverterTypeDbError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCJitStateEnum_lower(_ value: CJitStateEnum) -> RustBuffer { - return FfiConverterTypeCJitStateEnum.lower(value) +public func FfiConverterTypeDbError_lower(_ value: DbError) -> RustBuffer { + return FfiConverterTypeDbError.lower(value) } -extension CJitStateEnum: Equatable, Hashable {} +extension DbError: Equatable, Hashable {} + +extension DbError: Codable {} -extension CJitStateEnum: 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. -/** - * Coin selection strategy for transaction composition. - */ +public enum DecodingError: Swift.Error { -public enum CoinSelection { - /** - * Branch-and-bound (default). Minimizes change by searching for exact matches. - */ - case branchAndBound - /** - * Selects largest UTXOs first. Useful for UTXO consolidation. - */ - case largestFirst - /** - * Selects oldest UTXOs first. Maximizes coin-age spending. - */ - case oldestFirst + + case 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 CoinSelection: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeCoinSelection: FfiConverterRustBuffer { - typealias SwiftType = CoinSelection +public struct FfiConverterTypeDecodingError: FfiConverterRustBuffer { + typealias SwiftType = DecodingError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CoinSelection { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DecodingError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .branchAndBound - - case 2: return .largestFirst - - case 3: return .oldestFirst + - 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: CoinSelection, into buf: inout [UInt8]) { + public static func write(_ value: DecodingError, into buf: inout [UInt8]) { switch value { + + - case .branchAndBound: + + case .InvalidFormat: writeInt(&buf, Int32(1)) - case .largestFirst: + case .InvalidNetwork: writeInt(&buf, Int32(2)) - case .oldestFirst: + 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) + } } } @@ -22957,23 +24373,30 @@ public struct FfiConverterTypeCoinSelection: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCoinSelection_lift(_ buf: RustBuffer) throws -> CoinSelection { - return try FfiConverterTypeCoinSelection.lift(buf) +public func FfiConverterTypeDecodingError_lift(_ buf: RustBuffer) throws -> DecodingError { + return try FfiConverterTypeDecodingError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCoinSelection_lower(_ value: CoinSelection) -> RustBuffer { - return FfiConverterTypeCoinSelection.lower(value) +public func FfiConverterTypeDecodingError_lower(_ value: DecodingError) -> RustBuffer { + return FfiConverterTypeDecodingError.lower(value) } -extension CoinSelection: Equatable, Hashable {} +extension DecodingError: Equatable, Hashable {} + +extension DecodingError: Codable {} + -extension CoinSelection: Codable {} +extension DecodingError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} @@ -22981,75 +24404,56 @@ extension CoinSelection: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. /** - * Output specification for transaction composition. + * How an application exchanges data with a hardware wallet. */ -public enum ComposeOutput { +public enum HardwareWalletTransport { - /** - * Payment to a specific address with a fixed amount (satoshis) - */ - case payment(address: String, amountSats: UInt64 - ) - /** - * Send all remaining funds (after fees) to an address - */ - case sendMax(address: String - ) - /** - * OP_RETURN data output (hex-encoded payload) - */ - case opReturn(dataHex: String - ) + case usb + case bluetooth + case qr } #if compiler(>=6) -extension ComposeOutput: Sendable {} +extension HardwareWalletTransport: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeComposeOutput: FfiConverterRustBuffer { - typealias SwiftType = ComposeOutput +public struct FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { + typealias SwiftType = HardwareWalletTransport - 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 -> HardwareWalletTransport { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .payment(address: try FfiConverterString.read(from: &buf), amountSats: try FfiConverterUInt64.read(from: &buf) - ) + case 1: return .usb - case 2: return .sendMax(address: try FfiConverterString.read(from: &buf) - ) + case 2: return .bluetooth - case 3: return .opReturn(dataHex: try FfiConverterString.read(from: &buf) - ) + case 3: return .qr default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ComposeOutput, into buf: inout [UInt8]) { + public static func write(_ value: HardwareWalletTransport, into buf: inout [UInt8]) { switch value { - case let .payment(address,amountSats): + case .usb: writeInt(&buf, Int32(1)) - FfiConverterString.write(address, into: &buf) - FfiConverterUInt64.write(amountSats, into: &buf) - - case let .sendMax(address): + + case .bluetooth: writeInt(&buf, Int32(2)) - FfiConverterString.write(address, into: &buf) - - case let .opReturn(dataHex): + + case .qr: writeInt(&buf, Int32(3)) - FfiConverterString.write(dataHex, into: &buf) - + } } } @@ -23058,21 +24462,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 FfiConverterTypeHardwareWalletTransport_lift(_ buf: RustBuffer) throws -> HardwareWalletTransport { + return try FfiConverterTypeHardwareWalletTransport.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeOutput_lower(_ value: ComposeOutput) -> RustBuffer { - return FfiConverterTypeComposeOutput.lower(value) +public func FfiConverterTypeHardwareWalletTransport_lower(_ value: HardwareWalletTransport) -> RustBuffer { + return FfiConverterTypeHardwareWalletTransport.lower(value) } -extension ComposeOutput: Equatable, Hashable {} +extension HardwareWalletTransport: Equatable, Hashable {} -extension ComposeOutput: Codable {} +extension HardwareWalletTransport: Codable {} @@ -23082,78 +24486,56 @@ 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. /** - * Result of composing a transaction at a single fee rate. + * A hardware-wallet vendor recognized by Bitkit. */ -public enum ComposeResult { +public enum HardwareWalletVendor { - /** - * Successfully built a signable PSBT - */ - case success( - /** - * Base64-encoded PSBT ready for signing - */psbt: String, - /** - * Total fee in satoshis - */fee: UInt64, - /** - * Target fee rate in sat/vB (actual may differ slightly due to rounding) - */feeRate: Float, - /** - * Total value spent (payments + fee, excluding change). - * Uses BDK's `sent - received` semantics, which may undercount for - * self-transfers where the destination is also owned by the wallet. - */totalSpent: UInt64 - ) - /** - * Composition failed (e.g. insufficient funds) - */ - case error(error: String - ) + case trezor + case foundation + case blockstream } #if compiler(>=6) -extension ComposeResult: Sendable {} +extension HardwareWalletVendor: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeComposeResult: FfiConverterRustBuffer { - typealias SwiftType = ComposeResult +public struct FfiConverterTypeHardwareWalletVendor: FfiConverterRustBuffer { + typealias SwiftType = HardwareWalletVendor - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposeResult { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HardwareWalletVendor { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .success(psbt: try FfiConverterString.read(from: &buf), fee: try FfiConverterUInt64.read(from: &buf), feeRate: try FfiConverterFloat.read(from: &buf), totalSpent: try FfiConverterUInt64.read(from: &buf) - ) + case 1: return .trezor - case 2: return .error(error: try FfiConverterString.read(from: &buf) - ) + case 2: return .foundation + + case 3: return .blockstream default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ComposeResult, into buf: inout [UInt8]) { + public static func write(_ value: HardwareWalletVendor, into buf: inout [UInt8]) { switch value { - case let .success(psbt,fee,feeRate,totalSpent): + case .trezor: writeInt(&buf, Int32(1)) - FfiConverterString.write(psbt, into: &buf) - FfiConverterUInt64.write(fee, into: &buf) - FfiConverterFloat.write(feeRate, into: &buf) - FfiConverterUInt64.write(totalSpent, into: &buf) - - case let .error(error): + + case .foundation: writeInt(&buf, Int32(2)) - FfiConverterString.write(error, into: &buf) - + + + case .blockstream: + writeInt(&buf, Int32(3)) + } } } @@ -23162,99 +24544,84 @@ public struct FfiConverterTypeComposeResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeResult_lift(_ buf: RustBuffer) throws -> ComposeResult { - return try FfiConverterTypeComposeResult.lift(buf) +public func FfiConverterTypeHardwareWalletVendor_lift(_ buf: RustBuffer) throws -> HardwareWalletVendor { + return try FfiConverterTypeHardwareWalletVendor.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeResult_lower(_ value: ComposeResult) -> RustBuffer { - return FfiConverterTypeComposeResult.lower(value) +public func FfiConverterTypeHardwareWalletVendor_lower(_ value: HardwareWalletVendor) -> RustBuffer { + return FfiConverterTypeHardwareWalletVendor.lower(value) } -extension ComposeResult: Equatable, Hashable {} - -extension ComposeResult: Codable {} +extension HardwareWalletVendor: Equatable, Hashable {} +extension HardwareWalletVendor: 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 JadeAddressVariant { - - case DbActivityError(errorDetails: ActivityError - ) - case DbBlocktankError(errorDetails: BlocktankError - ) - case DbBoltzError(errorDetails: BoltzError - ) - case InitializationError(errorDetails: String - ) + case pkh + case wpkh + case shWpkh + case tr } +#if compiler(>=6) +extension JadeAddressVariant: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDbError: FfiConverterRustBuffer { - typealias SwiftType = DbError +public struct FfiConverterTypeJadeAddressVariant: FfiConverterRustBuffer { + typealias SwiftType = JadeAddressVariant - 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 -> JadeAddressVariant { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .pkh - case 1: return .DbActivityError( - errorDetails: try FfiConverterTypeActivityError.read(from: &buf) - ) - case 2: return .DbBlocktankError( - errorDetails: try FfiConverterTypeBlocktankError.read(from: &buf) - ) - case 3: return .DbBoltzError( - errorDetails: try FfiConverterTypeBoltzError.read(from: &buf) - ) - case 4: return .InitializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .wpkh + + case 3: return .shWpkh + + case 4: return .tr + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: DbError, into buf: inout [UInt8]) { + public static func write(_ value: JadeAddressVariant, into buf: inout [UInt8]) { switch value { - - - - case let .DbActivityError(errorDetails): + case .pkh: writeInt(&buf, Int32(1)) - FfiConverterTypeActivityError.write(errorDetails, into: &buf) - - case let .DbBlocktankError(errorDetails): + + case .wpkh: writeInt(&buf, Int32(2)) - FfiConverterTypeBlocktankError.write(errorDetails, into: &buf) - - case let .DbBoltzError(errorDetails): + + case .shWpkh: writeInt(&buf, Int32(3)) - FfiConverterTypeBoltzError.write(errorDetails, into: &buf) - - case let .InitializationError(errorDetails): + + case .tr: writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - + } } } @@ -23263,52 +24630,68 @@ 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 FfiConverterTypeJadeAddressVariant_lift(_ buf: RustBuffer) throws -> JadeAddressVariant { + return try FfiConverterTypeJadeAddressVariant.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDbError_lower(_ value: DbError) -> RustBuffer { - return FfiConverterTypeDbError.lower(value) +public func FfiConverterTypeJadeAddressVariant_lower(_ value: JadeAddressVariant) -> RustBuffer { + return FfiConverterTypeJadeAddressVariant.lower(value) } -extension DbError: Equatable, Hashable {} - -extension DbError: Codable {} - +extension JadeAddressVariant: Equatable, Hashable {} +extension JadeAddressVariant: Codable {} -extension DbError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} -public enum DecodingError: Swift.Error { +public enum JadeError: Swift.Error { - case InvalidFormat - case InvalidNetwork - case InvalidAmount - case InvalidLnurlPayAmount(amountSatoshis: UInt64, min: UInt64, max: UInt64 + case TransportError(errorDetails: String + ) + case DeviceNotFound + case DeviceDisconnected + case DeviceBusy + case NotConnected + case NotInitialized + case ConnectionError(errorDetails: String ) - case InvalidTimestamp - case InvalidChecksum - case InvalidResponse - case UnsupportedType - case InvalidAddress - case RequestFailed - case ClientCreationFailed - case InvoiceCreationFailed(errorMessage: String + case ProtocolError(errorDetails: String + ) + case Timeout + case UserCancelled + case DeviceLocked + case DeviceUninitialized + case InvalidPin + case NetworkMismatch(errorDetails: String + ) + case UnsupportedFirmware(installed: String, required: String + ) + case InvalidPath(errorDetails: String + ) + case InvalidPsbt(errorDetails: String + ) + case PsbtTooLarge(size: UInt64, max: UInt64 + ) + case FingerprintMismatch(device: String, psbt: String + ) + case NothingSigned + case AddressMismatch(expected: String, returned: String + ) + case PinServerError(errorDetails: String + ) + case DeviceError(errorDetails: String + ) + case IoError(errorDetails: String ) } @@ -23316,186 +24699,194 @@ public enum DecodingError: Swift.Error { #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDecodingError: FfiConverterRustBuffer { - typealias SwiftType = DecodingError +public struct FfiConverterTypeJadeError: FfiConverterRustBuffer { + typealias SwiftType = JadeError - 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 -> JadeError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InvalidFormat - case 2: return .InvalidNetwork - case 3: return .InvalidAmount - case 4: return .InvalidLnurlPayAmount( - amountSatoshis: try FfiConverterUInt64.read(from: &buf), - min: try FfiConverterUInt64.read(from: &buf), + case 1: return .TransportError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .DeviceNotFound + case 3: return .DeviceDisconnected + case 4: return .DeviceBusy + case 5: return .NotConnected + case 6: return .NotInitialized + case 7: return .ConnectionError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 8: return .ProtocolError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 9: return .Timeout + case 10: return .UserCancelled + case 11: return .DeviceLocked + case 12: return .DeviceUninitialized + case 13: return .InvalidPin + case 14: return .NetworkMismatch( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 15: return .UnsupportedFirmware( + installed: try FfiConverterString.read(from: &buf), + required: try FfiConverterString.read(from: &buf) + ) + case 16: return .InvalidPath( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 17: return .InvalidPsbt( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 18: return .PsbtTooLarge( + size: try FfiConverterUInt64.read(from: &buf), max: try FfiConverterUInt64.read(from: &buf) ) - case 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) + case 19: return .FingerprintMismatch( + device: try FfiConverterString.read(from: &buf), + psbt: try FfiConverterString.read(from: &buf) + ) + case 20: return .NothingSigned + case 21: return .AddressMismatch( + expected: try FfiConverterString.read(from: &buf), + returned: try FfiConverterString.read(from: &buf) + ) + case 22: return .PinServerError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 23: return .DeviceError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 24: return .IoError( + errorDetails: try FfiConverterString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: DecodingError, into buf: inout [UInt8]) { + public static func write(_ value: JadeError, into buf: inout [UInt8]) { switch value { - case .InvalidFormat: + case let .TransportError(errorDetails): writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .InvalidNetwork: + case .DeviceNotFound: writeInt(&buf, Int32(2)) - case .InvalidAmount: + case .DeviceDisconnected: writeInt(&buf, Int32(3)) - case let .InvalidLnurlPayAmount(amountSatoshis,min,max): + case .DeviceBusy: writeInt(&buf, Int32(4)) - FfiConverterUInt64.write(amountSatoshis, into: &buf) - FfiConverterUInt64.write(min, into: &buf) - FfiConverterUInt64.write(max, into: &buf) - - case .InvalidTimestamp: + + case .NotConnected: writeInt(&buf, Int32(5)) - case .InvalidChecksum: + case .NotInitialized: writeInt(&buf, Int32(6)) - case .InvalidResponse: + case let .ConnectionError(errorDetails): writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .UnsupportedType: + case let .ProtocolError(errorDetails): writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + - - case .InvalidAddress: + case .Timeout: writeInt(&buf, Int32(9)) - case .RequestFailed: + case .UserCancelled: writeInt(&buf, Int32(10)) - case .ClientCreationFailed: + case .DeviceLocked: writeInt(&buf, Int32(11)) - case let .InvoiceCreationFailed(errorMessage): + case .DeviceUninitialized: writeInt(&buf, Int32(12)) - FfiConverterString.write(errorMessage, into: &buf) + + + case .InvalidPin: + writeInt(&buf, Int32(13)) + + + case let .NetworkMismatch(errorDetails): + writeInt(&buf, Int32(14)) + FfiConverterString.write(errorDetails, into: &buf) - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDecodingError_lift(_ buf: RustBuffer) throws -> DecodingError { - return try FfiConverterTypeDecodingError.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeDecodingError_lower(_ value: DecodingError) -> RustBuffer { - return FfiConverterTypeDecodingError.lower(value) -} - - -extension DecodingError: Equatable, Hashable {} - -extension DecodingError: Codable {} - - - - -extension DecodingError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * How an application exchanges data with a hardware wallet. - */ - -public enum HardwareWalletTransport { - - case usb - case bluetooth - case qr -} - - -#if compiler(>=6) -extension HardwareWalletTransport: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { - typealias SwiftType = HardwareWalletTransport - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HardwareWalletTransport { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return .usb + case let .UnsupportedFirmware(installed,required): + writeInt(&buf, Int32(15)) + FfiConverterString.write(installed, into: &buf) + FfiConverterString.write(required, into: &buf) + - case 2: return .bluetooth + case let .InvalidPath(errorDetails): + writeInt(&buf, Int32(16)) + FfiConverterString.write(errorDetails, into: &buf) + - case 3: return .qr + case let .InvalidPsbt(errorDetails): + writeInt(&buf, Int32(17)) + FfiConverterString.write(errorDetails, into: &buf) + - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HardwareWalletTransport, into buf: inout [UInt8]) { - switch value { + case let .PsbtTooLarge(size,max): + writeInt(&buf, Int32(18)) + FfiConverterUInt64.write(size, into: &buf) + FfiConverterUInt64.write(max, into: &buf) + + case let .FingerprintMismatch(device,psbt): + writeInt(&buf, Int32(19)) + FfiConverterString.write(device, into: &buf) + FfiConverterString.write(psbt, into: &buf) + - case .usb: - writeInt(&buf, Int32(1)) + case .NothingSigned: + writeInt(&buf, Int32(20)) - case .bluetooth: - writeInt(&buf, Int32(2)) + case let .AddressMismatch(expected,returned): + writeInt(&buf, Int32(21)) + FfiConverterString.write(expected, into: &buf) + FfiConverterString.write(returned, into: &buf) + + case let .PinServerError(errorDetails): + writeInt(&buf, Int32(22)) + FfiConverterString.write(errorDetails, into: &buf) + - case .qr: - writeInt(&buf, Int32(3)) + case let .DeviceError(errorDetails): + writeInt(&buf, Int32(23)) + FfiConverterString.write(errorDetails, into: &buf) + + case let .IoError(errorDetails): + writeInt(&buf, Int32(24)) + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -23504,78 +24895,82 @@ public struct FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletTransport_lift(_ buf: RustBuffer) throws -> HardwareWalletTransport { - return try FfiConverterTypeHardwareWalletTransport.lift(buf) +public func FfiConverterTypeJadeError_lift(_ buf: RustBuffer) throws -> JadeError { + return try FfiConverterTypeJadeError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletTransport_lower(_ value: HardwareWalletTransport) -> RustBuffer { - return FfiConverterTypeHardwareWalletTransport.lower(value) +public func FfiConverterTypeJadeError_lower(_ value: JadeError) -> RustBuffer { + return FfiConverterTypeJadeError.lower(value) } -extension HardwareWalletTransport: Equatable, Hashable {} +extension JadeError: Equatable, Hashable {} + +extension JadeError: Codable {} -extension HardwareWalletTransport: Codable {} +extension JadeError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} + // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * A hardware-wallet vendor recognized by Bitkit. - */ -public enum HardwareWalletVendor { +public enum JadeNetwork { - case trezor - case foundation - case blockstream + case mainnet + case testnet + case regtest } #if compiler(>=6) -extension HardwareWalletVendor: Sendable {} +extension JadeNetwork: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeHardwareWalletVendor: FfiConverterRustBuffer { - typealias SwiftType = HardwareWalletVendor +public struct FfiConverterTypeJadeNetwork: FfiConverterRustBuffer { + typealias SwiftType = JadeNetwork - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HardwareWalletVendor { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeNetwork { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .trezor + case 1: return .mainnet - case 2: return .foundation + case 2: return .testnet - case 3: return .blockstream + case 3: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: HardwareWalletVendor, into buf: inout [UInt8]) { + public static func write(_ value: JadeNetwork, into buf: inout [UInt8]) { switch value { - case .trezor: + case .mainnet: writeInt(&buf, Int32(1)) - case .foundation: + case .testnet: writeInt(&buf, Int32(2)) - case .blockstream: + case .regtest: writeInt(&buf, Int32(3)) } @@ -23586,21 +24981,21 @@ public struct FfiConverterTypeHardwareWalletVendor: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletVendor_lift(_ buf: RustBuffer) throws -> HardwareWalletVendor { - return try FfiConverterTypeHardwareWalletVendor.lift(buf) +public func FfiConverterTypeJadeNetwork_lift(_ buf: RustBuffer) throws -> JadeNetwork { + return try FfiConverterTypeJadeNetwork.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletVendor_lower(_ value: HardwareWalletVendor) -> RustBuffer { - return FfiConverterTypeHardwareWalletVendor.lower(value) +public func FfiConverterTypeJadeNetwork_lower(_ value: JadeNetwork) -> RustBuffer { + return FfiConverterTypeJadeNetwork.lower(value) } -extension HardwareWalletVendor: Equatable, Hashable {} +extension JadeNetwork: Equatable, Hashable {} -extension HardwareWalletVendor: Codable {} +extension JadeNetwork: Codable {} @@ -23610,60 +25005,53 @@ extension HardwareWalletVendor: 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 JadeAddressVariant { +public enum JadePingStatus { - case pkh - case wpkh - case shWpkh - case tr + case idle + case busy + case awaitingUserInput } #if compiler(>=6) -extension JadeAddressVariant: Sendable {} +extension JadePingStatus: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeJadeAddressVariant: FfiConverterRustBuffer { - typealias SwiftType = JadeAddressVariant +public struct FfiConverterTypeJadePingStatus: FfiConverterRustBuffer { + typealias SwiftType = JadePingStatus - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeAddressVariant { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadePingStatus { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .pkh - - case 2: return .wpkh + case 1: return .idle - case 3: return .shWpkh + case 2: return .busy - case 4: return .tr + case 3: return .awaitingUserInput default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: JadeAddressVariant, into buf: inout [UInt8]) { + public static func write(_ value: JadePingStatus, into buf: inout [UInt8]) { switch value { - case .pkh: + case .idle: writeInt(&buf, Int32(1)) - case .wpkh: + case .busy: writeInt(&buf, Int32(2)) - case .shWpkh: + case .awaitingUserInput: writeInt(&buf, Int32(3)) - - case .tr: - writeInt(&buf, Int32(4)) - } } } @@ -23672,263 +25060,98 @@ public struct FfiConverterTypeJadeAddressVariant: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeAddressVariant_lift(_ buf: RustBuffer) throws -> JadeAddressVariant { - return try FfiConverterTypeJadeAddressVariant.lift(buf) +public func FfiConverterTypeJadePingStatus_lift(_ buf: RustBuffer) throws -> JadePingStatus { + return try FfiConverterTypeJadePingStatus.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeAddressVariant_lower(_ value: JadeAddressVariant) -> RustBuffer { - return FfiConverterTypeJadeAddressVariant.lower(value) +public func FfiConverterTypeJadePingStatus_lower(_ value: JadePingStatus) -> RustBuffer { + return FfiConverterTypeJadePingStatus.lower(value) } -extension JadeAddressVariant: Equatable, Hashable {} - -extension JadeAddressVariant: Codable {} +extension JadePingStatus: Equatable, Hashable {} +extension JadePingStatus: Codable {} -public enum JadeError: Swift.Error { +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum JadeState { - - case TransportError(errorDetails: String - ) - case DeviceNotFound - case DeviceDisconnected - case DeviceBusy - case NotConnected - case NotInitialized - case ConnectionError(errorDetails: String - ) - case ProtocolError(errorDetails: String - ) - case Timeout - case UserCancelled - case DeviceLocked - case DeviceUninitialized - case InvalidPin - case NetworkMismatch(errorDetails: String - ) - case UnsupportedFirmware(installed: String, required: String - ) - case InvalidPath(errorDetails: String - ) - case InvalidPsbt(errorDetails: String - ) - case PsbtTooLarge(size: UInt64, max: UInt64 - ) - case FingerprintMismatch(device: String, psbt: String - ) - case NothingSigned - case AddressMismatch(expected: String, returned: String - ) - case PinServerError(errorDetails: String - ) - case DeviceError(errorDetails: String - ) - case IoError(errorDetails: String - ) + case uninit + case unsaved + case locked + case ready + case temp + case unknown } +#if compiler(>=6) +extension JadeState: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeJadeError: FfiConverterRustBuffer { - typealias SwiftType = JadeError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .TransportError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .DeviceNotFound - case 3: return .DeviceDisconnected - case 4: return .DeviceBusy - case 5: return .NotConnected - case 6: return .NotInitialized - case 7: return .ConnectionError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 8: return .ProtocolError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 9: return .Timeout - case 10: return .UserCancelled - case 11: return .DeviceLocked - case 12: return .DeviceUninitialized - case 13: return .InvalidPin - case 14: return .NetworkMismatch( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 15: return .UnsupportedFirmware( - installed: try FfiConverterString.read(from: &buf), - required: try FfiConverterString.read(from: &buf) - ) - case 16: return .InvalidPath( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 17: return .InvalidPsbt( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 18: return .PsbtTooLarge( - size: try FfiConverterUInt64.read(from: &buf), - max: try FfiConverterUInt64.read(from: &buf) - ) - case 19: return .FingerprintMismatch( - device: try FfiConverterString.read(from: &buf), - psbt: try FfiConverterString.read(from: &buf) - ) - case 20: return .NothingSigned - case 21: return .AddressMismatch( - expected: try FfiConverterString.read(from: &buf), - returned: try FfiConverterString.read(from: &buf) - ) - case 22: return .PinServerError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 23: return .DeviceError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 24: return .IoError( - errorDetails: try FfiConverterString.read(from: &buf) - ) +public struct FfiConverterTypeJadeState: FfiConverterRustBuffer { + typealias SwiftType = JadeState - default: throw UniffiInternalError.unexpectedEnumCase + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeState { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .uninit + + case 2: return .unsaved + + case 3: return .locked + + case 4: return .ready + + case 5: return .temp + + case 6: return .unknown + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: JadeError, into buf: inout [UInt8]) { + public static func write(_ value: JadeState, into buf: inout [UInt8]) { switch value { - - - - case let .TransportError(errorDetails): + case .uninit: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - case .DeviceNotFound: + + case .unsaved: writeInt(&buf, Int32(2)) - case .DeviceDisconnected: + case .locked: writeInt(&buf, Int32(3)) - case .DeviceBusy: + case .ready: writeInt(&buf, Int32(4)) - case .NotConnected: + case .temp: writeInt(&buf, Int32(5)) - case .NotInitialized: + case .unknown: writeInt(&buf, Int32(6)) - - case let .ConnectionError(errorDetails): - writeInt(&buf, Int32(7)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .ProtocolError(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - - - case .Timeout: - writeInt(&buf, Int32(9)) - - - case .UserCancelled: - writeInt(&buf, Int32(10)) - - - case .DeviceLocked: - writeInt(&buf, Int32(11)) - - - case .DeviceUninitialized: - writeInt(&buf, Int32(12)) - - - case .InvalidPin: - writeInt(&buf, Int32(13)) - - - case let .NetworkMismatch(errorDetails): - writeInt(&buf, Int32(14)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .UnsupportedFirmware(installed,required): - writeInt(&buf, Int32(15)) - FfiConverterString.write(installed, into: &buf) - FfiConverterString.write(required, into: &buf) - - - case let .InvalidPath(errorDetails): - writeInt(&buf, Int32(16)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InvalidPsbt(errorDetails): - writeInt(&buf, Int32(17)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .PsbtTooLarge(size,max): - writeInt(&buf, Int32(18)) - FfiConverterUInt64.write(size, into: &buf) - FfiConverterUInt64.write(max, into: &buf) - - - case let .FingerprintMismatch(device,psbt): - writeInt(&buf, Int32(19)) - FfiConverterString.write(device, into: &buf) - FfiConverterString.write(psbt, into: &buf) - - - case .NothingSigned: - writeInt(&buf, Int32(20)) - - - case let .AddressMismatch(expected,returned): - writeInt(&buf, Int32(21)) - FfiConverterString.write(expected, into: &buf) - FfiConverterString.write(returned, into: &buf) - - - case let .PinServerError(errorDetails): - writeInt(&buf, Int32(22)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .DeviceError(errorDetails): - writeInt(&buf, Int32(23)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .IoError(errorDetails): - writeInt(&buf, Int32(24)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -23937,30 +25160,23 @@ public struct FfiConverterTypeJadeError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeError_lift(_ buf: RustBuffer) throws -> JadeError { - return try FfiConverterTypeJadeError.lift(buf) +public func FfiConverterTypeJadeState_lift(_ buf: RustBuffer) throws -> JadeState { + return try FfiConverterTypeJadeState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeError_lower(_ value: JadeError) -> RustBuffer { - return FfiConverterTypeJadeError.lower(value) +public func FfiConverterTypeJadeState_lower(_ value: JadeState) -> RustBuffer { + return FfiConverterTypeJadeState.lower(value) } -extension JadeError: Equatable, Hashable {} - -extension JadeError: Codable {} - +extension JadeState: Equatable, Hashable {} +extension JadeState: Codable {} -extension JadeError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} @@ -23968,53 +25184,67 @@ extension JadeError: 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 JadeNetwork { +public enum JadeTransportErrorCode { - case mainnet - case testnet - case regtest + case deviceBusy + case notConnected + case disconnected + case timeout + case permissionDenied } #if compiler(>=6) -extension JadeNetwork: Sendable {} +extension JadeTransportErrorCode: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeJadeNetwork: FfiConverterRustBuffer { - typealias SwiftType = JadeNetwork +public struct FfiConverterTypeJadeTransportErrorCode: FfiConverterRustBuffer { + typealias SwiftType = JadeTransportErrorCode - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeNetwork { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportErrorCode { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .mainnet + case 1: return .deviceBusy - case 2: return .testnet + case 2: return .notConnected - case 3: return .regtest + case 3: return .disconnected + + case 4: return .timeout + + case 5: return .permissionDenied default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: JadeNetwork, into buf: inout [UInt8]) { + public static func write(_ value: JadeTransportErrorCode, into buf: inout [UInt8]) { switch value { - case .mainnet: + case .deviceBusy: writeInt(&buf, Int32(1)) - case .testnet: + case .notConnected: writeInt(&buf, Int32(2)) - case .regtest: + case .disconnected: writeInt(&buf, Int32(3)) + + case .timeout: + writeInt(&buf, Int32(4)) + + + case .permissionDenied: + writeInt(&buf, Int32(5)) + } } } @@ -24023,21 +25253,21 @@ public struct FfiConverterTypeJadeNetwork: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeNetwork_lift(_ buf: RustBuffer) throws -> JadeNetwork { - return try FfiConverterTypeJadeNetwork.lift(buf) +public func FfiConverterTypeJadeTransportErrorCode_lift(_ buf: RustBuffer) throws -> JadeTransportErrorCode { + return try FfiConverterTypeJadeTransportErrorCode.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeNetwork_lower(_ value: JadeNetwork) -> RustBuffer { - return FfiConverterTypeJadeNetwork.lower(value) +public func FfiConverterTypeJadeTransportErrorCode_lower(_ value: JadeTransportErrorCode) -> RustBuffer { + return FfiConverterTypeJadeTransportErrorCode.lower(value) } -extension JadeNetwork: Equatable, Hashable {} +extension JadeTransportErrorCode: Equatable, Hashable {} -extension JadeNetwork: Codable {} +extension JadeTransportErrorCode: Codable {} @@ -24047,53 +25277,46 @@ extension JadeNetwork: 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 JadePingStatus { +public enum JadeTransportKind { - case idle - case busy - case awaitingUserInput + case bluetooth + case serial } #if compiler(>=6) -extension JadePingStatus: Sendable {} +extension JadeTransportKind: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeJadePingStatus: FfiConverterRustBuffer { - typealias SwiftType = JadePingStatus +public struct FfiConverterTypeJadeTransportKind: FfiConverterRustBuffer { + typealias SwiftType = JadeTransportKind - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadePingStatus { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportKind { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .idle - - case 2: return .busy + case 1: return .bluetooth - case 3: return .awaitingUserInput + case 2: return .serial default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: JadePingStatus, into buf: inout [UInt8]) { + public static func write(_ value: JadeTransportKind, into buf: inout [UInt8]) { switch value { - case .idle: + case .bluetooth: writeInt(&buf, Int32(1)) - case .busy: + case .serial: writeInt(&buf, Int32(2)) - - case .awaitingUserInput: - writeInt(&buf, Int32(3)) - } } } @@ -24102,97 +25325,124 @@ public struct FfiConverterTypeJadePingStatus: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadePingStatus_lift(_ buf: RustBuffer) throws -> JadePingStatus { - return try FfiConverterTypeJadePingStatus.lift(buf) +public func FfiConverterTypeJadeTransportKind_lift(_ buf: RustBuffer) throws -> JadeTransportKind { + return try FfiConverterTypeJadeTransportKind.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadePingStatus_lower(_ value: JadePingStatus) -> RustBuffer { - return FfiConverterTypeJadePingStatus.lower(value) +public func FfiConverterTypeJadeTransportKind_lower(_ value: JadeTransportKind) -> RustBuffer { + return FfiConverterTypeJadeTransportKind.lower(value) } -extension JadePingStatus: Equatable, Hashable {} +extension JadeTransportKind: Equatable, Hashable {} -extension JadePingStatus: Codable {} +extension JadeTransportKind: 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 JadeState { +public enum LnurlError: Swift.Error { + - case uninit - case unsaved - case locked - case ready - case temp - case unknown + + case InvalidAddress + case ClientCreationFailed + case RequestFailed + case InvalidResponse + case InvalidAmount(amountSatoshis: UInt64, min: UInt64, max: UInt64 + ) + case InvoiceCreationFailed(errorDetails: String + ) + case AmountMismatch(requestedMsats: UInt64, invoiceMsats: UInt64 + ) + case AuthenticationFailed } -#if compiler(>=6) -extension JadeState: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeJadeState: FfiConverterRustBuffer { - typealias SwiftType = JadeState +public struct FfiConverterTypeLnurlError: FfiConverterRustBuffer { + typealias SwiftType = LnurlError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeState { + 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 .uninit - - case 2: return .unsaved - - case 3: return .locked - - case 4: return .ready - - case 5: return .temp - - case 6: return .unknown + - default: throw UniffiInternalError.unexpectedEnumCase + 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 .AmountMismatch( + requestedMsats: try FfiConverterUInt64.read(from: &buf), + invoiceMsats: try FfiConverterUInt64.read(from: &buf) + ) + case 8: return .AuthenticationFailed + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: JadeState, into buf: inout [UInt8]) { + public static func write(_ value: LnurlError, into buf: inout [UInt8]) { switch value { + + - case .uninit: + + case .InvalidAddress: writeInt(&buf, Int32(1)) - case .unsaved: + case .ClientCreationFailed: writeInt(&buf, Int32(2)) - case .locked: + case .RequestFailed: writeInt(&buf, Int32(3)) - case .ready: + case .InvalidResponse: writeInt(&buf, Int32(4)) - case .temp: + 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 .unknown: + case let .InvoiceCreationFailed(errorDetails): writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .AmountMismatch(requestedMsats,invoiceMsats): + writeInt(&buf, Int32(7)) + FfiConverterUInt64.write(requestedMsats, into: &buf) + FfiConverterUInt64.write(invoiceMsats, into: &buf) + + + case .AuthenticationFailed: + writeInt(&buf, Int32(8)) } } @@ -24202,23 +25452,30 @@ public struct FfiConverterTypeJadeState: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeState_lift(_ buf: RustBuffer) throws -> JadeState { - return try FfiConverterTypeJadeState.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 FfiConverterTypeJadeState_lower(_ value: JadeState) -> RustBuffer { - return FfiConverterTypeJadeState.lower(value) +public func FfiConverterTypeLnurlError_lower(_ value: LnurlError) -> RustBuffer { + return FfiConverterTypeLnurlError.lower(value) } -extension JadeState: Equatable, Hashable {} +extension LnurlError: Equatable, Hashable {} + +extension LnurlError: Codable {} + -extension JadeState: Codable {} +extension LnurlError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} @@ -24226,67 +25483,60 @@ extension JadeState: 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 JadeTransportErrorCode { +public enum ManualRefundStateEnum { - case deviceBusy - case notConnected - case disconnected - case timeout - case permissionDenied + case created + case approved + case rejected + case sent } #if compiler(>=6) -extension JadeTransportErrorCode: Sendable {} +extension ManualRefundStateEnum: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeJadeTransportErrorCode: FfiConverterRustBuffer { - typealias SwiftType = JadeTransportErrorCode +public struct FfiConverterTypeManualRefundStateEnum: FfiConverterRustBuffer { + typealias SwiftType = ManualRefundStateEnum - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportErrorCode { + 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 .deviceBusy - - case 2: return .notConnected + case 1: return .created - case 3: return .disconnected + case 2: return .approved - case 4: return .timeout + case 3: return .rejected - case 5: return .permissionDenied + case 4: return .sent default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: JadeTransportErrorCode, into buf: inout [UInt8]) { + public static func write(_ value: ManualRefundStateEnum, into buf: inout [UInt8]) { switch value { - case .deviceBusy: + case .created: writeInt(&buf, Int32(1)) - case .notConnected: + case .approved: writeInt(&buf, Int32(2)) - case .disconnected: + case .rejected: writeInt(&buf, Int32(3)) - case .timeout: + case .sent: writeInt(&buf, Int32(4)) - - case .permissionDenied: - writeInt(&buf, Int32(5)) - } } } @@ -24295,21 +25545,21 @@ public struct FfiConverterTypeJadeTransportErrorCode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeTransportErrorCode_lift(_ buf: RustBuffer) throws -> JadeTransportErrorCode { - return try FfiConverterTypeJadeTransportErrorCode.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 FfiConverterTypeJadeTransportErrorCode_lower(_ value: JadeTransportErrorCode) -> RustBuffer { - return FfiConverterTypeJadeTransportErrorCode.lower(value) +public func FfiConverterTypeManualRefundStateEnum_lower(_ value: ManualRefundStateEnum) -> RustBuffer { + return FfiConverterTypeManualRefundStateEnum.lower(value) } -extension JadeTransportErrorCode: Equatable, Hashable {} +extension ManualRefundStateEnum: Equatable, Hashable {} -extension JadeTransportErrorCode: Codable {} +extension ManualRefundStateEnum: Codable {} @@ -24319,46 +25569,82 @@ extension JadeTransportErrorCode: 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 JadeTransportKind { +public enum Network { - case bluetooth - case serial + /** + * Mainnet Bitcoin. + */ + case bitcoin + /** + * Bitcoin's testnet network. + */ + case testnet + /** + * Bitcoin's testnet4 network. + */ + case testnet4 + /** + * Bitcoin's signet network. + */ + case signet + /** + * Bitcoin's regtest network. + */ + case regtest } #if compiler(>=6) -extension JadeTransportKind: Sendable {} +extension Network: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeJadeTransportKind: FfiConverterRustBuffer { - typealias SwiftType = JadeTransportKind +public struct FfiConverterTypeNetwork: FfiConverterRustBuffer { + typealias SwiftType = Network - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportKind { + 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 .bluetooth + case 1: return .bitcoin - case 2: return .serial + case 2: return .testnet + + case 3: return .testnet4 + + case 4: return .signet + + case 5: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: JadeTransportKind, into buf: inout [UInt8]) { + public static func write(_ value: Network, into buf: inout [UInt8]) { switch value { - case .bluetooth: + case .bitcoin: writeInt(&buf, Int32(1)) - case .serial: + case .testnet: writeInt(&buf, Int32(2)) + + case .testnet4: + writeInt(&buf, Int32(3)) + + + case .signet: + writeInt(&buf, Int32(4)) + + + case .regtest: + writeInt(&buf, Int32(5)) + } } } @@ -24367,125 +25653,84 @@ public struct FfiConverterTypeJadeTransportKind: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeJadeTransportKind_lift(_ buf: RustBuffer) throws -> JadeTransportKind { - return try FfiConverterTypeJadeTransportKind.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 FfiConverterTypeJadeTransportKind_lower(_ value: JadeTransportKind) -> RustBuffer { - return FfiConverterTypeJadeTransportKind.lower(value) +public func FfiConverterTypeNetwork_lower(_ value: Network) -> RustBuffer { + return FfiConverterTypeNetwork.lower(value) } -extension JadeTransportKind: Equatable, Hashable {} - -extension JadeTransportKind: Codable {} +extension Network: Equatable, Hashable {} +extension Network: Codable {} -public enum LnurlError: 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 NetworkType { - - case InvalidAddress - case ClientCreationFailed - case RequestFailed - case InvalidResponse - case InvalidAmount(amountSatoshis: UInt64, min: UInt64, max: UInt64 - ) - case InvoiceCreationFailed(errorDetails: String - ) - case AmountMismatch(requestedMsats: UInt64, invoiceMsats: UInt64 - ) - case AuthenticationFailed + case bitcoin + case testnet + case regtest + case signet } +#if compiler(>=6) +extension NetworkType: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLnurlError: FfiConverterRustBuffer { - typealias SwiftType = LnurlError +public struct FfiConverterTypeNetworkType: FfiConverterRustBuffer { + typealias SwiftType = NetworkType - 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 -> NetworkType { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .bitcoin - 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 .AmountMismatch( - requestedMsats: try FfiConverterUInt64.read(from: &buf), - invoiceMsats: try FfiConverterUInt64.read(from: &buf) - ) - case 8: return .AuthenticationFailed - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .testnet + + case 3: return .regtest + + case 4: return .signet + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: LnurlError, into buf: inout [UInt8]) { + public static func write(_ value: NetworkType, into buf: inout [UInt8]) { switch value { - - - - case .InvalidAddress: + case .bitcoin: writeInt(&buf, Int32(1)) - case .ClientCreationFailed: + case .testnet: writeInt(&buf, Int32(2)) - case .RequestFailed: + case .regtest: writeInt(&buf, Int32(3)) - case .InvalidResponse: + case .signet: 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 let .AmountMismatch(requestedMsats,invoiceMsats): - writeInt(&buf, Int32(7)) - FfiConverterUInt64.write(requestedMsats, into: &buf) - FfiConverterUInt64.write(invoiceMsats, into: &buf) - - - case .AuthenticationFailed: - writeInt(&buf, Int32(8)) - } } } @@ -24494,91 +25739,69 @@ 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 FfiConverterTypeNetworkType_lift(_ buf: RustBuffer) throws -> NetworkType { + return try FfiConverterTypeNetworkType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlError_lower(_ value: LnurlError) -> RustBuffer { - return FfiConverterTypeLnurlError.lower(value) +public func FfiConverterTypeNetworkType_lower(_ value: NetworkType) -> RustBuffer { + return FfiConverterTypeNetworkType.lower(value) } -extension LnurlError: Equatable, Hashable {} - -extension LnurlError: Codable {} +extension NetworkType: Equatable, Hashable {} +extension NetworkType: Codable {} -extension LnurlError: 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 OnchainError: Swift.Error { -public enum ManualRefundStateEnum { - case created - case approved - case rejected - case sent + + case InvalidExtendedPublicKey(errorDetails: String + ) } -#if compiler(>=6) -extension ManualRefundStateEnum: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeManualRefundStateEnum: FfiConverterRustBuffer { - typealias SwiftType = ManualRefundStateEnum +public struct FfiConverterTypeOnchainError: FfiConverterRustBuffer { + typealias SwiftType = OnchainError - 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 -> OnchainError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .created - - case 2: return .approved - - case 3: return .rejected - - case 4: return .sent + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .InvalidExtendedPublicKey( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ManualRefundStateEnum, into buf: inout [UInt8]) { + public static func write(_ value: OnchainError, into buf: inout [UInt8]) { switch value { + + - case .created: - writeInt(&buf, Int32(1)) - - - case .approved: - writeInt(&buf, Int32(2)) - - - case .rejected: - writeInt(&buf, Int32(3)) - - - case .sent: - writeInt(&buf, Int32(4)) + case let .InvalidExtendedPublicKey(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -24587,106 +25810,106 @@ 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 FfiConverterTypeOnchainError_lift(_ buf: RustBuffer) throws -> OnchainError { + return try FfiConverterTypeOnchainError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeManualRefundStateEnum_lower(_ value: ManualRefundStateEnum) -> RustBuffer { - return FfiConverterTypeManualRefundStateEnum.lower(value) +public func FfiConverterTypeOnchainError_lower(_ value: OnchainError) -> RustBuffer { + return FfiConverterTypeOnchainError.lower(value) } -extension ManualRefundStateEnum: Equatable, Hashable {} +extension OnchainError: Equatable, Hashable {} + +extension OnchainError: Codable {} -extension ManualRefundStateEnum: Codable {} +extension OnchainError: 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 Network { +public enum PassphraseResponse { /** - * Mainnet Bitcoin. - */ - case bitcoin - /** - * Bitcoin's testnet network. + * User cancelled. Aborts the pending operation. */ - case testnet + case cancel /** - * Bitcoin's testnet4 network. + * Standard wallet with no passphrase, equivalent to `Some("")` on the device. */ - case testnet4 + case standard /** - * Bitcoin's signet network. + * Hidden wallet derived from the passphrase entered on the host. */ - case signet + case hidden(value: String + ) /** - * Bitcoin's regtest network. + * Enter the passphrase on the Trezor device itself instead of on the host. */ - case regtest + case onDevice } #if compiler(>=6) -extension Network: Sendable {} +extension PassphraseResponse: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeNetwork: FfiConverterRustBuffer { - typealias SwiftType = Network +public struct FfiConverterTypePassphraseResponse: FfiConverterRustBuffer { + typealias SwiftType = PassphraseResponse - 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 -> PassphraseResponse { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .bitcoin - - case 2: return .testnet + case 1: return .cancel - case 3: return .testnet4 + case 2: return .standard - case 4: return .signet + case 3: return .hidden(value: try FfiConverterString.read(from: &buf) + ) - case 5: return .regtest + case 4: return .onDevice default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: Network, into buf: inout [UInt8]) { + public static func write(_ value: PassphraseResponse, into buf: inout [UInt8]) { switch value { - case .bitcoin: + case .cancel: writeInt(&buf, Int32(1)) - case .testnet: + case .standard: writeInt(&buf, Int32(2)) - case .testnet4: + case let .hidden(value): writeInt(&buf, Int32(3)) + FfiConverterString.write(value, into: &buf) + - - case .signet: + case .onDevice: writeInt(&buf, Int32(4)) - - case .regtest: - writeInt(&buf, Int32(5)) - } } } @@ -24695,21 +25918,21 @@ 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 FfiConverterTypePassphraseResponse_lift(_ buf: RustBuffer) throws -> PassphraseResponse { + return try FfiConverterTypePassphraseResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNetwork_lower(_ value: Network) -> RustBuffer { - return FfiConverterTypeNetwork.lower(value) +public func FfiConverterTypePassphraseResponse_lower(_ value: PassphraseResponse) -> RustBuffer { + return FfiConverterTypePassphraseResponse.lower(value) } -extension Network: Equatable, Hashable {} +extension PassphraseResponse: Equatable, Hashable {} -extension Network: Codable {} +extension PassphraseResponse: Codable {} @@ -24718,61 +25941,88 @@ extension Network: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * The route the router picked. A direct route means no swap is needed. + */ -public enum NetworkType { +public enum PaykitRoute { - case bitcoin - case testnet - case regtest - case signet + /** + * The wallet can pay this endpoint from its own balance. + */ + case direct(endpoint: PaykitEndpoint + ) + /** + * The wallet pays over Lightning and a Pubky Swaps provider delivers on-chain. + */ + case swap(quote: PubkySwapRouteQuote + ) + /** + * A service the wallet holds a balance on delivers to the contact. The app runs the leg. + */ + case service(leg: ServiceRouteLeg + ) + /** + * Nothing can pay this contact. `reason` says why, for the user. + */ + case none(reason: String + ) } #if compiler(>=6) -extension NetworkType: Sendable {} +extension PaykitRoute: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeNetworkType: FfiConverterRustBuffer { - typealias SwiftType = NetworkType +public struct FfiConverterTypePaykitRoute: FfiConverterRustBuffer { + typealias SwiftType = PaykitRoute - 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 -> PaykitRoute { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .bitcoin + case 1: return .direct(endpoint: try FfiConverterTypePaykitEndpoint.read(from: &buf) + ) - case 2: return .testnet + case 2: return .swap(quote: try FfiConverterTypePubkySwapRouteQuote.read(from: &buf) + ) - case 3: return .regtest + case 3: return .service(leg: try FfiConverterTypeServiceRouteLeg.read(from: &buf) + ) - case 4: return .signet + case 4: return .none(reason: try FfiConverterString.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: NetworkType, into buf: inout [UInt8]) { + public static func write(_ value: PaykitRoute, into buf: inout [UInt8]) { switch value { - case .bitcoin: + case let .direct(endpoint): writeInt(&buf, Int32(1)) + FfiConverterTypePaykitEndpoint.write(endpoint, into: &buf) + - - case .testnet: + case let .swap(quote): writeInt(&buf, Int32(2)) + FfiConverterTypePubkySwapRouteQuote.write(quote, into: &buf) + - - case .regtest: + case let .service(leg): writeInt(&buf, Int32(3)) + FfiConverterTypeServiceRouteLeg.write(leg, into: &buf) + - - case .signet: + case let .none(reason): writeInt(&buf, Int32(4)) - + FfiConverterString.write(reason, into: &buf) + } } } @@ -24781,69 +26031,77 @@ 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 FfiConverterTypePaykitRoute_lift(_ buf: RustBuffer) throws -> PaykitRoute { + return try FfiConverterTypePaykitRoute.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNetworkType_lower(_ value: NetworkType) -> RustBuffer { - return FfiConverterTypeNetworkType.lower(value) +public func FfiConverterTypePaykitRoute_lower(_ value: PaykitRoute) -> RustBuffer { + return FfiConverterTypePaykitRoute.lower(value) } -extension NetworkType: Equatable, Hashable {} - -extension NetworkType: Codable {} +extension PaykitRoute: Equatable, Hashable {} +extension PaykitRoute: Codable {} -public enum OnchainError: 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 InvalidExtendedPublicKey(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 FfiConverterTypeOnchainError: FfiConverterRustBuffer { - typealias SwiftType = OnchainError +public struct FfiConverterTypePaymentState: FfiConverterRustBuffer { + typealias SwiftType = PaymentState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnchainError { + 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 .InvalidExtendedPublicKey( - 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: OnchainError, into buf: inout [UInt8]) { + public static func write(_ value: PaymentState, into buf: inout [UInt8]) { switch value { - - - - case let .InvalidExtendedPublicKey(errorDetails): + case .pending: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - + + + case .succeeded: + writeInt(&buf, Int32(2)) + + + case .failed: + writeInt(&buf, Int32(3)) + } } } @@ -24852,30 +26110,23 @@ public struct FfiConverterTypeOnchainError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeOnchainError_lift(_ buf: RustBuffer) throws -> OnchainError { - return try FfiConverterTypeOnchainError.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 FfiConverterTypeOnchainError_lower(_ value: OnchainError) -> RustBuffer { - return FfiConverterTypeOnchainError.lower(value) +public func FfiConverterTypePaymentState_lower(_ value: PaymentState) -> RustBuffer { + return FfiConverterTypePaymentState.lower(value) } -extension OnchainError: Equatable, Hashable {} - -extension OnchainError: Codable {} - +extension PaymentState: Equatable, Hashable {} +extension PaymentState: Codable {} -extension OnchainError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} @@ -24883,75 +26134,46 @@ extension OnchainError: 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 PassphraseResponse { +public enum PaymentType { - /** - * User cancelled. Aborts the pending operation. - */ - case cancel - /** - * Standard wallet with no passphrase, equivalent to `Some("")` on the device. - */ - case standard - /** - * Hidden wallet derived from the passphrase entered on the host. - */ - case hidden(value: String - ) - /** - * Enter the passphrase on the Trezor device itself instead of on the host. - */ - case onDevice + case sent + case received } #if compiler(>=6) -extension PassphraseResponse: Sendable {} +extension PaymentType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePassphraseResponse: FfiConverterRustBuffer { - typealias SwiftType = PassphraseResponse +public struct FfiConverterTypePaymentType: FfiConverterRustBuffer { + typealias SwiftType = PaymentType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PassphraseResponse { + 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 .cancel - - case 2: return .standard - - case 3: return .hidden(value: try FfiConverterString.read(from: &buf) - ) + case 1: return .sent - case 4: return .onDevice + case 2: return .received default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: PassphraseResponse, into buf: inout [UInt8]) { + public static func write(_ value: PaymentType, into buf: inout [UInt8]) { switch value { - case .cancel: + case .sent: writeInt(&buf, Int32(1)) - case .standard: + case .received: writeInt(&buf, Int32(2)) - - case let .hidden(value): - writeInt(&buf, Int32(3)) - FfiConverterString.write(value, into: &buf) - - - case .onDevice: - writeInt(&buf, Int32(4)) - } } } @@ -24960,77 +26182,109 @@ public struct FfiConverterTypePassphraseResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePassphraseResponse_lift(_ buf: RustBuffer) throws -> PassphraseResponse { - return try FfiConverterTypePassphraseResponse.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 FfiConverterTypePassphraseResponse_lower(_ value: PassphraseResponse) -> RustBuffer { - return FfiConverterTypePassphraseResponse.lower(value) +public func FfiConverterTypePaymentType_lower(_ value: PaymentType) -> RustBuffer { + return FfiConverterTypePaymentType.lower(value) } -extension PassphraseResponse: Equatable, Hashable {} +extension PaymentType: Equatable, Hashable {} -extension PassphraseResponse: Codable {} +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 PaymentState { +public enum PsbtCompletionError: Swift.Error { + - case pending - case succeeded - case failed + + case InvalidPsbt(reason: String + ) + case CombineFailed(reason: String + ) + case FinalizationFailed(reason: String + ) + case VerificationFailed(reason: String + ) + case ExtractionFailed(reason: String + ) } -#if compiler(>=6) -extension PaymentState: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePaymentState: FfiConverterRustBuffer { - typealias SwiftType = PaymentState +public struct FfiConverterTypePsbtCompletionError: FfiConverterRustBuffer { + typealias SwiftType = PsbtCompletionError - 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 -> PsbtCompletionError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .pending - - case 2: return .succeeded - - case 3: return .failed + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .InvalidPsbt( + reason: try FfiConverterString.read(from: &buf) + ) + case 2: return .CombineFailed( + reason: try FfiConverterString.read(from: &buf) + ) + case 3: return .FinalizationFailed( + reason: try FfiConverterString.read(from: &buf) + ) + case 4: return .VerificationFailed( + reason: try FfiConverterString.read(from: &buf) + ) + case 5: return .ExtractionFailed( + reason: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: PaymentState, into buf: inout [UInt8]) { + public static func write(_ value: PsbtCompletionError, into buf: inout [UInt8]) { switch value { + + - case .pending: - writeInt(&buf, Int32(1)) + case let .InvalidPsbt(reason): + writeInt(&buf, Int32(1)) + FfiConverterString.write(reason, into: &buf) + - case .succeeded: + case let .CombineFailed(reason): writeInt(&buf, Int32(2)) + FfiConverterString.write(reason, into: &buf) + - - case .failed: + case let .FinalizationFailed(reason): writeInt(&buf, Int32(3)) + FfiConverterString.write(reason, into: &buf) + + + case let .VerificationFailed(reason): + writeInt(&buf, Int32(4)) + FfiConverterString.write(reason, into: &buf) + + case let .ExtractionFailed(reason): + writeInt(&buf, Int32(5)) + FfiConverterString.write(reason, into: &buf) + } } } @@ -25039,68 +26293,78 @@ public struct FfiConverterTypePaymentState: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePaymentState_lift(_ buf: RustBuffer) throws -> PaymentState { - return try FfiConverterTypePaymentState.lift(buf) +public func FfiConverterTypePsbtCompletionError_lift(_ buf: RustBuffer) throws -> PsbtCompletionError { + return try FfiConverterTypePsbtCompletionError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePaymentState_lower(_ value: PaymentState) -> RustBuffer { - return FfiConverterTypePaymentState.lower(value) +public func FfiConverterTypePsbtCompletionError_lower(_ value: PsbtCompletionError) -> RustBuffer { + return FfiConverterTypePsbtCompletionError.lower(value) } -extension PaymentState: Equatable, Hashable {} +extension PsbtCompletionError: Equatable, Hashable {} + +extension PsbtCompletionError: Codable {} + -extension PaymentState: Codable {} +extension PsbtCompletionError: 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. +/** + * The type of a `pubkyauth://` deep-link flow. + */ -public enum PaymentType { +public enum PubkyAuthKind { - case sent - case received + case signin + case signup } #if compiler(>=6) -extension PaymentType: Sendable {} +extension PubkyAuthKind: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePaymentType: FfiConverterRustBuffer { - typealias SwiftType = PaymentType +public struct FfiConverterTypePubkyAuthKind: FfiConverterRustBuffer { + typealias SwiftType = PubkyAuthKind - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PaymentType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyAuthKind { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .sent + case 1: return .signin - case 2: return .received + case 2: return .signup default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: PaymentType, into buf: inout [UInt8]) { + public static func write(_ value: PubkyAuthKind, into buf: inout [UInt8]) { switch value { - case .sent: + case .signin: writeInt(&buf, Int32(1)) - case .received: + case .signup: writeInt(&buf, Int32(2)) } @@ -25111,21 +26375,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 FfiConverterTypePubkyAuthKind_lift(_ buf: RustBuffer) throws -> PubkyAuthKind { + return try FfiConverterTypePubkyAuthKind.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePaymentType_lower(_ value: PaymentType) -> RustBuffer { - return FfiConverterTypePaymentType.lower(value) +public func FfiConverterTypePubkyAuthKind_lower(_ value: PubkyAuthKind) -> RustBuffer { + return FfiConverterTypePubkyAuthKind.lower(value) } -extension PaymentType: Equatable, Hashable {} +extension PubkyAuthKind: Equatable, Hashable {} -extension PaymentType: Codable {} +extension PubkyAuthKind: Codable {} @@ -25133,19 +26397,25 @@ extension PaymentType: Codable {} -public enum PsbtCompletionError: Swift.Error { +public enum PubkyError: Swift.Error { - case InvalidPsbt(reason: String + case InvalidCapabilities(reason: String ) - case CombineFailed(reason: String + case AuthFailed(reason: String ) - case FinalizationFailed(reason: String + case NoActiveFlow + case ResolutionFailed(reason: String ) - case VerificationFailed(reason: String + case FetchFailed(reason: String ) - case ExtractionFailed(reason: String + case ProfileNotFound + case ProfileParseFailed(reason: String + ) + case KeyError(reason: String + ) + case WriteFailed(reason: String ) } @@ -25153,29 +26423,37 @@ public enum PsbtCompletionError: Swift.Error { #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePsbtCompletionError: FfiConverterRustBuffer { - typealias SwiftType = PsbtCompletionError +public struct FfiConverterTypePubkyError: FfiConverterRustBuffer { + typealias SwiftType = PubkyError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PsbtCompletionError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InvalidPsbt( + case 1: return .InvalidCapabilities( reason: try FfiConverterString.read(from: &buf) ) - case 2: return .CombineFailed( + case 2: return .AuthFailed( reason: try FfiConverterString.read(from: &buf) ) - case 3: return .FinalizationFailed( + case 3: return .NoActiveFlow + case 4: return .ResolutionFailed( reason: try FfiConverterString.read(from: &buf) ) - case 4: return .VerificationFailed( + case 5: return .FetchFailed( reason: try FfiConverterString.read(from: &buf) ) - case 5: return .ExtractionFailed( + case 6: return .ProfileNotFound + case 7: return .ProfileParseFailed( + reason: try FfiConverterString.read(from: &buf) + ) + case 8: return .KeyError( + reason: try FfiConverterString.read(from: &buf) + ) + case 9: return .WriteFailed( reason: try FfiConverterString.read(from: &buf) ) @@ -25183,37 +26461,55 @@ public struct FfiConverterTypePsbtCompletionError: FfiConverterRustBuffer { } } - public static func write(_ value: PsbtCompletionError, into buf: inout [UInt8]) { + public static func write(_ value: PubkyError, into buf: inout [UInt8]) { switch value { - case let .InvalidPsbt(reason): + case let .InvalidCapabilities(reason): writeInt(&buf, Int32(1)) FfiConverterString.write(reason, into: &buf) - case let .CombineFailed(reason): + case let .AuthFailed(reason): writeInt(&buf, Int32(2)) FfiConverterString.write(reason, into: &buf) - case let .FinalizationFailed(reason): + case .NoActiveFlow: writeInt(&buf, Int32(3)) - FfiConverterString.write(reason, into: &buf) - - case let .VerificationFailed(reason): + + case let .ResolutionFailed(reason): writeInt(&buf, Int32(4)) FfiConverterString.write(reason, into: &buf) - case let .ExtractionFailed(reason): + case let .FetchFailed(reason): writeInt(&buf, Int32(5)) FfiConverterString.write(reason, into: &buf) + + case .ProfileNotFound: + writeInt(&buf, Int32(6)) + + + case let .ProfileParseFailed(reason): + writeInt(&buf, Int32(7)) + FfiConverterString.write(reason, into: &buf) + + + case let .KeyError(reason): + writeInt(&buf, Int32(8)) + FfiConverterString.write(reason, into: &buf) + + + case let .WriteFailed(reason): + writeInt(&buf, Int32(9)) + FfiConverterString.write(reason, into: &buf) + } } } @@ -25222,26 +26518,26 @@ public struct FfiConverterTypePsbtCompletionError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePsbtCompletionError_lift(_ buf: RustBuffer) throws -> PsbtCompletionError { - return try FfiConverterTypePsbtCompletionError.lift(buf) +public func FfiConverterTypePubkyError_lift(_ buf: RustBuffer) throws -> PubkyError { + return try FfiConverterTypePubkyError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePsbtCompletionError_lower(_ value: PsbtCompletionError) -> RustBuffer { - return FfiConverterTypePsbtCompletionError.lower(value) +public func FfiConverterTypePubkyError_lower(_ value: PubkyError) -> RustBuffer { + return FfiConverterTypePubkyError.lower(value) } -extension PsbtCompletionError: Equatable, Hashable {} +extension PubkyError: Equatable, Hashable {} -extension PsbtCompletionError: Codable {} +extension PubkyError: Codable {} -extension PsbtCompletionError: Foundation.LocalizedError { +extension PubkyError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -25250,52 +26546,119 @@ extension PsbtCompletionError: Foundation.LocalizedError { -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + /** - * The type of a `pubkyauth://` deep-link flow. + * Errors surfaced by the Pubky Swaps route module. */ +public enum PubkySwapError: Swift.Error { -public enum PubkyAuthKind { - case signin - case signup + + case InvalidInput(errorDetails: String + ) + case Transport(errorDetails: String + ) + /** + * The provider refused the request with one of its closed refusal codes. + */ + case Refused(code: String, reason: String + ) + /** + * The provider's quote, contract or invoice did not match what was asked for. + */ + case Validation(errorDetails: String + ) + case Chain(errorDetails: String + ) + case Storage(errorDetails: String + ) + case NotFound(errorDetails: String + ) } -#if compiler(>=6) -extension PubkyAuthKind: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePubkyAuthKind: FfiConverterRustBuffer { - typealias SwiftType = PubkyAuthKind +public struct FfiConverterTypePubkySwapError: FfiConverterRustBuffer { + typealias SwiftType = PubkySwapError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyAuthKind { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkySwapError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .signin - - case 2: return .signup + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .InvalidInput( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .Transport( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 3: return .Refused( + code: try FfiConverterString.read(from: &buf), + reason: try FfiConverterString.read(from: &buf) + ) + case 4: return .Validation( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 5: return .Chain( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 6: return .Storage( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 7: return .NotFound( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: PubkyAuthKind, into buf: inout [UInt8]) { + public static func write(_ value: PubkySwapError, into buf: inout [UInt8]) { switch value { + + - case .signin: - writeInt(&buf, Int32(1)) + case let .InvalidInput(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + - case .signup: + case let .Transport(errorDetails): writeInt(&buf, Int32(2)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .Refused(code,reason): + writeInt(&buf, Int32(3)) + FfiConverterString.write(code, into: &buf) + FfiConverterString.write(reason, into: &buf) + + + case let .Validation(errorDetails): + writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .Chain(errorDetails): + writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .Storage(errorDetails): + writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + case let .NotFound(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -25304,139 +26667,109 @@ public struct FfiConverterTypePubkyAuthKind: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyAuthKind_lift(_ buf: RustBuffer) throws -> PubkyAuthKind { - return try FfiConverterTypePubkyAuthKind.lift(buf) +public func FfiConverterTypePubkySwapError_lift(_ buf: RustBuffer) throws -> PubkySwapError { + return try FfiConverterTypePubkySwapError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyAuthKind_lower(_ value: PubkyAuthKind) -> RustBuffer { - return FfiConverterTypePubkyAuthKind.lower(value) +public func FfiConverterTypePubkySwapError_lower(_ value: PubkySwapError) -> RustBuffer { + return FfiConverterTypePubkySwapError.lower(value) } -extension PubkyAuthKind: Equatable, Hashable {} +extension PubkySwapError: Equatable, Hashable {} + +extension PubkySwapError: Codable {} -extension PubkyAuthKind: Codable {} +extension PubkySwapError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} -public enum PubkyError: 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 PubkySwapRouteState { - - case InvalidCapabilities(reason: String - ) - case AuthFailed(reason: String - ) - case NoActiveFlow - case ResolutionFailed(reason: String - ) - case FetchFailed(reason: String - ) - case ProfileNotFound - case ProfileParseFailed(reason: String + /** + * Waiting for the hold invoice to be paid. + */ + case awaitingPayment + /** + * Paid; waiting for the provider's on-chain lockup, or for its confirmations. + */ + case awaitingLockup(confirmations: UInt32, required: UInt32 ) - case KeyError(reason: String + /** + * The claim to the contact's address is broadcast. The provider settles the invoice + * once it sees the preimage. + */ + case claimed(txid: String ) - case WriteFailed(reason: String + case failed(reason: String ) } +#if compiler(>=6) +extension PubkySwapRouteState: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePubkyError: FfiConverterRustBuffer { - typealias SwiftType = PubkyError +public struct FfiConverterTypePubkySwapRouteState: FfiConverterRustBuffer { + typealias SwiftType = PubkySwapRouteState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkySwapRouteState { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .awaitingPayment - case 1: return .InvalidCapabilities( - reason: try FfiConverterString.read(from: &buf) - ) - case 2: return .AuthFailed( - reason: try FfiConverterString.read(from: &buf) - ) - case 3: return .NoActiveFlow - case 4: return .ResolutionFailed( - reason: try FfiConverterString.read(from: &buf) - ) - case 5: return .FetchFailed( - reason: try FfiConverterString.read(from: &buf) - ) - case 6: return .ProfileNotFound - case 7: return .ProfileParseFailed( - reason: try FfiConverterString.read(from: &buf) - ) - case 8: return .KeyError( - reason: try FfiConverterString.read(from: &buf) - ) - case 9: return .WriteFailed( - reason: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .awaitingLockup(confirmations: try FfiConverterUInt32.read(from: &buf), required: try FfiConverterUInt32.read(from: &buf) + ) + + case 3: return .claimed(txid: try FfiConverterString.read(from: &buf) + ) + + case 4: return .failed(reason: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: PubkyError, into buf: inout [UInt8]) { + public static func write(_ value: PubkySwapRouteState, into buf: inout [UInt8]) { switch value { - - - - case let .InvalidCapabilities(reason): + case .awaitingPayment: writeInt(&buf, Int32(1)) - FfiConverterString.write(reason, into: &buf) - - case let .AuthFailed(reason): + + case let .awaitingLockup(confirmations,required): writeInt(&buf, Int32(2)) - FfiConverterString.write(reason, into: &buf) + FfiConverterUInt32.write(confirmations, into: &buf) + FfiConverterUInt32.write(required, into: &buf) - case .NoActiveFlow: + case let .claimed(txid): writeInt(&buf, Int32(3)) - - - case let .ResolutionFailed(reason): - writeInt(&buf, Int32(4)) - FfiConverterString.write(reason, into: &buf) - - - case let .FetchFailed(reason): - writeInt(&buf, Int32(5)) - FfiConverterString.write(reason, into: &buf) - - - case .ProfileNotFound: - writeInt(&buf, Int32(6)) - - - case let .ProfileParseFailed(reason): - writeInt(&buf, Int32(7)) - FfiConverterString.write(reason, into: &buf) - - - case let .KeyError(reason): - writeInt(&buf, Int32(8)) - FfiConverterString.write(reason, into: &buf) + FfiConverterString.write(txid, into: &buf) - case let .WriteFailed(reason): - writeInt(&buf, Int32(9)) + case let .failed(reason): + writeInt(&buf, Int32(4)) FfiConverterString.write(reason, into: &buf) } @@ -25447,30 +26780,23 @@ public struct FfiConverterTypePubkyError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyError_lift(_ buf: RustBuffer) throws -> PubkyError { - return try FfiConverterTypePubkyError.lift(buf) +public func FfiConverterTypePubkySwapRouteState_lift(_ buf: RustBuffer) throws -> PubkySwapRouteState { + return try FfiConverterTypePubkySwapRouteState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyError_lower(_ value: PubkyError) -> RustBuffer { - return FfiConverterTypePubkyError.lower(value) +public func FfiConverterTypePubkySwapRouteState_lower(_ value: PubkySwapRouteState) -> RustBuffer { + return FfiConverterTypePubkySwapRouteState.lower(value) } -extension PubkyError: Equatable, Hashable {} - -extension PubkyError: Codable {} - +extension PubkySwapRouteState: Equatable, Hashable {} +extension PubkySwapRouteState: Codable {} -extension PubkyError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} @@ -28612,6 +29938,30 @@ fileprivate struct FfiConverterOptionTypePreActivityMetadata: FfiConverterRustBu } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeServiceRouteLeg: FfiConverterRustBuffer { + typealias SwiftType = ServiceRouteLeg? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeServiceRouteLeg.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 FfiConverterTypeServiceRouteLeg.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -29932,6 +31282,31 @@ fileprivate struct FfiConverterSequenceTypePassportAccount: FfiConverterRustBuff } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypePaykitEndpoint: FfiConverterRustBuffer { + typealias SwiftType = [PaykitEndpoint] + + public static func write(_ value: [PaykitEndpoint], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypePaykitEndpoint.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PaykitEndpoint] { + let len: Int32 = try readInt(&buf) + var seq = [PaykitEndpoint]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypePaykitEndpoint.read(from: &buf)) + } + return seq + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -29982,6 +31357,31 @@ fileprivate struct FfiConverterSequenceTypePubkyProfileLink: FfiConverterRustBuf } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeServiceRouteLeg: FfiConverterRustBuffer { + typealias SwiftType = [ServiceRouteLeg] + + public static func write(_ value: [ServiceRouteLeg], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeServiceRouteLeg.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ServiceRouteLeg] { + let len: Int32 = try readInt(&buf) + var seq = [ServiceRouteLeg]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeServiceRouteLeg.read(from: &buf)) + } + return seq + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -30007,6 +31407,31 @@ fileprivate struct FfiConverterSequenceTypeSupportedHardwareWallet: FfiConverter } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeSwapRouteEdge: FfiConverterRustBuffer { + typealias SwiftType = [SwapRouteEdge] + + public static func write(_ value: [SwapRouteEdge], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeSwapRouteEdge.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [SwapRouteEdge] { + let len: Int32 = try readInt(&buf) + var seq = [SwapRouteEdge]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeSwapRouteEdge.read(from: &buf)) + } + return seq + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -30860,6 +32285,24 @@ public func arkadeOffboard(address: String, amountSat: UInt64?)async throws -> errorHandler: FfiConverterTypeArkadeError_lift ) } +/** + * Run an Arkade leg the Paykit router picked: offboard exactly `amount_sat` to `address` in the next batch, the exit + * fee on top; the commitment txid. + */ +public func arkadeOffboardExact(address: String, amountSat: UInt64)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_arkade_offboard_exact(FfiConverterString.lower(address),FfiConverterUInt64.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: FfiConverterTypeArkadeError_lift + ) +} /** * The operator's fee programs, which `arkade_offboard` pays. */ @@ -30895,6 +32338,25 @@ public func arkadePay(bolt11: String, maxFeeSat: UInt64?)async throws -> Arkade errorHandler: FfiConverterTypeArkadeError_lift ) } +/** + * A Paykit route leg that offboards exactly `amount_sat` to the contact's on-chain `endpoint`, the exit fee on top, + * or `None` while the Arkade balance cannot cover both. Pass it to `pubky_swaps_route_paykit_payment` in + * `service_legs`. + */ +public func arkadePaykitRouteLeg(endpoint: PaykitEndpoint, amountSat: UInt64)async throws -> ServiceRouteLeg? { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_arkade_paykit_route_leg(FfiConverterTypePaykitEndpoint_lower(endpoint),FfiConverterUInt64.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: FfiConverterOptionTypeServiceRouteLeg.lift, + errorHandler: FfiConverterTypeArkadeError_lift + ) +} /** * What paying `bolt11` through Arkade Intents would cost. */ @@ -32829,6 +34291,80 @@ public func pubkySignUp(secretKeyHex: String, homeserverPublicKeyZ32: String, si errorHandler: FfiConverterTypePubkyError_lift ) } +/** + * Advance a committed route: once the provider's lockup has its confirmations, claim it to the + * contact's address. Call after paying the hold invoice, until it reports `Claimed`. + */ +public func pubkySwapsAdvance(swapId: String, mnemonic: String, bip39Passphrase: String?)async throws -> PubkySwapRouteStatus { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_pubky_swaps_advance(FfiConverterString.lower(swapId),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypePubkySwapRouteStatus_lift, + errorHandler: FfiConverterTypePubkySwapError_lift + ) +} +/** + * Commit to a routed quote and get the hold invoice to pay. The provider's contract and invoice + * are checked against the quote and the wallet's own keys before they are returned. + */ +public func pubkySwapsCommitRoute(quoteId: String, electrumUrl: String, mnemonic: String, bip39Passphrase: String?)async throws -> PubkySwapRoutePayment { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_pubky_swaps_commit_route(FfiConverterString.lower(quoteId),FfiConverterString.lower(electrumUrl),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypePubkySwapRoutePayment_lift, + errorHandler: FfiConverterTypePubkySwapError_lift + ) +} +/** + * The `swap/1` edges a Pubky Swaps provider advertises right now, read from its live offer + * over iroh. The wallet's swap identity is derived from `mnemonic`. + */ +public func pubkySwapsProviderEdges(providerPubky: String, mnemonic: String, bip39Passphrase: String?)async throws -> [SwapRouteEdge] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_pubky_swaps_provider_edges(FfiConverterString.lower(providerPubky),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypeSwapRouteEdge.lift, + errorHandler: FfiConverterTypePubkySwapError_lift + ) +} +/** + * Pick how to pay a Paykit contact. Returns `Direct` when a balance the wallet holds reaches + * one of the contact's endpoints, otherwise the cheaper of the request's service legs and the + * trusted Pubky Swaps providers' firm quotes, or `None` with a reason. The user never picks + * the route. + */ +public func pubkySwapsRoutePaykitPayment(request: PaykitRouteRequest, network: Network, mnemonic: String, bip39Passphrase: String?)async throws -> PaykitRoute { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_pubky_swaps_route_paykit_payment(FfiConverterTypePaykitRouteRequest_lower(request),FfiConverterTypeNetwork_lower(network),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypePaykitRoute_lift, + errorHandler: FfiConverterTypePubkySwapError_lift + ) +} /** * Persist a successful outgoing RBF result, including its replacement fee rate, in one transaction. * Call after the node has returned the replacement txid; this function does not broadcast anything. @@ -33750,12 +35286,18 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_arkade_offboard() != 3856) { return InitializationResult.apiChecksumMismatch } + if (uniffi_bitkitcore_checksum_func_arkade_offboard_exact() != 26429) { + return InitializationResult.apiChecksumMismatch + } if (uniffi_bitkitcore_checksum_func_arkade_offboard_fee() != 41350) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitkitcore_checksum_func_arkade_pay() != 8253) { return InitializationResult.apiChecksumMismatch } + if (uniffi_bitkitcore_checksum_func_arkade_paykit_route_leg() != 9352) { + return InitializationResult.apiChecksumMismatch + } if (uniffi_bitkitcore_checksum_func_arkade_quote_pay() != 10416) { return InitializationResult.apiChecksumMismatch } @@ -34191,6 +35733,18 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_pubky_sign_up() != 61692) { return InitializationResult.apiChecksumMismatch } + if (uniffi_bitkitcore_checksum_func_pubky_swaps_advance() != 27871) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_pubky_swaps_commit_route() != 4882) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_pubky_swaps_provider_edges() != 4359) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_pubky_swaps_route_paykit_payment() != 36140) { + return InitializationResult.apiChecksumMismatch + } if (uniffi_bitkitcore_checksum_func_record_rbf_boost() != 15433) { return InitializationResult.apiChecksumMismatch } diff --git a/bindings/ios/bitkitcoreFFI.h b/bindings/ios/bitkitcoreFFI.h index 8a4b82c..f48c9e5 100644 --- a/bindings/ios/bitkitcoreFFI.h +++ b/bindings/ios/bitkitcoreFFI.h @@ -968,6 +968,11 @@ uint64_t uniffi_bitkitcore_fn_func_arkade_lightning_address(void uint64_t uniffi_bitkitcore_fn_func_arkade_offboard(RustBuffer address, RustBuffer amount_sat ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_OFFBOARD_EXACT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_OFFBOARD_EXACT +uint64_t uniffi_bitkitcore_fn_func_arkade_offboard_exact(RustBuffer address, uint64_t amount_sat +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_OFFBOARD_FEE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_OFFBOARD_FEE uint64_t uniffi_bitkitcore_fn_func_arkade_offboard_fee(void @@ -979,6 +984,11 @@ uint64_t uniffi_bitkitcore_fn_func_arkade_offboard_fee(void uint64_t uniffi_bitkitcore_fn_func_arkade_pay(RustBuffer bolt11, RustBuffer max_fee_sat ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_PAYKIT_ROUTE_LEG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_PAYKIT_ROUTE_LEG +uint64_t uniffi_bitkitcore_fn_func_arkade_paykit_route_leg(RustBuffer endpoint, uint64_t amount_sat +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_QUOTE_PAY #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_ARKADE_QUOTE_PAY uint64_t uniffi_bitkitcore_fn_func_arkade_quote_pay(RustBuffer bolt11 @@ -1735,6 +1745,26 @@ uint64_t uniffi_bitkitcore_fn_func_pubky_sign_in(RustBuffer secret_key_hex uint64_t uniffi_bitkitcore_fn_func_pubky_sign_up(RustBuffer secret_key_hex, RustBuffer homeserver_public_key_z32, RustBuffer signup_code ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_ADVANCE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_ADVANCE +uint64_t uniffi_bitkitcore_fn_func_pubky_swaps_advance(RustBuffer swap_id, RustBuffer mnemonic, RustBuffer bip39_passphrase +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_COMMIT_ROUTE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_COMMIT_ROUTE +uint64_t uniffi_bitkitcore_fn_func_pubky_swaps_commit_route(RustBuffer quote_id, RustBuffer electrum_url, RustBuffer mnemonic, RustBuffer bip39_passphrase +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_PROVIDER_EDGES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_PROVIDER_EDGES +uint64_t uniffi_bitkitcore_fn_func_pubky_swaps_provider_edges(RustBuffer provider_pubky, RustBuffer mnemonic, RustBuffer bip39_passphrase +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_ROUTE_PAYKIT_PAYMENT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_ROUTE_PAYKIT_PAYMENT +uint64_t uniffi_bitkitcore_fn_func_pubky_swaps_route_paykit_payment(RustBuffer request, RustBuffer network, RustBuffer mnemonic, RustBuffer bip39_passphrase +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_RECORD_RBF_BOOST #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_RECORD_RBF_BOOST void uniffi_bitkitcore_fn_func_record_rbf_boost(RustBuffer wallet_id, RustBuffer original_activity_id, RustBuffer replacement_tx_id, uint64_t fee_rate, RustCallStatus *_Nonnull out_status @@ -2470,6 +2500,12 @@ uint16_t uniffi_bitkitcore_checksum_func_arkade_lightning_address(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_OFFBOARD uint16_t uniffi_bitkitcore_checksum_func_arkade_offboard(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_OFFBOARD_EXACT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_OFFBOARD_EXACT +uint16_t uniffi_bitkitcore_checksum_func_arkade_offboard_exact(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_OFFBOARD_FEE @@ -2482,6 +2518,12 @@ uint16_t uniffi_bitkitcore_checksum_func_arkade_offboard_fee(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_PAY uint16_t uniffi_bitkitcore_checksum_func_arkade_pay(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_PAYKIT_ROUTE_LEG +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_PAYKIT_ROUTE_LEG +uint16_t uniffi_bitkitcore_checksum_func_arkade_paykit_route_leg(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ARKADE_QUOTE_PAY @@ -3352,6 +3394,30 @@ uint16_t uniffi_bitkitcore_checksum_func_pubky_sign_in(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SIGN_UP uint16_t uniffi_bitkitcore_checksum_func_pubky_sign_up(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_ADVANCE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_ADVANCE +uint16_t uniffi_bitkitcore_checksum_func_pubky_swaps_advance(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_COMMIT_ROUTE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_COMMIT_ROUTE +uint16_t uniffi_bitkitcore_checksum_func_pubky_swaps_commit_route(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_PROVIDER_EDGES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_PROVIDER_EDGES +uint16_t uniffi_bitkitcore_checksum_func_pubky_swaps_provider_edges(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_ROUTE_PAYKIT_PAYMENT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_ROUTE_PAYKIT_PAYMENT +uint16_t uniffi_bitkitcore_checksum_func_pubky_swaps_route_paykit_payment(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_RECORD_RBF_BOOST diff --git a/src/lib.rs b/src/lib.rs index 647eecf..e5e3970 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,6 +54,10 @@ pub use crate::modules::jade::{ JadeTransportReadResult, JadeTransportResult, JadeVersionInfo, JadeXpubResponse, }; use crate::modules::pubky::{PubkyAuthDetails, PubkyAuthKind, PubkyError, PubkyProfile}; +use crate::modules::pubky_swaps::{ + self as pubky_swaps, PaykitEndpoint, PaykitRoute, PaykitRouteRequest, PubkySwapError, + PubkySwapRoutePayment, PubkySwapRouteStatus, ServiceRouteLeg, SwapRouteEdge, +}; use crate::modules::trezor::account_type_to_script_type; pub use crate::modules::trezor::{ get_transport_callback, trezor_is_ble_available, trezor_set_transport_callback, @@ -514,6 +518,9 @@ pub fn init_db(base_path: String) -> Result { let blocktank_db = rt .block_on(async { BlocktankDB::new(&format!("{}/blocktank.db", base_path), None).await })?; let boltz_db = rt.block_on(async { BoltzDB::new(&format!("{}/boltz.db", base_path)).await })?; + modules::pubky_swaps::init(&base_path).map_err(|e| DbError::InitializationError { + error_details: e.to_string(), + })?; // Initialize sync database { @@ -3420,6 +3427,81 @@ pub async fn boltz_stop_swap_updates() { .await; } +// =====================================================================// Pubky Swaps as Paykit routes +// ============================================================================ + +fn pubky_swaps_runtime_err(e: tokio::task::JoinError) -> PubkySwapError { + PubkySwapError::Transport { + error_details: format!("Runtime error: {}", e), + } +} + +/// The `swap/1` edges a Pubky Swaps provider advertises right now, read from its live offer +/// over iroh. The wallet's swap identity is derived from `mnemonic`. +#[uniffi::export] +pub async fn pubky_swaps_provider_edges( + provider_pubky: String, + mnemonic: String, + bip39_passphrase: Option, +) -> Result, PubkySwapError> { + let rt = ensure_runtime(); + rt.spawn(async move { + pubky_swaps::provider_edges(provider_pubky, mnemonic, bip39_passphrase).await + }) + .await + .unwrap_or_else(|e| Err(pubky_swaps_runtime_err(e))) +} + +/// Pick how to pay a Paykit contact. Returns `Direct` when a balance the wallet holds reaches +/// one of the contact's endpoints, otherwise the cheaper of the request's service legs and the +/// trusted Pubky Swaps providers' firm quotes, or `None` with a reason. The user never picks +/// the route. +#[uniffi::export] +pub async fn pubky_swaps_route_paykit_payment( + request: PaykitRouteRequest, + network: Network, + mnemonic: String, + bip39_passphrase: Option, +) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + pubky_swaps::route_paykit_payment(request, network.into(), mnemonic, bip39_passphrase).await + }) + .await + .unwrap_or_else(|e| Err(pubky_swaps_runtime_err(e))) +} + +/// Commit to a routed quote and get the hold invoice to pay. The provider's contract and invoice +/// are checked against the quote and the wallet's own keys before they are returned. +#[uniffi::export] +pub async fn pubky_swaps_commit_route( + quote_id: String, + electrum_url: String, + mnemonic: String, + bip39_passphrase: Option, +) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + pubky_swaps::commit_route(quote_id, electrum_url, mnemonic, bip39_passphrase).await + }) + .await + .unwrap_or_else(|e| Err(pubky_swaps_runtime_err(e))) +} + +/// Advance a committed route: once the provider's lockup has its confirmations, claim it to the +/// contact's address. Call after paying the hold invoice, until it reports `Claimed`. +#[uniffi::export] +pub async fn pubky_swaps_advance( + swap_id: String, + mnemonic: String, + bip39_passphrase: Option, +) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { pubky_swaps::advance_swap(swap_id, mnemonic, bip39_passphrase).await }) + .await + .unwrap_or_else(|e| Err(pubky_swaps_runtime_err(e))) +} + // ── Arkade ─────────────────────────────────────────────────────────────────── fn arkade_runtime_err(e: tokio::task::JoinError) -> ArkadeError { @@ -3513,6 +3595,27 @@ pub async fn arkade_offboard( on_arkade_runtime(arkade::offboard(address, amount_sat)).await } +/// A Paykit route leg that offboards exactly `amount_sat` to the contact's on-chain `endpoint`, the exit fee on top, +/// or `None` while the Arkade balance cannot cover both. Pass it to `pubky_swaps_route_paykit_payment` in +/// `service_legs`. +#[uniffi::export] +pub async fn arkade_paykit_route_leg( + endpoint: PaykitEndpoint, + amount_sat: u64, +) -> Result, ArkadeError> { + on_arkade_runtime(arkade::paykit_route_leg(endpoint, amount_sat)).await +} + +/// Run an Arkade leg the Paykit router picked: offboard exactly `amount_sat` to `address` in the next batch, the exit +/// fee on top; the commitment txid. +#[uniffi::export] +pub async fn arkade_offboard_exact( + address: String, + amount_sat: u64, +) -> Result { + on_arkade_runtime(arkade::offboard_exact(address, amount_sat)).await +} + /// Pay `amount_sat` to another Arkade address; the Arkade txid. #[uniffi::export] pub async fn arkade_send_ark(address: String, amount_sat: u64) -> Result { diff --git a/src/modules/arkade/mod.rs b/src/modules/arkade/mod.rs index 516f6af..351a241 100644 --- a/src/modules/arkade/mod.rs +++ b/src/modules/arkade/mod.rs @@ -25,6 +25,9 @@ pub use listener::{set_listener, ArkadeEventListener}; pub use lnurl::ArkadeLightningAddress; pub use types::*; +/// The `service` of an Arkade leg in a Paykit route. +pub const ROUTE_SERVICE: &str = "arkade"; + use std::path::Path; use std::sync::Arc; use std::time::Duration; @@ -185,6 +188,37 @@ pub async fn offboard(address: String, amount_sat: Option) -> Result Result, ArkadeError> { + let wallet = wallet().await?; + let fee = wallet + .offboard_exact_fee(&endpoint.value, amount_sat) + .await?; + let debit_sat = amount_sat + fee; + if wallet.balance().await?.available < debit_sat { + return Ok(None); + } + Ok(Some(crate::modules::pubky_swaps::ServiceRouteLeg { + service: ROUTE_SERVICE.into(), + endpoint, + delivered_sat: amount_sat, + debit_sat, + // The operator co-signs the batch that pays the contact. + atomicity: "operator".into(), + valid_until_unix: 0, + })) +} + +/// Run an Arkade leg the Paykit router picked: offboard exactly `amount_sat` to `address`; the commitment txid. +pub async fn offboard_exact(address: String, amount_sat: u64) -> Result { + wallet().await?.offboard_exact(&address, amount_sat).await +} + pub async fn send_ark(address: String, amount_sat: u64) -> Result { wallet().await?.send_ark(&address, amount_sat).await } diff --git a/src/modules/arkade/wallet.rs b/src/modules/arkade/wallet.rs index 1779c3d..89a1a0e 100644 --- a/src/modules/arkade/wallet.rs +++ b/src/modules/arkade/wallet.rs @@ -434,6 +434,37 @@ impl Wallet { Ok(txid.to_string()) } + /// The operator's exit fee for an offboard that delivers exactly `amount` to `address`. + pub async fn offboard_exact_fee(&self, address: &str, amount: u64) -> Result { + let info = self.client.server_info().await?; + let address = Address::from_str(address) + .and_then(|a| a.require_network(info.network)) + .map_err(|e| ArkadeError::invalid(format!("invalid address: {e}")))?; + let output = ark_fees::Output { + amount, + script: address.script_pubkey().to_string(), + }; + Ok(fee_estimator(&info)? + .eval_onchain_output(output) + .map_err(ArkadeError::ark)? + .to_satoshis()) + } + + /// Move exactly `amount` to the on-chain `address` in the next batch, the exit fee on top; the commitment txid. + pub async fn offboard_exact(&self, address: &str, amount: u64) -> Result { + let info = self.client.server_info().await?; + let address = Address::from_str(address) + .and_then(|a| a.require_network(info.network)) + .map_err(|e| ArkadeError::invalid(format!("invalid address: {e}")))?; + let mut rng = rng(); + let _batch = self.batch.lock().await; + let txid = self + .client + .collaborative_redeem(&mut rng, address, Amount::from_sat(amount)) + .await?; + Ok(txid.to_string()) + } + pub async fn send_ark(&self, address: &str, amount: u64) -> Result { let address = ArkAddress::decode(address) .map_err(|e| ArkadeError::invalid(format!("invalid Arkade address: {e}")))?; diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 3688c9e..a486b94 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -7,6 +7,7 @@ pub mod jade; pub mod lnurl; pub mod onchain; pub mod pubky; +pub mod pubky_swaps; pub mod scanner; pub mod seedqr; pub mod trezor; diff --git a/src/modules/pubky_swaps/README.md b/src/modules/pubky_swaps/README.md new file mode 100644 index 0000000..54d8d15 --- /dev/null +++ b/src/modules/pubky_swaps/README.md @@ -0,0 +1,73 @@ +# Pubky Swaps Module + +Routes a Paykit payment through a [Pubky Swaps](https://github.com/coreyphillips/pubky-swap) +provider when no balance the wallet holds reaches an endpoint the contact published. The user +never picks the swap: the router does, and the review screen shows the route. + +The first route is a reverse swap: the wallet pays over Lightning, the provider locks bitcoin on +chain, and this module claims it straight to the contact's on-chain address. The contact receives +exactly the amount asked for (`exact_out`): the lock covers the wallet's own claim fee. + +## Flow + +| Step | Paykit Capabilities | pubky-swap message | Owner | +|------|---------------------|--------------------|-------| +| Pick a route | router (§9.1) | `OfferRequest` → `Offer` | `pubky_swaps_route_paykit_payment` | +| Ask for a price | `rfq` → `quote` | `QuoteRequest` → `Quote` | same call, up to 3 providers | +| Commit | `commit` → `contract` | `SwapRequest` → `SwapAccept` | `pubky_swaps_commit_route` | +| Fund | funding is the acceptance | hold invoice | **App** pays the invoice from spending | +| Claim | evidence from the rail | claim with the preimage | `pubky_swaps_advance` | + +`pubky_swaps_route_paykit_payment` returns `Direct` when a balance reaches one of the contact's +endpoints, so the app only swaps when it must. + +## Service routes + +Services the wallet holds a balance on can also deliver to the contact: an Arkade offboard or a +Spark withdrawal pays an on-chain address from Spending without a Pubky Swaps provider. The app +quotes each such leg with its own engine for the service (`arkade_offboard_fee`, Spark's fee +quote) and passes it in `PaykitRouteRequest.service_legs`; the router never talks to Arkade or +Spark. + +When no balance reaches the contact directly, the router keeps the cheapest service leg that +delivers exactly the amount to an endpoint the contact published and has not expired, asks the +providers for a swap quote, and returns whichever costs less in fees: `Service` with the leg, which +the app runs, or `Swap`. A swap wins a tie, since a hash lock needs no one's trust; a service leg +states who it trusts in `atomicity` (`operator` for Arkade, `trusted` for Spark). + +Lightning through Arkade or Spark needs no service leg: the app counts those balances as +Lightning-spendable, and `Direct` covers it. One route has one leg: a service paying a provider's +hold invoice is not routed yet. + +Before the invoice reaches the app, the module checks the quote against the request +(`validate_quote`), the contract against the quote and the chain tip (`validate_accept`), rebuilds +the HTLC from its own keys (`verify_contract`), and binds the hold invoice to the quote and the +payment hash (`validate_hold_invoice`). These checks are pubky-swap's own `swap-common`. + +## Transport + +Requests travel over iroh `pubky-swap/direct/1`. The provider authenticates the request by the +connection's key, so neither side needs a homeserver. Paykit Capabilities §13.1 allows the same +payloads over this carrier. + +## Keys and storage + +- The wallet's identity towards providers, its claim keys and its preimages derive from the seed + with HMAC-SHA512 under their own domain strings. They never collide with the Boltz module's keys, + and the identity is not the user's Pubky identity. +- `/pubky_swaps/.json` holds the contract and the key index, never a secret. The + index is reserved on disk before the commit is sent. + +## What it does not do yet + +- **Discovery:** candidates come from the caller, usually the user's contacts. Each is asked for + its live offer over iroh; nothing reads published Capability Descriptors yet (§6, §7). +- **Paykit transport:** no `paykit-cap.*` messages over Encrypted Links. paykit-rs has no API to + send extension kinds yet (§17). +- **Signed terms:** pubky-swap signs nothing at `main`, so quotes and contracts are not + attributable to the provider yet. +- **Submarine routes** (savings to a Lightning-only contact) and USDT. Pubky Swaps is Bitcoin and + Lightning only. +- **Refunds and recovery:** a reverse swap needs no wallet refund (the provider cancels its hold + invoice), but there is no scan to rebuild swaps from the seed alone, and swap records are not in + the wallet backup. diff --git a/src/modules/pubky_swaps/client.rs b/src/modules/pubky_swaps/client.rs new file mode 100644 index 0000000..1689906 --- /dev/null +++ b/src/modules/pubky_swaps/client.rs @@ -0,0 +1,686 @@ +//! The `swap/1` flow for a Paykit payment: route, commit, claim. +//! +//! Message mapping (Paykit Capabilities §13.1): `rfq` is pubky-swap's `QuoteRequest`, `quote` +//! is `Quote`, `commit` is `SwapRequest`, `contract` is `SwapAccept`, `refusal` is `Reject`. +//! Here they travel over iroh `direct/1`, which §13.1 allows for the same payloads. + +use std::collections::HashMap; +use std::str::FromStr; +use std::sync::Mutex; +use std::time::{SystemTime, UNIX_EPOCH}; + +use bitcoin::{Address, OutPoint, ScriptBuf}; +use electrum_client::{Client as ElectrumClient, ElectrumApi}; +use once_cell::sync::Lazy; +use swap_common::htlc::build_htlc_script; +use swap_common::messages::{ + OfferRequest, Quote, QuoteRequest, Reject, SwapMessage, SwapOffer, SwapRequest, SwapScript, + SwapStatusRequest, PROTOCOL_VERSION, +}; +use swap_common::onchain::{build_claim_tx, estimate_spend_fee, spend_vsize}; +use swap_common::timelock::TimelockParams; +use swap_common::validate::{ + validate_accept, validate_hold_invoice, validate_quote, verify_contract, ClientPolicy, + DecodedHoldInvoice, +}; +use swap_common::SwapDirection; +use uuid::Uuid; + +use super::errors::PubkySwapError; +use super::keys; +use super::router::{self, is_lightning}; +use super::store::{self, SwapRecord}; +use super::transport::{bare_pubky, DirectClient}; +use super::types::*; + +/// How long a candidate provider has to answer an offer request. +const OFFER_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(20); + +/// Quotes the router fetched, kept until the wallet commits to one of them. +static QUOTES: Lazy>> = Lazy::new(Default::default); + +#[derive(Clone)] +struct CachedQuote { + route: PubkySwapRouteQuote, + quote: Quote, + network: bitcoin::Network, +} + +fn now_unix() -> u64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .map(|d| d.as_secs()) + .unwrap_or(0) +} + +fn policy(network: bitcoin::Network) -> ClientPolicy { + ClientPolicy::for_network(network, TimelockParams::default()) +} + +fn refused(reject: Reject) -> PubkySwapError { + PubkySwapError::Refused { + code: reject.code.unwrap_or_else(|| "unknown".into()), + reason: reject.reason, + } +} + +fn unexpected(what: &str, got: &SwapMessage) -> PubkySwapError { + PubkySwapError::transport(format!("expected {what}, got {got:?}")) +} + +fn identity_pubky(secret: &[u8; 32]) -> String { + pubky::Keypair::from_secret(secret).public_key().to_z32() +} + +fn parse_address(address: &str, network: bitcoin::Network) -> Result { + Address::from_str(address) + .map_err(|e| PubkySwapError::invalid(format!("address: {e}")))? + .require_network(network) + .map_err(|e| PubkySwapError::invalid(format!("address: {e}"))) +} + +/// The wallet's fee for claiming the provider's lockup to `destination`. +fn claim_fee(destination: &ScriptBuf, fee_rate_sat_vb: u64) -> Result { + // Only the shape matters for the size: a real contract has the same lengths. + let key = keys::swap_keys( + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + None, + 0, + )?; + let script = build_htlc_script(&[0; 32], &key.claim_pubkey, &key.claim_pubkey, 1_000_000); + Ok(estimate_spend_fee( + fee_rate_sat_vb.max(1), + spend_vsize(&script, destination, true), + )) +} + +async fn fetch_offer(client: &DirectClient, provider: &str) -> Result { + let request = SwapMessage::OfferRequest(OfferRequest { + request_id: Some(Uuid::new_v4()), + }); + match client.request(provider, &request).await? { + SwapMessage::Offer(offer) => Ok(offer), + SwapMessage::Reject(reject) => Err(refused(reject)), + other => Err(unexpected("Offer", &other)), + } +} + +/// The `swap/1` edges a provider advertises right now. +pub async fn provider_edges( + provider: String, + mnemonic: String, + bip39_passphrase: Option, +) -> Result, PubkySwapError> { + let secret = keys::identity_secret(&mnemonic, bip39_passphrase.as_deref())?; + let client = DirectClient::bind(secret).await?; + let offer = fetch_offer(&client, bare_pubky(&provider)).await; + client.close().await; + Ok(router::edges_from_offer(&offer?)) +} + +async fn quote_edge( + client: &DirectClient, + identity: &str, + offer: &SwapOffer, + lock_sat: u64, + network: bitcoin::Network, +) -> Result { + let request = QuoteRequest { + request_id: Some(Uuid::new_v4()), + offer_id: offer.offer_id, + client_pkarr: identity.to_string(), + direction: SwapDirection::Reverse, + amount_sat: lock_sat, + protocol_version: PROTOCOL_VERSION, + features: vec![], + }; + let reply = client + .request( + &offer.provider_pkarr, + &SwapMessage::QuoteRequest(request.clone()), + ) + .await?; + let quote = match reply { + SwapMessage::Quote(quote) => quote, + SwapMessage::Reject(reject) => return Err(refused(reject)), + other => return Err(unexpected("Quote", &other)), + }; + validate_quote("e, &request, now_unix(), &policy(network)) + .map_err(PubkySwapError::validation)?; + Ok(quote) +} + +/// Pick the route for a Paykit payment. The user never picks a swap: one is used only when no +/// rail the wallet holds reaches an endpoint the contact published. +pub async fn route_paykit_payment( + request: PaykitRouteRequest, + network: bitcoin::Network, + mnemonic: String, + bip39_passphrase: Option, +) -> Result { + let amount = request.amount_sat; + if amount == 0 { + return Err(PubkySwapError::invalid("amount must be positive")); + } + let endpoints = &request.contact_endpoints; + if let Some(lightning) = endpoints.iter().find(|e| is_lightning(&e.method_id)) { + if request.lightning_spendable_sat >= amount { + return Ok(PaykitRoute::Direct { + endpoint: lightning.clone(), + }); + } + } + let onchain = router::onchain_endpoint(endpoints, network); + if let Some(onchain) = &onchain { + if request.onchain_spendable_sat >= amount { + return Ok(PaykitRoute::Direct { + endpoint: onchain.clone(), + }); + } + } + let service = router::best_service_leg(&request.service_legs, endpoints, amount, now_unix()); + let swap = match &onchain { + Some(onchain) if !request.providers.is_empty() => { + match best_swap_route( + &request, + onchain.clone(), + network, + &mnemonic, + bip39_passphrase.as_deref(), + ) + .await + { + Ok(swap) => swap, + Err(e) if service.is_some() => { + log::warn!("pubky swaps: no swap route, paying through a service: {e}"); + None + } + Err(e) => return Err(e), + } + } + _ => None, + }; + Ok( + router::cheaper_route(service, swap).unwrap_or_else(|| PaykitRoute::None { + reason: if onchain.is_none() { + "No balance can reach an endpoint this contact accepts." + } else if request.providers.is_empty() { + "No swap provider is set up." + } else { + "No swap provider can route this payment right now." + } + .into(), + }), + ) +} + +/// The cheapest firm quote from the trusted Pubky Swaps providers for delivering the request's +/// amount to `onchain`, cached for `commit_route`. +async fn best_swap_route( + request: &PaykitRouteRequest, + onchain: PaykitEndpoint, + network: bitcoin::Network, + mnemonic: &str, + bip39_passphrase: Option<&str>, +) -> Result, PubkySwapError> { + let amount = request.amount_sat; + let destination = parse_address(&onchain.value, network)?.script_pubkey(); + let claim_fee_sat = claim_fee(&destination, request.fee_rate_sat_vb)?; + let lock_sat = amount + claim_fee_sat; + + let secret = keys::identity_secret(mnemonic, bip39_passphrase)?; + let identity = identity_pubky(&secret); + let client = DirectClient::bind(secret).await?; + + let mut offers = HashMap::new(); + let mut edges = vec![]; + // Candidates are usually the user's contacts, and most of them run no provider: ask them all at + // once and give each a short window to answer. + let mut probes = tokio::task::JoinSet::new(); + let mut candidates: Vec = request + .providers + .iter() + .map(|p| bare_pubky(p).to_string()) + .collect(); + candidates.sort(); + candidates.dedup(); + for provider in candidates { + let client = client.clone(); + probes.spawn(async move { + let offer = tokio::time::timeout(OFFER_TIMEOUT, fetch_offer(&client, &provider)).await; + (provider, offer) + }); + } + while let Some(probe) = probes.join_next().await { + let Ok((provider, offer)) = probe else { + continue; + }; + match offer { + Ok(Ok(offer)) if offer.network.to_bitcoin_network() == network => { + edges.extend(router::edges_from_offer(&offer)); + offers.insert(offer.provider_pkarr.clone(), offer); + } + Ok(Ok(_)) => log::warn!("pubky swaps: provider {provider} is on another network"), + Ok(Err(e)) => log::debug!("pubky swaps: no offer from {provider}: {e}"), + Err(_) => log::debug!("pubky swaps: {provider} did not answer in time"), + } + } + let ranked = router::rank_reverse_edges(edges, lock_sat, request.lightning_spendable_sat); + let asked = ranked.len() as u32; + + let mut best: Option<(Quote, String)> = None; + for edge in &ranked { + let Some(offer) = offers.get(&edge.provider_pubky) else { + continue; + }; + match quote_edge(&client, &identity, offer, lock_sat, network).await { + Ok(quote) if quote.total_sat <= request.lightning_spendable_sat => { + if best + .as_ref() + .is_none_or(|(b, _)| quote.total_sat < b.total_sat) + { + best = Some((quote, edge.provider_pubky.clone())); + } + } + Ok(_) => {} + Err(e) => log::warn!("pubky swaps: no quote from {}: {e}", edge.provider_pubky), + } + } + client.close().await; + + let Some((quote, provider)) = best else { + return Ok(None); + }; + let route = PubkySwapRouteQuote { + provider_pubky: provider, + quote_id: quote.quote_id.to_string(), + endpoint: onchain, + delivered_sat: amount, + lock_sat, + debit_sat: quote.total_sat, + service_fee_sat: quote.service_fee_sat, + provider_onchain_fee_sat: quote.onchain_fee_sat, + claim_fee_sat, + total_fee_sat: quote.total_sat.saturating_sub(amount), + atomicity: "hash".into(), + valid_until_unix: quote.valid_until_unix, + providers_quoted: asked, + }; + QUOTES.lock().unwrap().insert( + route.quote_id.clone(), + CachedQuote { + route: route.clone(), + quote, + network, + }, + ); + Ok(Some(route)) +} + +fn decode_hold_invoice(invoice: &str) -> Result { + let invoice = lightning_invoice::Bolt11Invoice::from_str(invoice) + .map_err(|e| PubkySwapError::validation(format!("hold invoice: {e}")))?; + let amount_msat = invoice.amount_milli_satoshis(); + let expires_at = invoice + .expires_at() + .map(|d| d.as_secs()) + .unwrap_or_default(); + Ok(DecodedHoldInvoice { + payment_hash: *invoice.payment_hash().as_ref(), + amount_msat: amount_msat.unwrap_or_default(), + amount_is_explicit: amount_msat.is_some(), + expires_at_unix: expires_at, + }) +} + +fn chain_tip(electrum_url: &str) -> Result { + let client = ElectrumClient::new(electrum_url)?; + Ok(client.block_headers_subscribe()?.height as u32) +} + +/// Commit to a routed quote. Returns the hold invoice the wallet pays over Lightning; nothing +/// is funded before that payment. +pub async fn commit_route( + quote_id: String, + electrum_url: String, + mnemonic: String, + bip39_passphrase: Option, +) -> Result { + let cached = QUOTES + .lock() + .unwrap() + .get("e_id) + .cloned() + .ok_or_else(|| PubkySwapError::NotFound { + error_details: format!("quote {quote_id}"), + })?; + let CachedQuote { + route, + quote, + network, + } = cached; + if quote.is_expired(now_unix()) { + return Err(PubkySwapError::Refused { + code: "quote_expired".into(), + reason: "The quote expired. Route the payment again.".into(), + }); + } + let passphrase = bip39_passphrase.as_deref(); + let secret = keys::identity_secret(&mnemonic, passphrase)?; + let index = store::reserve_index()?; + let swap_keys = keys::swap_keys(&mnemonic, passphrase, index)?; + let request = SwapRequest { + script_type: SwapScript::P2wsh, + quote_id: quote.quote_id, + client_pkarr: identity_pubky(&secret), + direction: SwapDirection::Reverse, + payment_hash_hex: hex::encode(swap_keys.payment_hash), + client_claim_pubkey_hex: Some(swap_keys.claim_pubkey.to_string()), + client_refund_pubkey_hex: None, + invoice: None, + }; + + let client = DirectClient::bind(secret).await?; + let reply = client + .request(&route.provider_pubky, &SwapMessage::SwapRequest(request)) + .await; + let reply = match reply { + // `pending` means the provider is still admitting it: ask again, never a decline. + Ok(SwapMessage::Reject(reject)) if reject.code.as_deref() == Some("pending") => { + let status = SwapMessage::SwapStatusRequest(SwapStatusRequest { + request_id: Some(Uuid::new_v4()), + swap_id: None, + quote_id: Some(quote.quote_id), + }); + client.request(&route.provider_pubky, &status).await + } + other => other, + }; + client.close().await; + let accept = match reply? { + SwapMessage::SwapAccept(accept) => accept, + SwapMessage::SwapStatusSnapshot(snapshot) => snapshot.accept, + SwapMessage::Reject(reject) => return Err(refused(reject)), + other => return Err(unexpected("SwapAccept", &other)), + }; + + let tip = { + let url = electrum_url.clone(); + tokio::task::spawn_blocking(move || chain_tip(&url)) + .await + .map_err(PubkySwapError::chain)?? + }; + let policy = policy(network); + validate_accept(&accept, "e, Some(tip), &policy).map_err(PubkySwapError::validation)?; + let htlc_spk = verify_contract( + &accept, + SwapDirection::Reverse, + &swap_keys.payment_hash, + &swap_keys.claim_pubkey, + network, + ) + .map_err(PubkySwapError::validation)?; + let invoice = accept + .invoice + .clone() + .ok_or_else(|| PubkySwapError::validation("the contract has no hold invoice"))?; + validate_hold_invoice( + &decode_hold_invoice(&invoice)?, + "e, + &swap_keys.payment_hash, + now_unix(), + &policy, + ) + .map_err(PubkySwapError::validation)?; + let htlc_address = Address::from_script(&htlc_spk, network) + .map_err(PubkySwapError::validation)? + .to_string(); + + let record = SwapRecord { + swap_id: accept.swap_id.to_string(), + key_index: index, + provider_pubky: route.provider_pubky.clone(), + network, + electrum_url, + quote, + accept: accept.clone(), + destination_address: route.endpoint.value.clone(), + delivered_sat: route.delivered_sat, + claim_fee_sat: route.claim_fee_sat, + claim_txid: None, + created_at_unix: now_unix(), + }; + store::save(&record)?; + QUOTES.lock().unwrap().remove("e_id); + + Ok(PubkySwapRoutePayment { + swap_id: record.swap_id, + invoice, + debit_sat: route.debit_sat, + delivered_sat: route.delivered_sat, + destination_address: route.endpoint.value, + htlc_address, + timeout_block_height: accept.timeout_block_height, + }) +} + +fn status_of(record: &SwapRecord, state: PubkySwapRouteState) -> PubkySwapRouteStatus { + PubkySwapRouteStatus { + swap_id: record.swap_id.clone(), + state, + provider_pubky: record.provider_pubky.clone(), + delivered_sat: record.delivered_sat, + destination_address: record.destination_address.clone(), + } +} + +/// Find the provider's lockup and, once it has its confirmations, claim it straight to the +/// contact's address. Call again until it reports `Claimed`. +fn advance_blocking( + mut record: SwapRecord, + mnemonic: &str, + passphrase: Option<&str>, +) -> Result { + if let Some(txid) = &record.claim_txid { + let state = PubkySwapRouteState::Claimed { txid: txid.clone() }; + return Ok(status_of(&record, state)); + } + let keys = keys::swap_keys(mnemonic, passphrase, record.key_index)?; + let provider = record + .accept + .provider_pubkey_hex + .parse() + .map_err(PubkySwapError::validation)?; + let redeem_script = build_htlc_script( + &keys.payment_hash, + &keys.claim_pubkey, + &provider, + record.accept.timeout_block_height, + ); + let htlc_spk = ScriptBuf::new_p2wsh(&redeem_script.wscript_hash()); + let required = + policy(record.network).effective_confirmations(record.quote.required_confirmations); + + let electrum = ElectrumClient::new(&record.electrum_url)?; + let tip = electrum.block_headers_subscribe()?.height as u32; + let mut lockup: Option<(OutPoint, u32)> = None; + for item in electrum.script_get_history(&htlc_spk)? { + let tx = electrum.transaction_get(&item.tx_hash)?; + let vout = tx.output.iter().position(|out| { + out.script_pubkey == htlc_spk && out.value.to_sat() == record.accept.onchain_amount_sat + }); + if let Some(vout) = vout { + let confirmations = if item.height > 0 { + tip.saturating_sub(item.height as u32) + 1 + } else { + 0 + }; + lockup = Some((OutPoint::new(item.tx_hash, vout as u32), confirmations)); + break; + } + } + let Some((outpoint, confirmations)) = lockup else { + let state = PubkySwapRouteState::AwaitingLockup { + confirmations: 0, + required, + }; + return Ok(status_of(&record, state)); + }; + if confirmations < required { + let state = PubkySwapRouteState::AwaitingLockup { + confirmations, + required, + }; + return Ok(status_of(&record, state)); + } + + let destination = parse_address(&record.destination_address, record.network)?; + let claim = build_claim_tx( + outpoint, + record.accept.onchain_amount_sat, + &redeem_script, + destination.script_pubkey(), + record.claim_fee_sat, + keys.preimage, + &keys.claim_key, + ) + .map_err(PubkySwapError::chain)?; + let txid = electrum.transaction_broadcast(&claim)?.to_string(); + record.claim_txid = Some(txid.clone()); + store::save(&record)?; + Ok(status_of(&record, PubkySwapRouteState::Claimed { txid })) +} + +pub async fn advance_swap( + swap_id: String, + mnemonic: String, + bip39_passphrase: Option, +) -> Result { + let record = store::load(&swap_id)?; + tokio::task::spawn_blocking(move || { + advance_blocking(record, &mnemonic, bip39_passphrase.as_deref()) + }) + .await + .map_err(PubkySwapError::chain)? +} + +#[cfg(test)] +mod tests { + use super::*; + + const MNEMONIC: &str = + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; + + fn onchain_contact() -> PaykitEndpoint { + PaykitEndpoint { + method_id: "btc-regtest-p2wpkh".into(), + value: "bcrt1qdp8zwu9xk08p3dvkz4qyavmfaadkr4lnvwfah2".into(), + } + } + + fn request(service_legs: Vec) -> PaykitRouteRequest { + PaykitRouteRequest { + amount_sat: 20_000, + contact_endpoints: vec![onchain_contact()], + lightning_spendable_sat: 0, + onchain_spendable_sat: 0, + providers: vec![], + fee_rate_sat_vb: 2, + service_legs, + } + } + + async fn route(request: PaykitRouteRequest) -> PaykitRoute { + route_paykit_payment(request, bitcoin::Network::Regtest, MNEMONIC.into(), None) + .await + .unwrap() + } + + #[tokio::test] + async fn routes_an_onchain_contact_through_a_service_without_providers() { + let leg = ServiceRouteLeg { + service: "arkade".into(), + endpoint: onchain_contact(), + delivered_sat: 20_000, + debit_sat: 20_300, + atomicity: "operator".into(), + valid_until_unix: 0, + }; + let PaykitRoute::Service { leg: picked } = route(request(vec![leg.clone()])).await else { + panic!("expected a service route"); + }; + assert_eq!(picked, leg); + } + + #[tokio::test] + async fn explains_why_nothing_routes_without_providers_or_services() { + let PaykitRoute::None { reason } = route(request(vec![])).await else { + panic!("expected no route"); + }; + assert_eq!(reason, "No swap provider is set up."); + } +} + +#[cfg(test)] +mod live_tests { + //! Against a running regtest provider: + //! `PUBKY_SWAPS_PROVIDER=[,…] PUBKY_SWAPS_ELECTRUM=tcp://127.0.0.1:60001 + //! PUBKY_SWAPS_DESTINATION= cargo test --lib pubky_swaps::client::live_tests -- --ignored` + use super::*; + + const MNEMONIC: &str = + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; + + #[tokio::test(flavor = "multi_thread")] + #[ignore = "needs a running regtest Pubky Swaps provider"] + async fn routes_an_onchain_contact_through_the_provider_and_commits() { + let provider = std::env::var("PUBKY_SWAPS_PROVIDER").unwrap(); + let electrum = std::env::var("PUBKY_SWAPS_ELECTRUM").unwrap(); + let destination = std::env::var("PUBKY_SWAPS_DESTINATION").unwrap(); + let dir = std::env::temp_dir().join(format!("pubky-swaps-{}", Uuid::new_v4())); + store::init(dir.to_str().unwrap()).unwrap(); + + let mut providers: Vec = provider.split(',').map(str::to_string).collect(); + let provider = providers[0].clone(); + let edges = provider_edges(provider.clone(), MNEMONIC.into(), None) + .await + .unwrap(); + assert!(edges.iter().any(|e| e.direction == "reverse"), "{edges:?}"); + + let request = PaykitRouteRequest { + amount_sat: 20_000, + contact_endpoints: vec![PaykitEndpoint { + method_id: "btc-regtest-p2wpkh".into(), + value: destination.clone(), + }], + lightning_spendable_sat: 500_000, + onchain_spendable_sat: 0, + providers: std::mem::take(&mut providers), + fee_rate_sat_vb: 2, + service_legs: vec![], + }; + let route = route_paykit_payment(request, bitcoin::Network::Regtest, MNEMONIC.into(), None) + .await + .unwrap(); + let PaykitRoute::Swap { quote } = route else { + panic!("expected a swap route, got {route:?}"); + }; + assert_eq!(quote.delivered_sat, 20_000); + assert_eq!(quote.lock_sat, 20_000 + quote.claim_fee_sat); + assert!(quote.debit_sat > quote.lock_sat); + + let payment = commit_route(quote.quote_id.clone(), electrum, MNEMONIC.into(), None) + .await + .unwrap(); + assert_eq!(payment.destination_address, destination); + assert!(payment.invoice.starts_with("lnbcrt"), "{}", payment.invoice); + let status = advance_swap(payment.swap_id.clone(), MNEMONIC.into(), None) + .await + .unwrap(); + assert!(matches!( + status.state, + PubkySwapRouteState::AwaitingLockup { .. } + )); + log::info!("{quote:?} {payment:?}"); + } +} diff --git a/src/modules/pubky_swaps/errors.rs b/src/modules/pubky_swaps/errors.rs new file mode 100644 index 0000000..3657d5f --- /dev/null +++ b/src/modules/pubky_swaps/errors.rs @@ -0,0 +1,78 @@ +use thiserror::Error; + +/// Errors surfaced by the Pubky Swaps route module. +#[derive(uniffi::Error, Debug, Error)] +pub enum PubkySwapError { + #[error("Invalid input: {error_details}")] + InvalidInput { error_details: String }, + + #[error("Provider unreachable: {error_details}")] + Transport { error_details: String }, + + /// The provider refused the request with one of its closed refusal codes. + #[error("Provider refused ({code}): {reason}")] + Refused { code: String, reason: String }, + + /// The provider's quote, contract or invoice did not match what was asked for. + #[error("Validation failed: {error_details}")] + Validation { error_details: String }, + + #[error("Chain error: {error_details}")] + Chain { error_details: String }, + + #[error("Storage error: {error_details}")] + Storage { error_details: String }, + + #[error("Swap not found: {error_details}")] + NotFound { error_details: String }, +} + +impl PubkySwapError { + pub(crate) fn invalid(details: impl ToString) -> Self { + Self::InvalidInput { + error_details: details.to_string(), + } + } + + pub(crate) fn transport(details: impl ToString) -> Self { + Self::Transport { + error_details: details.to_string(), + } + } + + pub(crate) fn validation(details: impl ToString) -> Self { + Self::Validation { + error_details: details.to_string(), + } + } + + pub(crate) fn chain(details: impl ToString) -> Self { + Self::Chain { + error_details: details.to_string(), + } + } + + pub(crate) fn storage(details: impl ToString) -> Self { + Self::Storage { + error_details: details.to_string(), + } + } +} + +impl From for PubkySwapError { + fn from(err: serde_json::Error) -> Self { + Self::storage(err) + } +} + +impl From for PubkySwapError { + fn from(err: std::io::Error) -> Self { + Self::storage(err) + } +} + +impl From for PubkySwapError { + fn from(err: electrum_client::Error) -> Self { + Self::chain(err) + } +} diff --git a/src/modules/pubky_swaps/keys.rs b/src/modules/pubky_swaps/keys.rs new file mode 100644 index 0000000..def82d7 --- /dev/null +++ b/src/modules/pubky_swaps/keys.rs @@ -0,0 +1,98 @@ +//! Swap keys derived from the wallet seed, so a swap can be rebuilt from the seed and its index. +//! +//! The provider sees only public keys and the payment hash. Each key is +//! HMAC-SHA512(seed, domain || index), truncated to 32 bytes, under its own domain string, so +//! nothing here can collide with the Boltz module's BIP85 keys or with each other. + +use bitcoin::hashes::{hmac, sha256, sha512, Hash, HashEngine}; +use bitcoin::secp256k1::{Secp256k1, SecretKey}; + +use super::errors::PubkySwapError; + +const IDENTITY_DOMAIN: &[u8] = b"bitkit/pubky-swaps/identity/v1"; +const CLAIM_DOMAIN: &[u8] = b"bitkit/pubky-swaps/claim/v1/"; +const PREIMAGE_DOMAIN: &[u8] = b"bitkit/pubky-swaps/preimage/v1/"; + +pub(crate) struct SwapKeys { + pub claim_key: SecretKey, + pub claim_pubkey: bitcoin::PublicKey, + pub preimage: [u8; 32], + pub payment_hash: [u8; 32], +} + +fn seed(mnemonic: &str, passphrase: Option<&str>) -> Result<[u8; 64], PubkySwapError> { + let mnemonic = bip39::Mnemonic::parse(mnemonic) + .map_err(|e| PubkySwapError::invalid(format!("mnemonic: {e}")))?; + Ok(mnemonic.to_seed(passphrase.unwrap_or(""))) +} + +fn derive(seed: &[u8; 64], domain: &[u8], index: Option) -> [u8; 32] { + let mut engine = hmac::HmacEngine::::new(seed); + engine.input(domain); + if let Some(index) = index { + engine.input(&index.to_be_bytes()); + } + let out = hmac::Hmac::::from_engine(engine).to_byte_array(); + let mut key = [0u8; 32]; + key.copy_from_slice(&out[..32]); + key +} + +/// The Ed25519 secret the wallet uses as its identity towards swap providers. It is not the +/// user's Pubky identity, so providers cannot link swaps to the user's profile. +pub(crate) fn identity_secret( + mnemonic: &str, + passphrase: Option<&str>, +) -> Result<[u8; 32], PubkySwapError> { + Ok(derive(&seed(mnemonic, passphrase)?, IDENTITY_DOMAIN, None)) +} + +pub(crate) fn swap_keys( + mnemonic: &str, + passphrase: Option<&str>, + index: u64, +) -> Result { + let seed = seed(mnemonic, passphrase)?; + let claim_key = SecretKey::from_slice(&derive(&seed, CLAIM_DOMAIN, Some(index))) + .map_err(|e| PubkySwapError::invalid(format!("claim key: {e}")))?; + let claim_pubkey = bitcoin::PublicKey::new(claim_key.public_key(&Secp256k1::new())); + let preimage = derive(&seed, PREIMAGE_DOMAIN, Some(index)); + let payment_hash = sha256::Hash::hash(&preimage).to_byte_array(); + Ok(SwapKeys { + claim_key, + claim_pubkey, + preimage, + payment_hash, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + const MNEMONIC: &str = + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; + + #[test] + fn keys_are_deterministic_and_distinct_per_index() { + let a = swap_keys(MNEMONIC, None, 0).unwrap(); + let again = swap_keys(MNEMONIC, None, 0).unwrap(); + let b = swap_keys(MNEMONIC, None, 1).unwrap(); + assert_eq!(a.claim_key, again.claim_key); + assert_eq!(a.preimage, again.preimage); + assert_ne!(a.claim_key, b.claim_key); + assert_ne!(a.preimage, b.preimage); + assert_ne!(a.preimage[..], a.claim_key.secret_bytes()[..]); + } + + #[test] + fn passphrase_changes_every_key() { + let plain = swap_keys(MNEMONIC, None, 0).unwrap(); + let with = swap_keys(MNEMONIC, Some("x"), 0).unwrap(); + assert_ne!(plain.claim_key, with.claim_key); + assert_ne!( + identity_secret(MNEMONIC, None).unwrap(), + identity_secret(MNEMONIC, Some("x")).unwrap() + ); + } +} diff --git a/src/modules/pubky_swaps/mod.rs b/src/modules/pubky_swaps/mod.rs new file mode 100644 index 0000000..d95646f --- /dev/null +++ b/src/modules/pubky_swaps/mod.rs @@ -0,0 +1,16 @@ +//! Pubky Swaps as Paykit routes: when no rail the wallet holds reaches an endpoint a Paykit +//! contact published, route the payment through a Pubky Swaps provider (`swap/1`). +//! See README.md. + +mod client; +mod errors; +mod keys; +mod router; +mod store; +mod transport; +mod types; + +pub use client::{advance_swap, commit_route, provider_edges, route_paykit_payment}; +pub use errors::PubkySwapError; +pub(crate) use store::init; +pub use types::*; diff --git a/src/modules/pubky_swaps/router.rs b/src/modules/pubky_swaps/router.rs new file mode 100644 index 0000000..7d94f9d --- /dev/null +++ b/src/modules/pubky_swaps/router.rs @@ -0,0 +1,293 @@ +//! Wallet-local route selection for a Paykit payment (Paykit Capabilities §9.1, one `swap/1` +//! leg at most). +//! +//! A contact the wallet can pay from its own balance is paid directly. Otherwise the router +//! turns each trusted provider's offer into `swap/1` edges, keeps the edges that connect a rail +//! the wallet holds to an endpoint the contact published, pre-ranks them by indicative fee, +//! asks the best few for a firm quote, and picks the one that debits the wallet least for the +//! exact amount the contact must receive. + +use swap_common::messages::SwapOffer; +use swap_common::SwapDirection; + +use super::types::{ + PaykitEndpoint, PaykitRoute, PubkySwapRouteQuote, ServiceRouteLeg, SwapRouteEdge, +}; + +pub(crate) const LIGHTNING_BOLT11: &str = "btc-lightning-bolt11"; +pub(crate) const LIGHTNING_LNURL: &str = "btc-lightning-lnurl"; +/// Providers asked for a firm quote per payment (§9.1 `fanout_budget`). +pub(crate) const FANOUT_BUDGET: usize = 3; + +/// On-chain address types in the order Bitkit prefers to pay them. +const ONCHAIN_PREFERENCE: [&str; 4] = ["p2tr", "p2wpkh", "p2sh", "p2pkh"]; + +pub(crate) fn network_label(network: bitcoin::Network) -> &'static str { + match network { + bitcoin::Network::Bitcoin => "bitcoin", + bitcoin::Network::Regtest => "regtest", + bitcoin::Network::Signet => "signet", + _ => "testnet", + } +} + +pub(crate) fn is_lightning(method_id: &str) -> bool { + method_id == LIGHTNING_BOLT11 || method_id == LIGHTNING_LNURL +} + +/// The contact's on-chain endpoint for `network`, preferring the cheapest address type. +pub(crate) fn onchain_endpoint( + endpoints: &[PaykitEndpoint], + network: bitcoin::Network, +) -> Option { + let prefix = format!("btc-{}-", network_label(network)); + ONCHAIN_PREFERENCE.iter().find_map(|kind| { + endpoints + .iter() + .find(|e| e.method_id == format!("{prefix}{kind}")) + .cloned() + }) +} + +/// The `swap/1` edges an offer advertises (Paykit Capabilities §13.1). The fee, minimum and +/// `fund_within_secs` are offer-wide, so both directions carry the same numbers. +pub(crate) fn edges_from_offer(offer: &SwapOffer) -> Vec { + let onchain = format!( + "btc-{}-*", + network_label(offer.network.to_bitcoin_network()) + ); + offer + .directions + .iter() + .map(|direction| { + let (dir, from, to) = match direction { + SwapDirection::Reverse => { + ("reverse", LIGHTNING_BOLT11.to_string(), onchain.clone()) + } + SwapDirection::Submarine => { + ("submarine", onchain.clone(), LIGHTNING_BOLT11.to_string()) + } + }; + SwapRouteEdge { + provider_pubky: offer.provider_pkarr.clone(), + offer_id: offer.offer_id.to_string(), + direction: dir.to_string(), + from_endpoint: from, + to_endpoint: to, + min_sat: offer.effective_min_amount_sat(), + max_sat: offer.max_amount_sat, + base_fee_sat: offer.base_fee_sat, + fee_ppm: offer.fee_ppm, + onchain_fee_sat: offer.onchain_fee_sat, + atomicity: "hash".to_string(), + fund_within_secs: offer.fund_within_secs, + } + }) + .collect() +} + +/// Indicative fee of an edge for `amount_sat`: base + ppm + on-chain (§6.2). +pub(crate) fn indicative_fee(edge: &SwapRouteEdge, amount_sat: u64) -> u64 { + let proportional = (u128::from(amount_sat) * u128::from(edge.fee_ppm) / 1_000_000) as u64; + edge.base_fee_sat + .saturating_add(proportional) + .saturating_add(edge.onchain_fee_sat) +} + +/// Reverse edges that can lock `lock_sat` and that the wallet can afford over Lightning, +/// cheapest first, at most [`FANOUT_BUDGET`]. +pub(crate) fn rank_reverse_edges( + edges: Vec, + lock_sat: u64, + lightning_spendable_sat: u64, +) -> Vec { + let mut usable: Vec<_> = edges + .into_iter() + .filter(|e| e.direction == "reverse") + .filter(|e| lock_sat >= e.min_sat && lock_sat <= e.max_sat) + .filter(|e| lock_sat.saturating_add(indicative_fee(e, lock_sat)) <= lightning_spendable_sat) + .collect(); + usable.sort_by_key(|e| indicative_fee(e, lock_sat)); + usable.truncate(FANOUT_BUDGET); + usable +} + +/// The cheapest service leg that delivers exactly `amount_sat` to an endpoint the contact +/// published and whose quote still holds at `now_unix`. +pub(crate) fn best_service_leg( + legs: &[ServiceRouteLeg], + endpoints: &[PaykitEndpoint], + amount_sat: u64, + now_unix: u64, +) -> Option { + legs.iter() + .filter(|leg| endpoints.contains(&leg.endpoint)) + .filter(|leg| leg.delivered_sat == amount_sat && leg.debit_sat >= leg.delivered_sat) + .filter(|leg| leg.valid_until_unix == 0 || leg.valid_until_unix > now_unix) + .min_by_key(|leg| leg.debit_sat - leg.delivered_sat) + .cloned() +} + +/// The route that costs the wallet less in fees. A hash-locked swap wins a tie: the wallet +/// trusts no one to complete it. +pub(crate) fn cheaper_route( + service: Option, + swap: Option, +) -> Option { + match (service, swap) { + (Some(leg), Some(quote)) if quote.total_fee_sat <= leg.debit_sat - leg.delivered_sat => { + Some(PaykitRoute::Swap { quote }) + } + (Some(leg), _) => Some(PaykitRoute::Service { leg }), + (None, Some(quote)) => Some(PaykitRoute::Swap { quote }), + (None, None) => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn edge(provider: &str, direction: &str, base: u64, min: u64, max: u64) -> SwapRouteEdge { + SwapRouteEdge { + provider_pubky: provider.into(), + offer_id: "o".into(), + direction: direction.into(), + from_endpoint: LIGHTNING_BOLT11.into(), + to_endpoint: "btc-regtest-*".into(), + min_sat: min, + max_sat: max, + base_fee_sat: base, + fee_ppm: 2500, + onchain_fee_sat: 500, + atomicity: "hash".into(), + fund_within_secs: 300, + } + } + + fn endpoint(method_id: &str) -> PaykitEndpoint { + PaykitEndpoint { + method_id: method_id.into(), + value: "v".into(), + } + } + + #[test] + fn picks_preferred_onchain_endpoint_for_the_network() { + let endpoints = vec![ + endpoint("btc-regtest-p2pkh"), + endpoint("btc-bitcoin-p2tr"), + endpoint("btc-regtest-p2wpkh"), + ]; + let picked = onchain_endpoint(&endpoints, bitcoin::Network::Regtest).unwrap(); + assert_eq!(picked.method_id, "btc-regtest-p2wpkh"); + assert!( + onchain_endpoint(&[endpoint(LIGHTNING_BOLT11)], bitcoin::Network::Regtest).is_none() + ); + } + + #[test] + fn ranks_reverse_edges_by_fee_within_bounds_and_budget() { + let edges = vec![ + edge("expensive", "reverse", 900, 10_000, 1_000_000), + edge("cheap", "reverse", 100, 10_000, 1_000_000), + edge("submarine", "submarine", 0, 10_000, 1_000_000), + edge("too-small", "reverse", 0, 10_000, 15_000), + edge("min-too-high", "reverse", 0, 50_000, 1_000_000), + ]; + let ranked = rank_reverse_edges(edges, 20_000, 1_000_000); + let names: Vec<_> = ranked.iter().map(|e| e.provider_pubky.as_str()).collect(); + assert_eq!(names, ["cheap", "expensive"]); + } + + #[test] + fn drops_edges_the_wallet_cannot_afford() { + let edges = vec![edge("p", "reverse", 100, 10_000, 1_000_000)]; + // 20,000 locked + 100 + 50 + 500 fee = 20,650. + assert!(rank_reverse_edges(edges.clone(), 20_000, 20_649).is_empty()); + assert_eq!(rank_reverse_edges(edges, 20_000, 20_650).len(), 1); + } + + #[test] + fn indicative_fee_matches_the_offer_formula() { + let e = edge("p", "reverse", 100, 0, u64::MAX); + assert_eq!(indicative_fee(&e, 100_000), 100 + 250 + 500); + } + + fn leg( + service: &str, + method_id: &str, + delivered: u64, + debit: u64, + until: u64, + ) -> ServiceRouteLeg { + ServiceRouteLeg { + service: service.into(), + endpoint: endpoint(method_id), + delivered_sat: delivered, + debit_sat: debit, + atomicity: "operator".into(), + valid_until_unix: until, + } + } + + #[test] + fn picks_the_cheapest_service_leg_to_a_published_endpoint() { + let endpoints = vec![endpoint("btc-regtest-p2wpkh")]; + let legs = vec![ + leg("spark", "btc-regtest-p2wpkh", 20_000, 20_900, 0), + leg("arkade", "btc-regtest-p2wpkh", 20_000, 20_400, 0), + leg("unpublished", "btc-regtest-p2tr", 20_000, 20_001, 0), + ]; + let picked = best_service_leg(&legs, &endpoints, 20_000, 100).unwrap(); + assert_eq!(picked.service, "arkade"); + } + + #[test] + fn drops_service_legs_that_are_expired_or_deliver_another_amount() { + let endpoints = vec![endpoint("btc-regtest-p2wpkh")]; + let legs = vec![ + leg("expired", "btc-regtest-p2wpkh", 20_000, 20_100, 100), + leg("short", "btc-regtest-p2wpkh", 19_000, 19_100, 0), + leg("negative-fee", "btc-regtest-p2wpkh", 20_000, 19_999, 0), + ]; + assert!(best_service_leg(&legs, &endpoints, 20_000, 100).is_none()); + let live = leg("live", "btc-regtest-p2wpkh", 20_000, 20_100, 101); + assert_eq!( + best_service_leg(std::slice::from_ref(&live), &endpoints, 20_000, 100), + Some(live) + ); + } + + fn swap_quote(total_fee_sat: u64) -> PubkySwapRouteQuote { + PubkySwapRouteQuote { + provider_pubky: "p".into(), + quote_id: "q".into(), + endpoint: endpoint("btc-regtest-p2wpkh"), + delivered_sat: 20_000, + lock_sat: 20_200, + debit_sat: 20_000 + total_fee_sat, + service_fee_sat: 0, + provider_onchain_fee_sat: 0, + claim_fee_sat: 200, + total_fee_sat, + atomicity: "hash".into(), + valid_until_unix: 0, + providers_quoted: 1, + } + } + + #[test] + fn picks_the_route_with_the_lower_fee_and_the_swap_on_a_tie() { + let service = leg("arkade", "btc-regtest-p2wpkh", 20_000, 20_500, 0); + let pick = |swap_fee| cheaper_route(Some(service.clone()), Some(swap_quote(swap_fee))); + assert!(matches!(pick(499), Some(PaykitRoute::Swap { .. }))); + assert!(matches!(pick(500), Some(PaykitRoute::Swap { .. }))); + assert!(matches!(pick(501), Some(PaykitRoute::Service { .. }))); + assert!(matches!( + cheaper_route(Some(service), None), + Some(PaykitRoute::Service { .. }) + )); + assert!(cheaper_route(None, None).is_none()); + } +} diff --git a/src/modules/pubky_swaps/store.rs b/src/modules/pubky_swaps/store.rs new file mode 100644 index 0000000..6efaec4 --- /dev/null +++ b/src/modules/pubky_swaps/store.rs @@ -0,0 +1,83 @@ +//! One JSON file per swap under `/pubky_swaps/`, plus the next key index. +//! +//! A record holds only public data and the key index; the keys come from the seed. Every +//! record is written before the step it protects: the index before the commit is sent, the +//! contract before the invoice is handed to the app. + +use std::fs; +use std::path::{Path, PathBuf}; +use std::sync::Mutex; + +use once_cell::sync::OnceCell; +use serde::{Deserialize, Serialize}; +use swap_common::messages::{Quote, SwapAccept}; + +use super::errors::PubkySwapError; + +static BASE: OnceCell = OnceCell::new(); +static LOCK: Mutex<()> = Mutex::new(()); + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub(crate) struct SwapRecord { + pub swap_id: String, + pub key_index: u64, + pub provider_pubky: String, + pub network: bitcoin::Network, + pub electrum_url: String, + pub quote: Quote, + pub accept: SwapAccept, + pub destination_address: String, + pub delivered_sat: u64, + pub claim_fee_sat: u64, + pub claim_txid: Option, + pub created_at_unix: u64, +} + +pub(crate) fn init(base_path: &str) -> Result<(), PubkySwapError> { + let dir = Path::new(base_path).join("pubky_swaps"); + fs::create_dir_all(&dir)?; + let _ = BASE.set(dir); + Ok(()) +} + +fn dir() -> Result<&'static PathBuf, PubkySwapError> { + BASE.get() + .ok_or_else(|| PubkySwapError::storage("Database not initialized. Call init_db first.")) +} + +fn write_atomic(path: &Path, bytes: &[u8]) -> Result<(), PubkySwapError> { + let tmp = path.with_extension("tmp"); + fs::write(&tmp, bytes)?; + fs::rename(tmp, path)?; + Ok(()) +} + +/// Reserve the next key index, persisted before it is used. +pub(crate) fn reserve_index() -> Result { + let _guard = LOCK.lock().unwrap(); + let path = dir()?.join("next_index"); + let index = match fs::read_to_string(&path) { + Ok(s) => s.trim().parse().map_err(PubkySwapError::storage)?, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => 0, + Err(e) => return Err(e.into()), + }; + write_atomic(&path, (index + 1).to_string().as_bytes())?; + Ok(index) +} + +pub(crate) fn save(record: &SwapRecord) -> Result<(), PubkySwapError> { + let _guard = LOCK.lock().unwrap(); + let path = dir()?.join(format!("{}.json", record.swap_id)); + write_atomic(&path, &serde_json::to_vec_pretty(record)?) +} + +pub(crate) fn load(swap_id: &str) -> Result { + let path = dir()?.join(format!("{swap_id}.json")); + match fs::read(&path) { + Ok(bytes) => Ok(serde_json::from_slice(&bytes)?), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => Err(PubkySwapError::NotFound { + error_details: swap_id.to_string(), + }), + Err(e) => Err(e.into()), + } +} diff --git a/src/modules/pubky_swaps/transport.rs b/src/modules/pubky_swaps/transport.rs new file mode 100644 index 0000000..40063ec --- /dev/null +++ b/src/modules/pubky_swaps/transport.rs @@ -0,0 +1,99 @@ +//! Requests to a Pubky Swaps provider over iroh `pubky-swap/direct/1`. +//! +//! The provider authenticates the request by the connection's key, so this needs no +//! homeserver on either side. Each request opens a stream, writes `{"message": …}`, and reads +//! the provider's reply, which is one `SwapMessage`. + +use std::time::Duration; + +use iroh::endpoint::presets; +use iroh::{Endpoint, PublicKey as EndpointId, SecretKey}; +use serde_json::json; +use swap_common::messages::SwapMessage; + +use super::errors::PubkySwapError; + +const DIRECT_ALPN: &[u8] = b"pubky-swap/direct/1"; +const MAX_REPLY_BYTES: usize = 64 * 1024; +const CONNECT_TIMEOUT: Duration = Duration::from_secs(20); +const REQUEST_TIMEOUT: Duration = Duration::from_secs(60); +const ONLINE_TIMEOUT: Duration = Duration::from_secs(10); + +#[derive(Clone)] +pub(crate) struct DirectClient { + endpoint: Endpoint, +} + +impl DirectClient { + /// Bind an endpoint whose id is the wallet's swap identity. + pub(crate) async fn bind(identity_secret: [u8; 32]) -> Result { + let endpoint = Endpoint::builder(presets::N0) + .secret_key(SecretKey::from_bytes(&identity_secret)) + .bind() + .await + .map_err(PubkySwapError::transport)?; + // Reaching a provider needs a home relay; without one the first connects all time out. + if tokio::time::timeout(ONLINE_TIMEOUT, endpoint.online()) + .await + .is_err() + { + log::warn!("pubky swaps: no home relay after {ONLINE_TIMEOUT:?}"); + } + Ok(Self { endpoint }) + } + + /// Send one request to `provider_pubky` and return its reply. + pub(crate) async fn request( + &self, + provider_pubky: &str, + message: &SwapMessage, + ) -> Result { + let provider = provider_endpoint_id(provider_pubky)?; + let body = serde_json::to_vec(&json!({ "message": message }))?; + let conn = tokio::time::timeout( + CONNECT_TIMEOUT, + self.endpoint.connect(provider, DIRECT_ALPN), + ) + .await + .map_err(|_| PubkySwapError::transport("timed out connecting to the provider"))? + .map_err(PubkySwapError::transport)?; + let reply = tokio::time::timeout(REQUEST_TIMEOUT, async { + let (mut send, mut recv) = conn.open_bi().await.map_err(PubkySwapError::transport)?; + send.write_all(&body) + .await + .map_err(PubkySwapError::transport)?; + send.finish().map_err(PubkySwapError::transport)?; + recv.read_to_end(MAX_REPLY_BYTES) + .await + .map_err(PubkySwapError::transport) + }) + .await + .map_err(|_| PubkySwapError::transport("timed out waiting for the provider"))??; + conn.close(0u32.into(), b"done"); + serde_json::from_slice(&reply) + .map_err(|e| PubkySwapError::transport(format!("unreadable reply: {e}"))) + } + + pub(crate) async fn close(self) { + self.endpoint.close().await; + } +} + +/// A pubky and an iroh endpoint id are the same Ed25519 key. +fn provider_endpoint_id(provider_pubky: &str) -> Result { + let bare = bare_pubky(provider_pubky); + let key = pubky::PublicKey::try_from_z32(bare) + .map_err(|e| PubkySwapError::invalid(format!("provider pubky: {e}")))?; + EndpointId::from_bytes(&key.to_bytes()) + .map_err(|e| PubkySwapError::invalid(format!("provider pubky: {e}"))) +} + +/// The 52-character z-base-32 key, with any `pubky://` or `pubky` display prefix removed. +pub(crate) fn bare_pubky(pubky: &str) -> &str { + let pubky = pubky.trim(); + let pubky = pubky.strip_prefix("pubky://").unwrap_or(pubky); + match pubky.strip_prefix("pubky") { + Some(rest) if rest.len() == 52 => rest, + _ => pubky, + } +} diff --git a/src/modules/pubky_swaps/types.rs b/src/modules/pubky_swaps/types.rs new file mode 100644 index 0000000..8ea8edf --- /dev/null +++ b/src/modules/pubky_swaps/types.rs @@ -0,0 +1,145 @@ +use serde::{Deserialize, Serialize}; + +/// A `swap/1` edge from a provider's offer, in Paykit Capabilities terms: the payment endpoint +/// the owner pays from, the endpoint the route delivers to, its bounds and its indicative fee. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)] +pub struct SwapRouteEdge { + pub provider_pubky: String, + pub offer_id: String, + /// `reverse` (Lightning to on-chain) or `submarine` (on-chain to Lightning). + pub direction: String, + /// Payment Endpoint Identifier the owner pays with, such as `btc-lightning-bolt11`. + pub from_endpoint: String, + /// Payment Endpoint Identifier family the route delivers to, such as `btc-regtest-*`. + pub to_endpoint: String, + /// The minimum the provider enforces, not its configured floor. + pub min_sat: u64, + pub max_sat: u64, + pub base_fee_sat: u64, + pub fee_ppm: u64, + pub onchain_fee_sat: u64, + /// Atomicity class of the edge. Pubky Swaps legs are always `hash`. + pub atomicity: String, + pub fund_within_secs: u64, +} + +/// What the wallet knows when it pays a Paykit contact: the amount, the endpoints the contact +/// published and what the wallet can spend on each rail. +#[derive(Debug, Clone, uniffi::Record)] +pub struct PaykitRouteRequest { + pub amount_sat: u64, + /// Payment Endpoint Identifiers paired with their values, as Paykit resolved them. + pub contact_endpoints: Vec, + pub lightning_spendable_sat: u64, + pub onchain_spendable_sat: u64, + /// Candidate swap providers as pubkys, usually the user's contacts. Each is asked for its + /// offer; those that run no provider are skipped. + pub providers: Vec, + /// Fee rate for the wallet's own claim transaction. + pub fee_rate_sat_vb: u64, + /// Routes through services the wallet holds a balance on (Arkade, Spark), each already quoted + /// by the app's engine for that service. They compete with the Pubky Swaps providers on fee. + pub service_legs: Vec, +} + +/// A one-leg route through a service the wallet holds a balance on, such as an Arkade offboard +/// or a Spark withdrawal to the contact's on-chain address. The app quotes it and runs it. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)] +pub struct ServiceRouteLeg { + /// `arkade` or `spark`. + pub service: String, + /// The contact endpoint the service delivers to. It must be one the contact published. + pub endpoint: PaykitEndpoint, + /// What the contact receives. + pub delivered_sat: u64, + /// What the wallet's balance on the service is debited. + pub debit_sat: u64, + /// Who the wallet trusts to complete the leg: `operator` for an Arkade batch, `trusted` for + /// Spark's operators. Pubky Swaps legs are `hash`. + pub atomicity: String, + /// When the quote stops holding, or 0 when it does not expire. + pub valid_until_unix: u64, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)] +pub struct PaykitEndpoint { + pub method_id: String, + pub value: String, +} + +/// The route the router picked. A direct route means no swap is needed. +#[derive(Debug, Clone, uniffi::Enum)] +pub enum PaykitRoute { + /// The wallet can pay this endpoint from its own balance. + Direct { endpoint: PaykitEndpoint }, + /// The wallet pays over Lightning and a Pubky Swaps provider delivers on-chain. + Swap { quote: PubkySwapRouteQuote }, + /// A service the wallet holds a balance on delivers to the contact. The app runs the leg. + Service { leg: ServiceRouteLeg }, + /// Nothing can pay this contact. `reason` says why, for the user. + None { reason: String }, +} + +/// A firm `swap/1` quote for one route, with everything the review screen shows. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)] +pub struct PubkySwapRouteQuote { + pub provider_pubky: String, + pub quote_id: String, + /// The contact endpoint the swap delivers to. + pub endpoint: PaykitEndpoint, + /// What the contact receives. + pub delivered_sat: u64, + /// What the provider locks on chain: the delivered amount plus the wallet's claim fee. + pub lock_sat: u64, + /// What the wallet pays over Lightning. + pub debit_sat: u64, + pub service_fee_sat: u64, + pub provider_onchain_fee_sat: u64, + pub claim_fee_sat: u64, + /// `debit_sat - delivered_sat`. + pub total_fee_sat: u64, + pub atomicity: String, + pub valid_until_unix: u64, + /// How many providers were asked for a quote. + pub providers_quoted: u32, +} + +/// A committed swap: the hold invoice the wallet pays to start it. +#[derive(Debug, Clone, uniffi::Record)] +pub struct PubkySwapRoutePayment { + pub swap_id: String, + pub invoice: String, + pub debit_sat: u64, + pub delivered_sat: u64, + pub destination_address: String, + pub htlc_address: String, + pub timeout_block_height: u32, +} + +#[derive(Debug, Clone, PartialEq, Eq, uniffi::Enum)] +pub enum PubkySwapRouteState { + /// Waiting for the hold invoice to be paid. + AwaitingPayment, + /// Paid; waiting for the provider's on-chain lockup, or for its confirmations. + AwaitingLockup { + confirmations: u32, + required: u32, + }, + /// The claim to the contact's address is broadcast. The provider settles the invoice + /// once it sees the preimage. + Claimed { + txid: String, + }, + Failed { + reason: String, + }, +} + +#[derive(Debug, Clone, uniffi::Record)] +pub struct PubkySwapRouteStatus { + pub swap_id: String, + pub state: PubkySwapRouteState, + pub provider_pubky: String, + pub delivered_sat: u64, + pub destination_address: String, +}