From 8f820857ba4486094fc2da0217d83d992c1c1683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Granh=C3=A3o?= <32176319+danielgranhao@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:52:54 +0000 Subject: [PATCH] Use new fiat topup registration mutations --- Cargo.lock | 592 +++++++------------------------ Cargo.toml | 22 +- examples/node/cli.rs | 16 +- mock/pocketclient/Cargo.toml | 9 - mock/pocketclient/src/lib.rs | 42 --- mock/wild/chameleon/Cargo.toml | 4 +- mock/wild/crow/Cargo.toml | 5 +- mock/wild/crow/src/lib.rs | 54 ++- mock/wild/honeybadger/Cargo.toml | 4 +- mock/wild/parrot/Cargo.toml | 4 +- mock/wild/pigeon/Cargo.toml | 2 +- mock/wild/squirrel/Cargo.toml | 4 +- pocketclient/Cargo.toml | 11 - pocketclient/src/lib.rs | 271 -------------- src/data_store.rs | 14 +- src/fiat_topup.rs | 73 ++-- src/lib.rs | 45 +-- src/lipalightninglib.udl | 11 +- src/support.rs | 2 - tests/topup_test.rs | 29 +- 20 files changed, 278 insertions(+), 936 deletions(-) delete mode 100644 mock/pocketclient/Cargo.toml delete mode 100644 mock/pocketclient/src/lib.rs delete mode 100644 pocketclient/Cargo.toml delete mode 100644 pocketclient/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 0aa950d9..7c40bdd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -134,9 +134,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "android-tzdata" @@ -180,12 +180,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a30a44e99a1c83ccb2a6298c563c888952a1c9134953db26876528f84c93a" -[[package]] -name = "ascii" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" - [[package]] name = "askama" version = "0.12.1" @@ -209,7 +203,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -285,7 +279,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -296,7 +290,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -333,9 +327,9 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.31", + "http", + "http-body", + "hyper", "itoa", "matchit", "memchr", @@ -344,7 +338,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper 0.1.2", + "sync_wrapper", "tower", "tower-layer", "tower-service", @@ -359,8 +353,8 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http", + "http-body", "mime", "rustversion", "tower-layer", @@ -687,7 +681,7 @@ dependencies = [ "prost", "rand", "regex", - "reqwest 0.11.20", + "reqwest", "ripemd", "rusqlite", "rusqlite_migration", @@ -798,9 +792,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "shlex", ] @@ -844,7 +838,7 @@ dependencies = [ [[package]] name = "chameleon" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.28.0#8ad85fa3020046a042614c2da7d6f513661311da" +source = "git+https://github.com/getlipa/wild?tag=v1.29.0#c6d1c3fc9dd8b92922760d363e5793d76657f46d" dependencies = [ "graphql", "honeybadger", @@ -939,15 +933,12 @@ dependencies = [ [[package]] name = "combine" -version = "3.8.1" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ - "ascii", - "byteorder", - "either", + "bytes", "memchr", - "unreachable", ] [[package]] @@ -1069,7 +1060,7 @@ dependencies = [ [[package]] name = "crow" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.28.0#8ad85fa3020046a042614c2da7d6f513661311da" +source = "git+https://github.com/getlipa/wild?tag=v1.29.0#c6d1c3fc9dd8b92922760d363e5793d76657f46d" dependencies = [ "graphql", "honeybadger", @@ -1087,6 +1078,7 @@ dependencies = [ "isocountry", "isolanguage-1", "lazy_static", + "uuid", ] [[package]] @@ -1122,7 +1114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1164,7 +1156,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1175,7 +1167,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1261,7 +1253,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1602,7 +1594,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1709,8 +1701,8 @@ dependencies = [ "cln-grpc", "futures", "hex", - "http 0.2.12", - "http-body 0.4.6", + "http", + "http-body", "log", "mockall", "picky", @@ -1721,10 +1713,10 @@ dependencies = [ "prost-derive", "rand", "rcgen", - "reqwest 0.11.20", + "reqwest", "ring 0.16.20", "runeauth", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "secp256k1 0.26.0", "serde", "serde_json", @@ -1766,13 +1758,13 @@ dependencies = [ [[package]] name = "graphql" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.28.0#8ad85fa3020046a042614c2da7d6f513661311da" +source = "git+https://github.com/getlipa/wild?tag=v1.29.0#c6d1c3fc9dd8b92922760d363e5793d76657f46d" dependencies = [ "chrono", "graphql_client", "log", "perro", - "reqwest 0.11.20", + "reqwest", "serde", ] @@ -1787,9 +1779,9 @@ dependencies = [ [[package]] name = "graphql-parser" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ebc8013b4426d5b81a4364c419a95ed0b404af2b82e2457de52d9348f0e474" +checksum = "7a818c0d883d7c0801df27be910917750932be279c7bc82dc541b8769425f409" dependencies = [ "combine", "thiserror 1.0.69", @@ -1802,7 +1794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a50cfdc7f34b7f01909d55c2dcb71d4c13cbcbb4a1605d6c8bd760d654c1144b" dependencies = [ "graphql_query_derive", - "reqwest 0.11.20", + "reqwest", "serde", "serde_json", ] @@ -1846,8 +1838,8 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http 0.2.12", - "indexmap 2.6.0", + "http", + "indexmap 2.7.0", "slab", "tokio", "tokio-util", @@ -1976,7 +1968,7 @@ dependencies = [ [[package]] name = "honeybadger" version = "1.0.1" -source = "git+https://github.com/getlipa/wild?tag=v1.28.0#8ad85fa3020046a042614c2da7d6f513661311da" +source = "git+https://github.com/getlipa/wild?tag=v1.29.0#c6d1c3fc9dd8b92922760d363e5793d76657f46d" dependencies = [ "base64 0.22.1", "bdk", @@ -2013,17 +2005,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http-body" version = "0.4.6" @@ -2031,30 +2012,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http 0.2.12", - "pin-project-lite", -] - -[[package]] -name = "http-body" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" -dependencies = [ - "bytes", - "http 1.1.0", -] - -[[package]] -name = "http-body-util" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" -dependencies = [ - "bytes", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", + "http", "pin-project-lite", ] @@ -2087,8 +2045,8 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http 0.2.12", - "http-body 0.4.6", + "http", + "http-body", "httparse", "httpdate", "itoa", @@ -2100,25 +2058,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - [[package]] name = "hyper-rustls" version = "0.24.2" @@ -2126,38 +2065,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http 0.2.12", - "hyper 0.14.31", + "http", + "hyper", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", ] -[[package]] -name = "hyper-rustls" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" -dependencies = [ - "futures-util", - "http 1.1.0", - "hyper 1.5.1", - "hyper-util", - "rustls 0.23.19", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.26.0", - "tower-service", - "webpki-roots 0.26.7", -] - [[package]] name = "hyper-timeout" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.31", + "hyper", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -2170,31 +2091,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.31", + "hyper", "native-tls", "tokio", "tokio-native-tls", ] -[[package]] -name = "hyper-util" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "hyper 1.5.1", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", -] - [[package]] name = "iana-time-zone" version = "0.1.61" @@ -2342,7 +2244,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2385,9 +2287,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -2472,10 +2374,11 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -2499,9 +2402,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.166" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libm" @@ -2661,12 +2564,9 @@ dependencies = [ "phonenumber", "pigeon", "pigeon-mock", - "pocketclient", - "pocketclient-mock", "qrcode", "rand", "regex", - "reqwest 0.12.9", "rusqlite", "rusqlite_migration", "rustyline", @@ -2782,11 +2682,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "log", "wasi", @@ -2972,7 +2871,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3056,7 +2955,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3138,7 +3037,7 @@ dependencies = [ [[package]] name = "parrot" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.28.0#8ad85fa3020046a042614c2da7d6f513661311da" +source = "git+https://github.com/getlipa/wild?tag=v1.29.0#c6d1c3fc9dd8b92922760d363e5793d76657f46d" dependencies = [ "graphql", "honeybadger", @@ -3234,7 +3133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.6.0", + "indexmap 2.7.0", ] [[package]] @@ -3267,7 +3166,7 @@ dependencies = [ "aes-gcm 0.9.2", "base64 0.13.1", "digest 0.9.0", - "http 0.2.12", + "http", "num-bigint-dig", "oid", "picky-asn1 0.3.3", @@ -3357,7 +3256,7 @@ dependencies = [ [[package]] name = "pigeon" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.28.0#8ad85fa3020046a042614c2da7d6f513661311da" +source = "git+https://github.com/getlipa/wild?tag=v1.29.0#c6d1c3fc9dd8b92922760d363e5793d76657f46d" dependencies = [ "graphql", "honeybadger", @@ -3389,7 +3288,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3416,26 +3315,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -[[package]] -name = "pocketclient" -version = "0.1.0" -dependencies = [ - "chrono", - "log", - "perro", - "reqwest 0.12.9", - "serde", -] - -[[package]] -name = "pocketclient-mock" -version = "0.1.0" -dependencies = [ - "perro", - "pocketclient", - "uuid", -] - [[package]] name = "poly1305" version = "0.8.0" @@ -3625,58 +3504,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "quinn" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" -dependencies = [ - "bytes", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash 2.0.0", - "rustls 0.23.19", - "socket2", - "thiserror 2.0.4", - "tokio", - "tracing", -] - -[[package]] -name = "quinn-proto" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" -dependencies = [ - "bytes", - "getrandom", - "rand", - "ring 0.17.8", - "rustc-hash 2.0.0", - "rustls 0.23.19", - "rustls-pki-types", - "slab", - "thiserror 2.0.4", - "tinyvec", - "tracing", - "web-time", -] - -[[package]] -name = "quinn-udp" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" -dependencies = [ - "cfg_aliases", - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.59.0", -] - [[package]] name = "quote" version = "1.0.37" @@ -3816,10 +3643,10 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.31", - "hyper-rustls 0.24.2", + "http", + "http-body", + "hyper", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -3831,7 +3658,7 @@ dependencies = [ "pin-project-lite", "rustls 0.21.12", "rustls-native-certs", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", @@ -3847,49 +3674,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "reqwest" -version = "0.12.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" -dependencies = [ - "base64 0.22.1", - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "http-body-util", - "hyper 1.5.1", - "hyper-rustls 0.27.3", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "quinn", - "rustls 0.23.19", - "rustls-pemfile 2.2.0", - "rustls-pki-types", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 1.0.2", - "tokio", - "tokio-rustls 0.26.0", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots 0.26.7", - "windows-registry", -] - [[package]] name = "ring" version = "0.16.20" @@ -3960,7 +3744,7 @@ dependencies = [ "crypto", "env_logger 0.10.2", "hex", - "indexmap 2.6.0", + "indexmap 2.7.0", "sha2 0.10.8", "thiserror 1.0.69", ] @@ -4003,12 +3787,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc-hash" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" - [[package]] name = "rusticata-macros" version = "4.1.0" @@ -4051,24 +3829,10 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", - "rustls-webpki 0.101.7", + "rustls-webpki", "sct", ] -[[package]] -name = "rustls" -version = "0.23.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" -dependencies = [ - "once_cell", - "ring 0.17.8", - "rustls-pki-types", - "rustls-webpki 0.102.8", - "subtle", - "zeroize", -] - [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -4076,7 +3840,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "schannel", "security-framework", ] @@ -4090,24 +3854,6 @@ dependencies = [ "base64 0.21.7", ] -[[package]] -name = "rustls-pemfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" -dependencies = [ - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" -dependencies = [ - "web-time", -] - [[package]] name = "rustls-webpki" version = "0.101.7" @@ -4118,17 +3864,6 @@ dependencies = [ "untrusted 0.9.0", ] -[[package]] -name = "rustls-webpki" -version = "0.102.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" -dependencies = [ - "ring 0.17.8", - "rustls-pki-types", - "untrusted 0.9.0", -] - [[package]] name = "rustversion" version = "1.0.18" @@ -4166,7 +3901,7 @@ checksum = "327e9d075f6df7e25fbf594f1be7ef55cf0d567a6cb5112eeccbbd51ceb48e0d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4216,7 +3951,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4253,7 +3988,7 @@ dependencies = [ "prost", "querystring", "regex", - "reqwest 0.11.20", + "reqwest", "serde", "serde_json", "strum_macros 0.25.3", @@ -4386,7 +4121,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4423,7 +4158,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.6.0", + "indexmap 2.7.0", "serde", "serde_derive", "serde_json", @@ -4440,7 +4175,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4466,7 +4201,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4683,7 +4418,7 @@ dependencies = [ [[package]] name = "squirrel" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.28.0#8ad85fa3020046a042614c2da7d6f513661311da" +source = "git+https://github.com/getlipa/wild?tag=v1.29.0#c6d1c3fc9dd8b92922760d363e5793d76657f46d" dependencies = [ "bdk", "graphql", @@ -4752,7 +4487,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4765,7 +4500,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4787,9 +4522,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.89" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -4802,15 +4537,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "sync_wrapper" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" -dependencies = [ - "futures-core", -] - [[package]] name = "synstructure" version = "0.12.6" @@ -4831,7 +4557,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4897,7 +4623,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4908,7 +4634,7 @@ checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4928,9 +4654,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", @@ -4951,9 +4677,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -4970,7 +4696,7 @@ dependencies = [ "once_cell", "pbkdf2", "rand", - "rustc-hash 1.1.0", + "rustc-hash", "sha2 0.10.8", "thiserror 1.0.69", "unicode-normalization", @@ -5039,7 +4765,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5073,17 +4799,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" -dependencies = [ - "rustls 0.23.19", - "rustls-pki-types", - "tokio", -] - [[package]] name = "tokio-stream" version = "0.1.16" @@ -5097,9 +4812,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -5129,7 +4844,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.7.0", "toml_datetime", "winnow", ] @@ -5148,16 +4863,16 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.31", + "http", + "http-body", + "hyper", "hyper-timeout", "percent-encoding", "pin-project", "prost", "prost-derive", "rustls-native-certs", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "tokio", "tokio-rustls 0.23.4", "tokio-stream", @@ -5235,7 +4950,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5363,7 +5078,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "802d2051a700e3ec894c79f80d2705b69d85844dafbbe5d1a92776f8f48b563a" dependencies = [ "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5393,7 +5108,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.89", + "syn 2.0.90", "toml", "uniffi_meta", ] @@ -5456,15 +5171,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - [[package]] name = "untrusted" version = "0.7.1" @@ -5607,12 +5313,6 @@ dependencies = [ "vls-protocol", ] -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "vte" version = "0.11.1" @@ -5650,9 +5350,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -5661,36 +5361,37 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5698,38 +5399,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "web-sys" -version = "0.3.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "web-time" -version = "1.1.0" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", @@ -5760,15 +5451,6 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" -[[package]] -name = "webpki-roots" -version = "0.26.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "weedle2" version = "5.0.0" @@ -5830,36 +5512,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-registry" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" -dependencies = [ - "windows-result", - "windows-strings", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-result" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-strings" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" -dependencies = [ - "windows-result", - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -6106,7 +5758,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -6134,7 +5786,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6154,7 +5806,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -6175,7 +5827,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6197,5 +5849,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] diff --git a/Cargo.toml b/Cargo.toml index 32a3b531..41a1ed79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ members = [ "mock/breez-sdk", "parser", - "pocketclient" ] [package] @@ -16,22 +15,20 @@ name = "uniffi_lipalightninglib" [dependencies] parser = { path = "parser" } -pocketclient = { path = "pocketclient", optional = true } -pocketclient-mock = { path = "mock/pocketclient", optional = true } -chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true } +chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true } chameleon-mock = { path = "mock/wild/chameleon", optional = true } -crow = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true } +crow = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true } crow-mock = { path = "mock/wild/crow", optional = true } -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } -honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } +honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true } honeybadger-mock = { path = "mock/wild/honeybadger", optional = true } -parrot = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true } +parrot = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true } parrot-mock = { path = "mock/wild/parrot", optional = true } perro = { git = "https://github.com/getlipa/perro", tag = "v1.2.0" } -pigeon = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true } +pigeon = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true } pigeon-mock = { path = "mock/wild/pigeon", optional = true } -squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true } +squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true } squirrel-mock = { path = "mock/wild/squirrel", optional = true } breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.6.5", optional = true } @@ -51,7 +48,6 @@ num_enum = "0.7.3" phonenumber = "0.3.6" rand = "0.8.5" regex = { version = "1.11.1" } -reqwest = { version = "0.12", default-features = false, features = ["json", "blocking", "rustls-tls"] } rusqlite_migration = "1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -63,8 +59,8 @@ uniffi = "0.28.3" uuid = { version = "1.11.0", features = ["v5"] } [features] -default = ["dep:breez-sdk-core", "dep:chameleon", "dep:crow", "dep:honeybadger", "dep:parrot", "dep:pigeon", "dep:squirrel", "dep:pocketclient"] -mock-deps = ["dep:breez-sdk-mock", "dep:chameleon-mock", "dep:crow-mock", "dep:honeybadger-mock", "dep:parrot-mock", "dep:pigeon-mock", "dep:squirrel-mock", "dep:pocketclient-mock"] +default = ["dep:breez-sdk-core", "dep:chameleon", "dep:crow", "dep:honeybadger", "dep:parrot", "dep:pigeon", "dep:squirrel"] +mock-deps = ["dep:breez-sdk-mock", "dep:chameleon-mock", "dep:crow-mock", "dep:honeybadger-mock", "dep:parrot-mock", "dep:pigeon-mock", "dep:squirrel-mock"] # Bundle sqlite for all targets except iOS. [target.'cfg(not(target_os = "ios"))'.dependencies] diff --git a/examples/node/cli.rs b/examples/node/cli.rs index 456e9e60..f9326ae5 100644 --- a/examples/node/cli.rs +++ b/examples/node/cli.rs @@ -433,7 +433,7 @@ fn setup_editor(history_path: &Path) -> Editor { )); hints.insert(CommandHint::new( - "registertopup [email] [referral code]", + "registertopup [email] [referral code]", "registertopup ", )); hints.insert(CommandHint::new("resettopup", "resettopup")); @@ -559,7 +559,7 @@ fn help() { println!(" getfailedswapresolvingfees "); println!(" refundfailedswap "); println!(); - println!(" registertopup [email] [referral code]"); + println!(" registertopup [email] [referral code]"); println!(" resettopup"); println!(" getregisteredtopup"); println!(" listoffers"); @@ -1151,12 +1151,18 @@ fn register_topup(node: &LightningNode, words: &mut dyn Iterator) - let currency = words.next().ok_or(anyhow!("Currency is required"))?; + let provider = words.next().ok_or(anyhow!("Provider is required"))?; + let email = words.next().map(String::from); let referral = words.next().map(String::from); - let topup_info = - node.fiat_topup() - .register(email, referral, iban.to_string(), currency.to_string())?; + let topup_info = node.fiat_topup().register( + email, + iban.to_string(), + currency.to_string(), + provider.to_string(), + referral, + )?; println!("{topup_info:?}"); Ok(()) diff --git a/mock/pocketclient/Cargo.toml b/mock/pocketclient/Cargo.toml deleted file mode 100644 index 6e38dfe5..00000000 --- a/mock/pocketclient/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "pocketclient-mock" -version = "0.1.0" -edition = "2021" - -[dependencies] -perro = { git = "https://github.com/getlipa/perro", tag = "v1.2.0" } -pocketclient = { path = "../../pocketclient" } -uuid = { version = "1.10.0", features = ["v4"] } diff --git a/mock/pocketclient/src/lib.rs b/mock/pocketclient/src/lib.rs deleted file mode 100644 index 00ffea82..00000000 --- a/mock/pocketclient/src/lib.rs +++ /dev/null @@ -1,42 +0,0 @@ -pub use pocketclient::{FiatTopupInfo, Result}; -use std::future::Future; -use uuid::Uuid; - -pub struct PocketClient {} - -impl PocketClient { - pub fn new(_pocket_url: String) -> Result { - Ok(PocketClient {}) - } - - pub async fn register_pocket_fiat_topup( - &self, - _user_iban: &str, - _user_currency: String, - _node_pubkey: String, - _sign_message: S, - ) -> Result - where - S: FnOnce(String) -> Fut, - Fut: Future>, - { - Ok(FiatTopupInfo { - order_id: Uuid::new_v4().to_string(), - debitor_iban: "Mock debitor_iban".to_string(), - creditor_reference: "Mock creditor_reference".to_string(), - creditor_iban: "Mock creditor_iban".to_string(), - creditor_bank_name: "Mock creditor_bank_name".to_string(), - creditor_bank_street: "Mock creditor_bank_street".to_string(), - creditor_bank_postal_code: "Mock creditor_bank_postal_code".to_string(), - creditor_bank_town: "Mock creditor_bank_town".to_string(), - creditor_bank_country: "Mock creditor_bank_country".to_string(), - creditor_bank_bic: "Mock creditor_bank_bic".to_string(), - creditor_name: "Mock creditor_name".to_string(), - creditor_street: "Mock creditor_street".to_string(), - creditor_postal_code: "Mock creditor_postal_code".to_string(), - creditor_town: "Mock creditor_town".to_string(), - creditor_country: "Mock creditor_country".to_string(), - currency: "Mock currency".to_string(), - }) - } -} diff --git a/mock/wild/chameleon/Cargo.toml b/mock/wild/chameleon/Cargo.toml index 76c53e08..53835c23 100644 --- a/mock/wild/chameleon/Cargo.toml +++ b/mock/wild/chameleon/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" name = "chameleon" [dependencies] -chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } honeybadger-mock = { path = "../honeybadger" } lazy_static = "1.4.0" rand = "0.8.5" diff --git a/mock/wild/crow/Cargo.toml b/mock/wild/crow/Cargo.toml index aef9800d..49fef256 100644 --- a/mock/wild/crow/Cargo.toml +++ b/mock/wild/crow/Cargo.toml @@ -7,9 +7,10 @@ edition = "2021" name = "crow" [dependencies] -crow = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +crow = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } honeybadger-mock = { path = "../honeybadger" } isocountry = { version = "0.3.2" } isolanguage-1 = { version = "0.2.2" } lazy_static = "1.4.0" +uuid = { version = "1.11.0", features = ["v4"] } diff --git a/mock/wild/crow/src/lib.rs b/mock/wild/crow/src/lib.rs index 1f1c3393..b65868c3 100644 --- a/mock/wild/crow/src/lib.rs +++ b/mock/wild/crow/src/lib.rs @@ -6,15 +6,19 @@ use std::time::{Duration, SystemTime}; pub use isocountry::CountryCode; pub use isolanguage_1::LanguageCode; +pub use crow::FiatTopupSetupChallenge; +pub use crow::FiatTopupSetupInfo; pub use crow::PermanentFailureCode; pub use crow::TemporaryFailureCode; pub use crow::TopupError; pub use crow::TopupInfo; pub use crow::TopupStatus; use lazy_static::lazy_static; +use uuid::Uuid; lazy_static! { static ref TOPUPS: Mutex> = Mutex::new(Vec::new()); + static ref EMAIL: Mutex> = Mutex::new(None); } const REFUND_EMAIL: &str = "refund@top.up"; @@ -27,15 +31,34 @@ impl OfferManager { Self {} } - pub fn register_topup( + pub fn start_topup_setup( &self, - order_id: String, + _node_pubkey: String, + _provider: String, + _source_iban: String, + _user_currency: String, email: Option, - _referral: Option, - ) -> graphql::Result<()> { + _referral_code: Option, + ) -> graphql::Result { + let mut stored_email = EMAIL.lock().unwrap(); + *stored_email = email; + + Ok(FiatTopupSetupChallenge { + id: "id".to_string(), + challenge: "challenge".to_string(), + }) + } + + pub fn complete_topup_setup( + &self, + id: String, + _signed_challenge: String, + _source_iban: String, + ) -> graphql::Result { let mut status = TopupStatus::READY; - if let Some(email) = email { + let stored_email = EMAIL.lock().unwrap(); + if let Some(email) = stored_email.as_ref() { match email.as_str() { REFUND_EMAIL => status = TopupStatus::REFUNDED, FAIL_EMAIL => status = TopupStatus::FAILED, @@ -44,7 +67,7 @@ impl OfferManager { } TOPUPS.lock().unwrap().push(TopupInfo { - id: order_id, + id, status, amount_sat: 30_000, topup_value_minor_units: 20_00, // 20 EUR @@ -60,7 +83,24 @@ impl OfferManager { error: None, }); - Ok(()) + Ok(FiatTopupSetupInfo { + order_id: Uuid::new_v4().to_string(), + debitor_iban: "Mock debitor_iban".to_string(), + creditor_reference: "Mock creditor_reference".to_string(), + creditor_iban: "Mock creditor_iban".to_string(), + creditor_bank_name: "Mock creditor_bank_name".to_string(), + creditor_bank_street: "Mock creditor_bank_street".to_string(), + creditor_bank_postal_code: "Mock creditor_bank_postal_code".to_string(), + creditor_bank_town: "Mock creditor_bank_town".to_string(), + creditor_bank_country: "Mock creditor_bank_country".to_string(), + creditor_bank_bic: "Mock creditor_bank_bic".to_string(), + creditor_name: "Mock creditor_name".to_string(), + creditor_street: "Mock creditor_street".to_string(), + creditor_postal_code: "Mock creditor_postal_code".to_string(), + creditor_town: "Mock creditor_town".to_string(), + creditor_country: "Mock creditor_country".to_string(), + currency: "Mock currency".to_string(), + }) } pub fn register_notification_token( diff --git a/mock/wild/honeybadger/Cargo.toml b/mock/wild/honeybadger/Cargo.toml index cf7e7400..20450598 100644 --- a/mock/wild/honeybadger/Cargo.toml +++ b/mock/wild/honeybadger/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" name = "honeybadger" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } -honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } +honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } rand = "0.8.5" secp256k1 = { version = "0.27.0", features = ["global-context"] } tokio = "1.37.0" diff --git a/mock/wild/parrot/Cargo.toml b/mock/wild/parrot/Cargo.toml index 07b340ec..7d303d9a 100644 --- a/mock/wild/parrot/Cargo.toml +++ b/mock/wild/parrot/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" name = "parrot" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } honeybadger-mock = { path = "../honeybadger" } -parrot = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +parrot = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } diff --git a/mock/wild/pigeon/Cargo.toml b/mock/wild/pigeon/Cargo.toml index f78de1ca..6d33613a 100644 --- a/mock/wild/pigeon/Cargo.toml +++ b/mock/wild/pigeon/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" name = "pigeon" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } honeybadger-mock = { path = "../honeybadger" } lazy_static = "1.4.0" diff --git a/mock/wild/squirrel/Cargo.toml b/mock/wild/squirrel/Cargo.toml index b5a00b6c..67a6e636 100644 --- a/mock/wild/squirrel/Cargo.toml +++ b/mock/wild/squirrel/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" name = "squirrel" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } honeybadger-mock = { path = "../honeybadger" } -squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" } +squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" } diff --git a/pocketclient/Cargo.toml b/pocketclient/Cargo.toml deleted file mode 100644 index 7ad66096..00000000 --- a/pocketclient/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "pocketclient" -version = "0.1.0" -edition = "2021" - -[dependencies] -chrono = { version = "0.4.38", default-features = false, features = ["serde"] } -log = "0.4.22" -perro = { git = "https://github.com/getlipa/perro", tag = "v1.2.0" } -reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } -serde = { version = "1.0", features = ["derive"] } diff --git a/pocketclient/src/lib.rs b/pocketclient/src/lib.rs deleted file mode 100644 index 9121f295..00000000 --- a/pocketclient/src/lib.rs +++ /dev/null @@ -1,271 +0,0 @@ -use chrono::{DateTime, Utc}; -use perro::{ensure, runtime_error, MapToError, OptionToError}; -use reqwest::StatusCode; -use serde::{Deserialize, Serialize}; -use std::fmt::{Display, Formatter}; -use std::future::Future; -use std::time::Duration; - -/// Information about a fiat top-up registration -#[derive(Debug, Clone, PartialEq)] -pub struct FiatTopupInfo { - pub order_id: String, - /// The user should transfer fiat from this IBAN - pub debitor_iban: String, - /// This reference should be included in the fiat transfer reference - pub creditor_reference: String, - /// The user should transfer fiat to this IBAN - pub creditor_iban: String, - pub creditor_bank_name: String, - pub creditor_bank_street: String, - pub creditor_bank_postal_code: String, - pub creditor_bank_town: String, - pub creditor_bank_country: String, - pub creditor_bank_bic: String, - pub creditor_name: String, - pub creditor_street: String, - pub creditor_postal_code: String, - pub creditor_town: String, - pub creditor_country: String, - pub currency: String, -} - -impl FiatTopupInfo { - fn from_pocket_create_order_response(create_order_response: CreateOrderResponse) -> Self { - FiatTopupInfo { - order_id: create_order_response.id, - debitor_iban: create_order_response.payment_method.debitor_iban, - creditor_reference: create_order_response.payment_method.creditor_reference, - creditor_iban: create_order_response.payment_method.creditor_iban, - creditor_bank_name: create_order_response.payment_method.creditor_bank_name, - creditor_bank_street: create_order_response.payment_method.creditor_bank_street, - creditor_bank_postal_code: create_order_response - .payment_method - .creditor_bank_postal_code, - creditor_bank_town: create_order_response.payment_method.creditor_bank_town, - creditor_bank_country: create_order_response.payment_method.creditor_bank_country, - creditor_bank_bic: create_order_response.payment_method.creditor_bank_bic, - creditor_name: create_order_response.payment_method.creditor_name, - creditor_street: create_order_response.payment_method.creditor_street, - creditor_postal_code: create_order_response.payment_method.creditor_postal_code, - creditor_town: create_order_response.payment_method.creditor_town, - creditor_country: create_order_response.payment_method.creditor_country, - currency: create_order_response.payment_method.currency, - } - } -} - -#[allow(dead_code)] -#[derive(Debug, Deserialize)] -struct ChallengeResponse { - id: String, - token: String, - expires_on: Option>, - completed_on: Option>, -} - -#[derive(Debug, Serialize)] -struct PaymentMethodRequest { - currency: String, - debitor_iban: String, -} - -#[derive(Debug, Serialize, Deserialize)] -struct PayoutMethod { - node_pubkey: String, - message: String, - signature: String, -} - -#[derive(Debug, Serialize)] -struct CreateOrderRequest { - active: bool, - #[serde(skip_serializing_if = "Option::is_none")] - affiliate_id: Option, - payment_method: PaymentMethodRequest, - payout_method: PayoutMethod, -} - -#[allow(dead_code)] -#[derive(Debug, Deserialize)] -struct PaymentMethodResponse { - currency: String, - debitor_iban: String, - creditor_reference: String, - creditor_iban: String, - creditor_bank_name: String, - creditor_bank_street: String, - creditor_bank_postal_code: String, - creditor_bank_town: String, - creditor_bank_country: String, - creditor_bank_bic: String, - creditor_name: String, - creditor_street: String, - creditor_postal_code: String, - creditor_town: String, - creditor_country: String, -} - -#[allow(dead_code)] -#[derive(Debug, Deserialize)] -pub struct CreateOrderResponse { - id: String, - active: bool, - created_on: Option>, - affiliate_id: Option, - fee_rate: f64, - payment_method: PaymentMethodResponse, - payout_method: PayoutMethod, -} - -pub struct PocketClient { - pocket_url: String, - client: reqwest::Client, -} - -/// A code that specifies the Pocket client error that occurred -#[derive(Debug, PartialEq, Eq)] -pub enum PocketClientErrorCode { - ServiceUnavailable, - UnexpectedResponse, - SignerFailure, -} - -impl Display for PocketClientErrorCode { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{self:?}") - } -} - -pub type PocketClientError = perro::Error; -pub type Result = std::result::Result; - -impl PocketClient { - pub fn new(pocket_url: String) -> Result { - let client = reqwest::Client::builder() - .timeout(Duration::from_secs(20)) - .build() - .map_to_permanent_failure("Failed to build a Pocket Client instance")?; - Ok(Self { pocket_url, client }) - } - - pub async fn register_pocket_fiat_topup( - &self, - user_iban: &str, - user_currency: String, - node_pubkey: String, - sign_message: S, - ) -> Result - where - S: FnOnce(String) -> Fut, - Fut: Future>, - { - let challenge_response = self.request_challenge().await?; - - let create_order_response = self - .create_order( - challenge_response, - user_iban, - user_currency, - node_pubkey, - sign_message, - ) - .await?; - - Ok(FiatTopupInfo::from_pocket_create_order_response( - create_order_response, - )) - } - - async fn request_challenge(&self) -> Result { - let raw_response = self - .client - .post(format!("{}/v1/challenges", self.pocket_url)) - .send() - .await - .map_to_runtime_error( - PocketClientErrorCode::ServiceUnavailable, - "Failed to get a response from the Pocket API", - )?; - - ensure!( - raw_response.status() == StatusCode::CREATED, - runtime_error( - PocketClientErrorCode::UnexpectedResponse, - "Got unexpected response to Pocket challenge request" - ) - ); - - raw_response - .json::() - .await - .map_to_runtime_error( - PocketClientErrorCode::UnexpectedResponse, - "Failed to parse ChallengeResponse", - ) - } - - async fn create_order( - &self, - challenge_response: ChallengeResponse, - user_iban: &str, - user_currency: String, - node_pubkey: String, - sign_message: S, - ) -> Result - where - S: FnOnce(String) -> Fut, - Fut: Future>, - { - let message = format!( - "I confirm my bitcoin wallet. [{}]", - challenge_response.token - ); - - let signature = sign_message(message.clone()).await.ok_or_runtime_error( - PocketClientErrorCode::SignerFailure, - "Failed to create signature", - )?; - - let create_order_request = CreateOrderRequest { - active: true, - affiliate_id: None, - payment_method: PaymentMethodRequest { - currency: user_currency.to_lowercase(), - debitor_iban: user_iban.to_string(), - }, - payout_method: PayoutMethod { - node_pubkey, - message, - signature, - }, - }; - - let raw_response = self - .client - .post(format!("{}/v1/orders", self.pocket_url)) - .json(&create_order_request) - .send() - .await - .map_to_runtime_error( - PocketClientErrorCode::ServiceUnavailable, - "Failed to get a response from the Pocket API", - )?; - - ensure!( - raw_response.status() == StatusCode::CREATED, - runtime_error( - PocketClientErrorCode::UnexpectedResponse, - "Got unexpected response to Pocket order creation request" - ) - ); - - raw_response - .json::() - .await - .map_to_runtime_error( - PocketClientErrorCode::UnexpectedResponse, - "Failed to parse CreateOrderResponse", - ) - } -} diff --git a/src/data_store.rs b/src/data_store.rs index d12bb8c8..6428334d 100644 --- a/src/data_store.rs +++ b/src/data_store.rs @@ -3,8 +3,8 @@ use crate::errors::Result; use crate::migrations::migrate; use crate::{EnableStatus, ExchangeRate, OfferKind, PocketOfferError, TzConfig, UserPreferences}; -use crate::pocketclient::FiatTopupInfo; use chrono::{DateTime, Utc}; +use crow::FiatTopupSetupInfo; use crow::{PermanentFailureCode, TemporaryFailureCode}; use perro::MapToError; use rusqlite::{backup, params, Connection, OptionalExtension, Params, Row}; @@ -299,7 +299,7 @@ impl DataStore { .collect() } - pub fn store_fiat_topup_info(&self, fiat_topup_info: FiatTopupInfo) -> Result<()> { + pub fn store_fiat_topup_info(&self, fiat_topup_info: FiatTopupSetupInfo) -> Result<()> { let dt: DateTime = SystemTime::now().into(); self.conn .execute( @@ -322,7 +322,7 @@ impl DataStore { Ok(()) } - pub fn retrieve_latest_fiat_topup_info(&self) -> Result> { + pub fn retrieve_latest_fiat_topup_info(&self) -> Result> { let mut statement = self.conn.prepare( "SELECT order_id, debitor_iban, creditor_reference, creditor_iban, creditor_bank_name, creditor_bank_street, creditor_bank_postal_code, creditor_bank_town, creditor_bank_country, creditor_bank_bic, creditor_name, creditor_street, creditor_postal_code, creditor_town, creditor_country, currency FROM fiat_topup_info ORDER BY created_at DESC LIMIT 1", ).map_to_permanent_failure("Failed to prepare query latest fiat topup info statement")?; @@ -677,8 +677,8 @@ pub fn to_offer_error(code: Option) -> Option { }) } -fn fiat_topup_info_from_row(row: &Row) -> rusqlite::Result> { - Ok(Some(FiatTopupInfo { +fn fiat_topup_info_from_row(row: &Row) -> rusqlite::Result> { + Ok(Some(FiatTopupSetupInfo { order_id: row.get(0)?, debitor_iban: row.get(1)?, creditor_reference: row.get(2)?, @@ -705,7 +705,7 @@ mod tests { use crate::{EnableStatus, ExchangeRate, OfferKind, PocketOfferError, UserPreferences}; use crate::analytics::AnalyticsConfig; - use crate::pocketclient::FiatTopupInfo; + use crow::FiatTopupSetupInfo; use crow::TopupError::TemporaryFailure; use crow::{PermanentFailureCode, TemporaryFailureCode}; use std::fs; @@ -1242,7 +1242,7 @@ mod tests { assert_eq!(data_store.retrieve_latest_fiat_topup_info().unwrap(), None); - let mut fiat_topup_info = FiatTopupInfo { + let mut fiat_topup_info = FiatTopupSetupInfo { order_id: "961b8ee9-74cc-4844-9fe8-b02ce0702663".to_string(), debitor_iban: "CH4889144919566329178".to_string(), creditor_reference: "8584-9931-ABCD".to_string(), diff --git a/src/fiat_topup.rs b/src/fiat_topup.rs index cebed147..e8429df4 100644 --- a/src/fiat_topup.rs +++ b/src/fiat_topup.rs @@ -1,7 +1,6 @@ use crate::amount::{AsSats, ToAmount}; use crate::errors::Result; use crate::locker::Locker; -use crate::pocketclient::FiatTopupInfo; use crate::support::Support; use crate::{ filter_out_and_log_corrupted_activities, Activities, Activity, Amount, OfferInfo, OfferKind, @@ -11,6 +10,7 @@ use breez_sdk_core::{ parse, InputType, ListPaymentsRequest, LnUrlWithdrawRequest, PaymentStatus, PaymentTypeFilter, SignMessageRequest, }; +use crow::FiatTopupSetupInfo; use crow::TopupInfo; use email_address::EmailAddress; use honeybadger::{TermsAndConditions, TermsAndConditionsStatus}; @@ -70,16 +70,19 @@ impl FiatTopup { /// * `user_currency` - the fiat currency (ISO 4217 currency code) that will be sent for /// exchange. Not all are supported. A consumer of this library should find out about available /// ones using other sources. + /// * `provider` - a fiat topup provider id. + /// * `referral_code` - a code to be provided by users in order to get benefits, /// /// Requires network: **yes** pub fn register( &self, email: Option, - referral: Option, user_iban: String, user_currency: String, - ) -> Result { - debug!("fiat_topup().register() - called with - email: {email:?} - referral code: {referral:?} - user_iban: {user_iban} - user_currency: {user_currency:?}"); + provider: String, + referral_code: Option, + ) -> Result { + debug!("fiat_topup().register() - called with - email: {email:?} - user_iban: {user_iban} - user_currency: {user_currency:?} - provider: {provider} - referral code: {referral_code:?}"); user_iban .parse::() .map_to_invalid_input("Invalid user_iban")?; @@ -88,33 +91,50 @@ impl FiatTopup { EmailAddress::from_str(email).map_to_invalid_input("Invalid email")?; } - if let Some(referral) = referral.as_ref() { - let string_length = referral.len(); - if referral.len() > self.support.node_config.topup_referral_code_max_length as usize { + if let Some(referral_code) = referral_code.as_ref() { + let string_length = referral_code.len(); + if string_length > self.support.node_config.topup_referral_code_max_length as usize { invalid_input!("Invalid referral code [string length: {string_length}]"); } } - let sdk = Arc::clone(&self.support.sdk); - let sign_message = |message| async move { - sdk.sign_message(SignMessageRequest { message }) - .await - .ok() - .map(|r| r.signature) - }; - let topup_info = self + let challenge = self + .support + .offer_manager + .start_topup_setup( + self.support.get_node_info()?.node_pubkey, + provider, + user_iban.clone(), + user_currency, + email, + referral_code, + ) + .map_to_runtime_error( + RuntimeErrorCode::OfferServiceUnavailable, + "Failed to start fiat topup setup", + )?; + + let message = format!("I confirm my bitcoin wallet. [{}]", challenge.challenge); + let signature = self .support .rt .handle() - .block_on(self.support.fiat_topup_client.register_pocket_fiat_topup( - &user_iban, - user_currency, - self.support.get_node_info()?.node_pubkey, - sign_message, - )) + .block_on( + self.support + .sdk + .sign_message(SignMessageRequest { message }), + ) + .ok() + .map(|r| r.signature) + .ok_or_runtime_error(RuntimeErrorCode::NodeUnavailable, "Failed to sign message")?; + + let topup_info = self + .support + .offer_manager + .complete_topup_setup(challenge.id, signature, user_iban) .map_to_runtime_error( RuntimeErrorCode::OfferServiceUnavailable, - "Failed to register pocket fiat topup", + "Failed to complete fiat topup setup", )?; self.support @@ -122,11 +142,6 @@ impl FiatTopup { .lock_unwrap() .store_fiat_topup_info(topup_info.clone())?; - self.support - .offer_manager - .register_topup(topup_info.order_id.clone(), email, referral) - .map_runtime_error_to(RuntimeErrorCode::OfferServiceUnavailable)?; - Ok(topup_info) } @@ -140,10 +155,10 @@ impl FiatTopup { .clear_fiat_topup_info() } - /// Returns the latest [`FiatTopupInfo`] if the user has registered for the fiat topup. + /// Returns the latest [`FiatTopupSetupInfo`] if the user has registered for the fiat topup. /// /// Requires network: **no** - pub fn get_info(&self) -> Result> { + pub fn get_info(&self) -> Result> { self.support .data_store .lock_unwrap() diff --git a/src/lib.rs b/src/lib.rs index a84c5c5a..01adff61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -100,14 +100,7 @@ use crate::task_manager::TaskManager; use crate::util::unix_timestamp_to_system_time; pub use crate::util::Util; -#[cfg(not(feature = "mock-deps"))] -#[allow(clippy::single_component_path_imports)] -use pocketclient; -#[cfg(feature = "mock-deps")] -use pocketclient_mock as pocketclient; - -pub use crate::pocketclient::FiatTopupInfo; -use crate::pocketclient::PocketClient; +pub use crow::FiatTopupSetupInfo; pub use crate::actions_required::ActionsRequired; pub use crate::activities::Activities; @@ -489,13 +482,6 @@ impl LightningNode { Arc::clone(&auth), )); - let fiat_topup_client = - PocketClient::new(node_config.remote_services_config.pocket_url.clone()) - .map_to_runtime_error( - RuntimeErrorCode::OfferServiceUnavailable, - "Couldn't create a fiat topup client", - )?; - let persistence_encryption_key = derive_persistence_encryption_key(&strong_typed_seed)?; let backup_client = RemoteBackupClient::new( node_config.remote_services_config.backend_url.clone(), @@ -525,7 +511,6 @@ impl LightningNode { sdk: Arc::clone(&sdk), auth: Arc::clone(&auth), async_auth: Arc::clone(&async_auth), - fiat_topup_client, offer_manager: Arc::clone(&offer_manager), rt: Arc::clone(&rt), data_store: Arc::clone(&data_store), @@ -1048,30 +1033,6 @@ impl LightningNode { .map_runtime_error_to(RuntimeErrorCode::AuthServiceUnavailable) } - /// Register for fiat topups. Returns information that can be used by the user to transfer fiat - /// to the 3rd party exchange service. Once the 3rd party exchange receives funds, the user will - /// be able to withdraw sats using LNURL-w. - /// - /// Parameters: - /// * `email` - this email will be used to send status information about different topups - /// * `referral` - the referral code of another user - /// * `user_iban` - the user will send fiat from this iban - /// * `user_currency` - the fiat currency (ISO 4217 currency code) that will be sent for - /// exchange. Not all are supported. A consumer of this library should find out about available - /// ones using other sources. - /// - /// Requires network: **yes** - #[deprecated = "fiat_topup().register() should be used instead"] - pub fn register_fiat_topup( - &self, - email: Option, - user_iban: String, - user_currency: String, - ) -> Result { - self.fiat_topup - .register(email, None, user_iban, user_currency) - } - /// Resets a previous fiat topups registration. /// /// Requires network: **no** @@ -1464,11 +1425,11 @@ impl LightningNode { self.util.log_debug_info() } - /// Returns the latest [`FiatTopupInfo`] if the user has registered for the fiat topup. + /// Returns the latest [`FiatTopupSetupInfo`] if the user has registered for the fiat topup. /// /// Requires network: **no** #[deprecated = "fiat_topup().get_info() should be used instead"] - pub fn retrieve_latest_fiat_topup_info(&self) -> Result> { + pub fn retrieve_latest_fiat_topup_info(&self) -> Result> { self.fiat_topup.get_info() } diff --git a/src/lipalightninglib.udl b/src/lipalightninglib.udl index 459ebe76..446bf836 100644 --- a/src/lipalightninglib.udl +++ b/src/lipalightninglib.udl @@ -84,9 +84,6 @@ interface LightningNode { [Throws=LnError] TermsAndConditionsStatus get_terms_and_conditions_status(TermsAndConditions terms_and_conditions); - [Throws=LnError] - FiatTopupInfo register_fiat_topup(string? email, string user_iban, string user_currency); - [Throws=LnError] void reset_fiat_topup(); @@ -157,7 +154,7 @@ interface LightningNode { void log_debug_info(); [Throws=LnError] - FiatTopupInfo? retrieve_latest_fiat_topup_info(); + FiatTopupSetupInfo? retrieve_latest_fiat_topup_info(); [Throws=LnError] BreezHealthCheckStatus get_health_status(); @@ -285,13 +282,13 @@ interface FiatTopup { TermsAndConditionsStatus query_tc_status(); [Throws=LnError] - FiatTopupInfo register(string? email, string? referral_code, string user_iban, string user_currency); + FiatTopupSetupInfo register(string? email, string user_iban, string user_currency, string provider, string? referral_code); [Throws=LnError] void reset(); [Throws=LnError] - FiatTopupInfo? get_info(); + FiatTopupSetupInfo? get_info(); [Throws=LnError] Amount calculate_payout_fee(OfferInfo offer); @@ -719,7 +716,7 @@ dictionary Amount { FiatValue? fiat; }; -dictionary FiatTopupInfo { +dictionary FiatTopupSetupInfo { string order_id; string debitor_iban; string creditor_reference; diff --git a/src/support.rs b/src/support.rs index 30c990a0..65b813b3 100644 --- a/src/support.rs +++ b/src/support.rs @@ -5,7 +5,6 @@ use crate::data_store::DataStore; use crate::errors::Result; use crate::locker::Locker; use crate::phone_number::PhoneNumberPrefixParser; -use crate::pocketclient::PocketClient; use crate::task_manager::TaskManager; use crate::util::LogIgnoreError; use crate::{ @@ -28,7 +27,6 @@ pub(crate) struct Support { pub sdk: Arc, pub auth: Arc, pub async_auth: Arc, - pub fiat_topup_client: PocketClient, pub offer_manager: Arc, pub rt: Arc, pub data_store: Arc>, diff --git a/tests/topup_test.rs b/tests/topup_test.rs index 525852dc..02a17972 100644 --- a/tests/topup_test.rs +++ b/tests/topup_test.rs @@ -16,27 +16,30 @@ fn test_topup() { node.fiat_topup() .register( None, - Some("123456789".to_string()), "CH8689144834469929874".to_string(), "CHF".to_string(), + "pocket".to_string(), + None, ) .expect("Couldn't register topup without email"); node.fiat_topup() .register( Some("alice-topup@integration.lipa.swiss".to_string()), + "CH0389144436836555818".to_string(), + "chf".to_string(), + "pocket".to_string(), None, - "CH8689144834469929874".to_string(), - "CHF".to_string(), ) .expect("Couldn't register topup without referral code"); node.fiat_topup() .register( Some("alice-topup@integration.lipa.swiss".to_string()), - None, "CH0389144436836555818".to_string(), "chf".to_string(), + "pocket".to_string(), + None, ) .expect("Couldn't register topup with email and referral code"); @@ -44,35 +47,39 @@ fn test_topup() { assert!(too_long_referral_code.len() > setup::MAX_REFERRAL_CODE_LENGTH as usize); let result = node.fiat_topup().register( Some("alice-topup@integration.lipa.swiss".to_string()), - Some(too_long_referral_code), "CH9289144414389576442".to_string(), "chf".to_string(), + "pocket".to_string(), + Some(too_long_referral_code), ); assert!(matches!(result, Err(InvalidInput { .. }))); node.fiat_topup() .register( Some("alice-topup@integration.lipa.swiss".to_string()), - Some("123456789".to_string()), "CH9289144414389576442".to_string(), "chf".to_string(), + "pocket".to_string(), + Some("123456789".to_string()), ) .expect("Couldn't register second topup with used email"); node.fiat_topup() .register( Some("alice-topup2@integration.lipa.swiss".to_string()), - None, "CH9289144414389576442".to_string(), "chf".to_string(), + "pocket".to_string(), + None, ) .expect("Couldn't re-register topup with different email"); let result = node.fiat_topup().register( Some("alice-topup@integration.lipa.swiss".to_string()), - None, "INVALID_IBAN".to_string(), "chf".to_string(), + "pocket".to_string(), + None, ); assert!(matches!(result, Err(InvalidInput { .. }))); @@ -84,10 +91,11 @@ fn test_topup() { // `DK1125112511251125` triggers a new topup ready to be collected node.fiat_topup() .register( - None, None, "DK1125112511251125".to_string(), "eur".to_string(), + "pocket".to_string(), + None, ) .unwrap(); @@ -118,9 +126,10 @@ fn test_topup() { node.fiat_topup() .register( Some("refund@top.up".to_string()), - None, "DK2225222522252225".to_string(), "eur".to_string(), + "pocket".to_string(), + None, ) .unwrap();