diff --git a/README.md b/README.md index 5f072d729..e02324474 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Breez-SDK Liquid +# Liquid Swap SDK -- `lib`: [lib/README.md](lib/README.md) +- `lib`: [lib/README.md](lib/ls-sdk-core/README.md) - `cli`: [cli/README.md](cli/README.md) ## Roadmap diff --git a/cli/Cargo.lock b/cli/Cargo.lock index bd912e945..5031628c4 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anstream" @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "atty" @@ -216,9 +216,9 @@ dependencies = [ [[package]] name = "bitcoin" -version = "0.31.1" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd00f3c09b5f21fb357abe32d29946eb8bb7a0862bae62c0b5e4a692acbbe73c" +checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" dependencies = [ "base64 0.21.7", "bech32 0.10.0-beta", @@ -289,7 +289,7 @@ version = "0.1.3" source = "git+https://github.com/SatoshiPortal/boltz-rust?rev=e55b8439f3311be7fcd18ec14a5747d0f3dbd74f#e55b8439f3311be7fcd18ec14a5747d0f3dbd74f" dependencies = [ "bip39", - "bitcoin 0.31.1", + "bitcoin 0.31.2", "electrum-client", "elements", "env_logger 0.7.1", @@ -302,44 +302,11 @@ dependencies = [ "url", ] -[[package]] -name = "breez-sdk-liquid" -version = "0.0.1" -dependencies = [ - "anyhow", - "bip39", - "boltz-client", - "log", - "lwk_common", - "lwk_signer", - "lwk_wollet", - "rusqlite", - "rusqlite_migration", - "serde", - "thiserror", -] - -[[package]] -name = "breez-sdk-liquid-cli" -version = "0.0.1" -dependencies = [ - "anyhow", - "bip39", - "breez-sdk-liquid", - "clap", - "env_logger 0.11.3", - "log", - "qr2term", - "rustyline", - "serde", - "serde_json", -] - [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -355,9 +322,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" [[package]] name = "cfg-if" @@ -535,7 +502,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89008f106be6f303695522f2f4c1f28b40c3e8367ed8b3bb227f1f882cb52cc2" dependencies = [ - "bitcoin 0.31.1", + "bitcoin 0.31.2", "byteorder", "libc", "log", @@ -552,7 +519,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6b8388053196e6b2702a45418078a654680ce9e1fd91799f51f67a40118ff5" dependencies = [ - "bitcoin 0.31.1", + "bitcoin 0.31.2", "secp256k1-zkp", "serde", "serde_json", @@ -564,7 +531,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73842aeed05c6d62a985672f651914080e6f1cedced5ea194405f5b5f838f6dd" dependencies = [ - "bitcoin 0.31.1", + "bitcoin 0.31.2", "elements", "miniscript", "serde", @@ -572,9 +539,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -813,9 +780,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -832,9 +799,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -1140,6 +1107,39 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "ls-sdk" +version = "0.0.1" +dependencies = [ + "anyhow", + "bip39", + "boltz-client", + "log", + "lwk_common", + "lwk_signer", + "lwk_wollet", + "rusqlite", + "rusqlite_migration", + "serde", + "thiserror", +] + +[[package]] +name = "ls-sdk-cli" +version = "0.0.1" +dependencies = [ + "anyhow", + "bip39", + "clap", + "env_logger 0.11.3", + "log", + "ls-sdk", + "qr2term", + "rustyline", + "serde", + "serde_json", +] + [[package]] name = "lwk_common" version = "0.3.0" @@ -1232,7 +1232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86a23dd3ad145a980e231185d114399f25a0a307d2cd918010ddda6334323df9" dependencies = [ "bech32 0.10.0-beta", - "bitcoin 0.31.1", + "bitcoin 0.31.2", "bitcoin-internals", ] @@ -1247,9 +1247,9 @@ dependencies = [ [[package]] name = "minreq" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3371dfc7b772c540da1380123674a8e20583aca99907087d990ca58cf44203" +checksum = "00a000cf8bbbfb123a9bdc66b61c2885a4bb038df4f2629884caafabeb76b0f9" dependencies = [ "log", "once_cell", @@ -1374,9 +1374,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -1440,9 +1440,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1510,9 +1510,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1867,9 +1867,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -1880,9 +1880,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -2024,9 +2024,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" @@ -2036,9 +2036,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -2130,9 +2130,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 19d444326..5ed0f25c7 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "breez-sdk-liquid-cli" +name = "ls-sdk-cli" edition = "2021" version = "0.0.1" @@ -8,10 +8,10 @@ version = "0.0.1" [dependencies] anyhow = "1.0.80" bip39 = "2.0.0" -breez-sdk-liquid = { path = "../lib" } clap = { version = "4.5.1", features = ["derive"] } env_logger = "0.11" log = "0.4.20" +ls-sdk = { path = "../lib/ls-sdk-core" } qr2term = "0.3.1" rustyline = { version = "13.0.0", features = ["derive"] } serde = { version = "1.0.197", features = ["derive"] } diff --git a/cli/src/commands.rs b/cli/src/commands.rs index ff80fa551..71a7bf55c 100644 --- a/cli/src/commands.rs +++ b/cli/src/commands.rs @@ -5,12 +5,11 @@ use std::time::Duration; use anyhow::Result; use clap::{arg, Parser}; +use ls_sdk::{ReceivePaymentRequest, Wallet}; use rustyline::highlight::Highlighter; use rustyline::history::DefaultHistory; use rustyline::Editor; use rustyline::{hint::HistoryHinter, Completer, Helper, Hinter, Validator}; - -use breez_sdk_liquid::{ReceivePaymentRequest, Wallet}; use serde::Serialize; use serde_json::to_string_pretty; diff --git a/cli/src/main.rs b/cli/src/main.rs index f8bfc8b1f..4d153bdff 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -4,10 +4,10 @@ mod persist; use std::{fs, path::PathBuf}; use anyhow::{anyhow, Result}; -use breez_sdk_liquid::{Network, Wallet}; use clap::Parser; use commands::{handle_command, CliHelper, Command, CommandResult}; use log::{error, info}; +use ls_sdk::{Network, Wallet}; use persist::CliPersistence; use rustyline::{error::ReadlineError, hint::HistoryHinter, Editor}; diff --git a/lib/Cargo.lock b/lib/Cargo.lock index e447a1984..7794718c7 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -76,15 +76,104 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" + +[[package]] +name = "askama" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28" +dependencies = [ + "askama_derive", + "askama_escape", +] + +[[package]] +name = "askama_derive" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83" +dependencies = [ + "askama_parser", + "basic-toml", + "mime", + "mime_guess", + "proc-macro2", + "quote", + "serde", + "syn", +] + +[[package]] +name = "askama_escape" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" + +[[package]] +name = "askama_parser" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0" +dependencies = [ + "nom", +] [[package]] name = "atty" @@ -130,6 +219,15 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "basic-toml" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "823388e228f614e9558c6804262db37960ec8821856535f5c3f59913140558f8" +dependencies = [ + "serde", +] + [[package]] name = "bech32" version = "0.9.1" @@ -142,6 +240,15 @@ version = "0.10.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bip39" version = "2.0.0" @@ -168,9 +275,9 @@ dependencies = [ [[package]] name = "bitcoin" -version = "0.31.1" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd00f3c09b5f21fb357abe32d29946eb8bb7a0862bae62c0b5e4a692acbbe73c" +checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" dependencies = [ "base64 0.21.7", "bech32 0.10.0-beta", @@ -241,7 +348,7 @@ version = "0.1.3" source = "git+https://github.com/SatoshiPortal/boltz-rust?rev=e55b8439f3311be7fcd18ec14a5747d0f3dbd74f#e55b8439f3311be7fcd18ec14a5747d0f3dbd74f" dependencies = [ "bip39", - "bitcoin 0.31.1", + "bitcoin 0.31.2", "electrum-client", "elements", "env_logger", @@ -254,30 +361,11 @@ dependencies = [ "url", ] -[[package]] -name = "breez-sdk-liquid" -version = "0.0.1" -dependencies = [ - "anyhow", - "bip39", - "boltz-client", - "log", - "lwk_common", - "lwk_signer", - "lwk_wollet", - "rusqlite", - "rusqlite_migration", - "serde", - "tempdir", - "thiserror", - "uuid", -] - [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -291,11 +379,43 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" [[package]] name = "cfg-if" @@ -312,6 +432,52 @@ dependencies = [ "generic-array", ] +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "core-foundation" version = "0.9.4" @@ -387,7 +553,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89008f106be6f303695522f2f4c1f28b40c3e8367ed8b3bb227f1f882cb52cc2" dependencies = [ - "bitcoin 0.31.1", + "bitcoin 0.31.2", "byteorder", "libc", "log", @@ -404,7 +570,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6b8388053196e6b2702a45418078a654680ce9e1fd91799f51f67a40118ff5" dependencies = [ - "bitcoin 0.31.1", + "bitcoin 0.31.2", "secp256k1-zkp", "serde", "serde_json", @@ -416,7 +582,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73842aeed05c6d62a985672f651914080e6f1cedced5ea194405f5b5f838f6dd" dependencies = [ - "bitcoin 0.31.1", + "bitcoin 0.31.2", "elements", "miniscript", "serde", @@ -424,9 +590,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -518,6 +684,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] + [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -625,9 +800,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -642,11 +817,28 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "goblin" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb07a4ffed2093b118a525b1d8f5204ae274faed5604537caf7135d0f18d9887" +dependencies = [ + "log", + "plain", + "scroll", +] + [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -686,6 +878,18 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -931,6 +1135,35 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "ls-sdk" +version = "0.0.1" +dependencies = [ + "anyhow", + "bip39", + "boltz-client", + "log", + "lwk_common", + "lwk_signer", + "lwk_wollet", + "rusqlite", + "rusqlite_migration", + "serde", + "tempdir", + "thiserror", + "uuid", +] + +[[package]] +name = "ls-sdk-bindings" +version = "0.0.1" +dependencies = [ + "anyhow", + "ls-sdk", + "thiserror", + "uniffi", +] + [[package]] name = "lwk_common" version = "0.3.0" @@ -1016,6 +1249,22 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniscript" version = "11.0.0" @@ -1023,7 +1272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86a23dd3ad145a980e231185d114399f25a0a307d2cd918010ddda6334323df9" dependencies = [ "bech32 0.10.0-beta", - "bitcoin 0.31.1", + "bitcoin 0.31.2", "bitcoin-internals", ] @@ -1038,9 +1287,9 @@ dependencies = [ [[package]] name = "minreq" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3371dfc7b772c540da1380123674a8e20583aca99907087d990ca58cf44203" +checksum = "00a000cf8bbbfb123a9bdc66b61c2885a4bb038df4f2629884caafabeb76b0f9" dependencies = [ "log", "once_cell", @@ -1080,6 +1329,16 @@ dependencies = [ "tempfile", ] +[[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 = "num-traits" version = "0.2.18" @@ -1104,6 +1363,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "oneshot-uniffi" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c548d5c78976f6955d72d0ced18c48ca07030f7a1d4024529fedd7c1c01b29c" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -1179,6 +1444,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1203,6 +1474,12 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + [[package]] name = "polyval" version = "0.5.3" @@ -1238,9 +1515,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1515,6 +1792,26 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scroll" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sct" version = "0.7.1" @@ -1588,9 +1885,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -1601,14 +1898,23 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", ] +[[package]] +name = "semver" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +dependencies = [ + "serde", +] + [[package]] name = "serde" version = "1.0.197" @@ -1682,6 +1988,12 @@ dependencies = [ "digest", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -1697,6 +2009,12 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "socket2" version = "0.5.6" @@ -1713,6 +2031,18 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.4.1" @@ -1721,9 +2051,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -1788,6 +2118,17 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.58" @@ -1862,6 +2203,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -1931,6 +2281,15 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -1943,6 +2302,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -1952,6 +2317,145 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "uniffi" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5566fae48a5cb017005bf9cd622af5236b2a203a13fb548afde3506d3c68277" +dependencies = [ + "anyhow", + "camino", + "clap", + "uniffi_bindgen", + "uniffi_build", + "uniffi_core", + "uniffi_macros", +] + +[[package]] +name = "uniffi_bindgen" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a77bb514bcd4bf27c9bd404d7c3f2a6a8131b957eba9c22cfeb7751c4278e09" +dependencies = [ + "anyhow", + "askama", + "camino", + "cargo_metadata", + "clap", + "fs-err", + "glob", + "goblin", + "heck 0.4.1", + "once_cell", + "paste", + "serde", + "textwrap", + "toml", + "uniffi_meta", + "uniffi_testing", + "uniffi_udl", +] + +[[package]] +name = "uniffi_build" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45cba427aeb7b3a8b54830c4c915079a7a3c62608dd03dddba1d867a8a023eb4" +dependencies = [ + "anyhow", + "camino", + "uniffi_bindgen", +] + +[[package]] +name = "uniffi_checksum_derive" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae7e5a6c33b1dec3f255f57ec0b6af0f0b2bb3021868be1d5eec7a38e2905ebc" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "uniffi_core" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea3eb5474d50fc149b7e4d86b9c5bd4a61dcc167f0683902bf18ae7bbb3deef" +dependencies = [ + "anyhow", + "bytes", + "camino", + "log", + "once_cell", + "oneshot-uniffi", + "paste", + "static_assertions", +] + +[[package]] +name = "uniffi_macros" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18331d35003f46f0d04047fbe4227291815b83a937a8c32bc057f990962182c4" +dependencies = [ + "bincode", + "camino", + "fs-err", + "once_cell", + "proc-macro2", + "quote", + "serde", + "syn", + "toml", + "uniffi_meta", +] + +[[package]] +name = "uniffi_meta" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7224422c4cfd181c7ca9fca2154abca4d21db962f926f270f996edd38b0c4b8" +dependencies = [ + "anyhow", + "bytes", + "siphasher", + "uniffi_checksum_derive", +] + +[[package]] +name = "uniffi_testing" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ce878d0bdfc288b58797044eaaedf748526c56eef3575380bb4d4b19d69eee" +dependencies = [ + "anyhow", + "camino", + "cargo_metadata", + "fs-err", + "once_cell", +] + +[[package]] +name = "uniffi_udl" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c43c9ed40a8d20a5c3eae2d23031092db6b96dc8e571beb449ba9757484cea0" +dependencies = [ + "anyhow", + "textwrap", + "uniffi_meta", + "uniffi_testing", + "weedle2", +] + [[package]] name = "universal-hash" version = "0.4.1" @@ -2003,6 +2507,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "1.8.0" @@ -2136,6 +2646,15 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "weedle2" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e" +dependencies = [ + "nom", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 3ed74c8f8..b84e00b52 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -1,28 +1,18 @@ -[package] -name = "breez-sdk-liquid" -edition = "2021" -version = "0.0.1" - -[lib] -name = "breez_sdk_liquid" -crate-type = ["staticlib", "cdylib", "lib"] +[workspace] +members = [ + "ls-sdk-bindings", + "ls-sdk-core", +] +resolver = "2" -[dependencies] -anyhow = "1.0.80" -bip39 = { version = "2.0.0", features = ["serde"] } -boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", rev = "e55b8439f3311be7fcd18ec14a5747d0f3dbd74f" } -log = "0.4.20" -lwk_common = "0.3.0" -lwk_signer = "0.3.0" -lwk_wollet = "0.3.0" -rusqlite = "0.29" -rusqlite_migration = "1.0" -serde = { version = "1.0.197", features = ["derive"] } -thiserror = "1.0.57" +[workspace.package] +version = "0.0.1" -[dev-dependencies] -tempdir = "0.3.7" -uuid = { version = "1.8.0", features = ["v4"] } +[workspace.dependencies] +anyhow = "1.0" +thiserror = "1.0" +uniffi = "0.27.1" +uniffi_macros = "0.27.1" [patch.crates-io] -secp256k1-zkp = {git = "https://github.com/BlockstreamResearch/rust-secp256k1-zkp.git", rev = "60e631c24588a0c9e271badd61959294848c665d"} +secp256k1-zkp = {git = "https://github.com/BlockstreamResearch/rust-secp256k1-zkp.git", rev = "60e631c24588a0c9e271badd61959294848c665d"} \ No newline at end of file diff --git a/lib/ls-sdk-bindings/Cargo.toml b/lib/ls-sdk-bindings/Cargo.toml new file mode 100644 index 000000000..654942ad7 --- /dev/null +++ b/lib/ls-sdk-bindings/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "ls-sdk-bindings" +edition = "2021" +version.workspace = true + +[[bin]] +name = "uniffi-bindgen" +path = "uniffi-bindgen.rs" + +[lib] +name = "ls_sdk_bindings" +crate-type = ["staticlib", "cdylib", "lib"] + + +[dependencies] +anyhow = { workspace = true } +ls-sdk = { path = "../ls-sdk-core" } +uniffi = { workspace = true, features = [ "cli" ] } +thiserror = { workspace = true } + +[build-dependencies] +uniffi = { workspace = true, features = [ "build" ] } \ No newline at end of file diff --git a/lib/ls-sdk-bindings/README.md b/lib/ls-sdk-bindings/README.md new file mode 100644 index 000000000..e0bd771f1 --- /dev/null +++ b/lib/ls-sdk-bindings/README.md @@ -0,0 +1,9 @@ +To build the bindings: + +```bash +make kotlin + +make python + +make swift +``` \ No newline at end of file diff --git a/lib/ls-sdk-bindings/build.rs b/lib/ls-sdk-bindings/build.rs new file mode 100644 index 000000000..089a6a45c --- /dev/null +++ b/lib/ls-sdk-bindings/build.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::generate_scaffolding("src/ls_sdk.udl").unwrap(); +} diff --git a/lib/ls-sdk-bindings/makefile b/lib/ls-sdk-bindings/makefile new file mode 100644 index 000000000..3b748d5e3 --- /dev/null +++ b/lib/ls-sdk-bindings/makefile @@ -0,0 +1,17 @@ +SOURCES=$(sort $(wildcard ./src/*.rs ./src/**/*.rs)) + +TARGET ?= x86_64-unknown-linux-gnu + +all: python kotlin swift + +python: $(SOURCES) + cargo build --release --target $(TARGET) + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl --no-format --language python -o ffi/python + +kotlin: $(SOURCES) + cargo build --release --target $(TARGET) + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl --no-format --language kotlin -o ffi/kotlin + +swift: $(SOURCES) + cargo build --release --target $(TARGET) + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl --no-format --language swift -o ffi/swift diff --git a/lib/ls-sdk-bindings/src/lib.rs b/lib/ls-sdk-bindings/src/lib.rs new file mode 100644 index 000000000..c3bc714fd --- /dev/null +++ b/lib/ls-sdk-bindings/src/lib.rs @@ -0,0 +1,55 @@ +use std::sync::Arc; + +use anyhow::{Error, Result}; +use ls_sdk::{ + model::PaymentError, Network, PreparePaymentResponse, ReceivePaymentRequest, + ReceivePaymentResponse, SendPaymentResponse, Wallet, WalletInfo, +}; + +// TODO Unify error enum +#[derive(Debug, thiserror::Error)] +pub enum LsSdkError { + #[error("Error: {err}")] + Generic { err: String }, +} + +impl From for LsSdkError { + fn from(e: Error) -> Self { + LsSdkError::Generic { err: e.to_string() } + } +} + +pub fn init( + mnemonic: String, + data_dir: Option, + network: Network, +) -> Result, LsSdkError> { + let ln_sdk = Wallet::init(&mnemonic, data_dir, network)?; + Ok(Arc::from(BindingWallet { ln_sdk })) +} + +pub struct BindingWallet { + ln_sdk: Arc, +} + +impl BindingWallet { + pub fn get_info(&self, with_scan: bool) -> Result { + self.ln_sdk.get_info(with_scan).map_err(Into::into) + } + + pub fn send_payment( + &self, + req: PreparePaymentResponse, + ) -> Result { + self.ln_sdk.send_payment(&req) + } + + pub fn receive_payment( + &self, + req: ReceivePaymentRequest, + ) -> Result { + self.ln_sdk.receive_payment(req) + } +} + +uniffi::include_scaffolding!("ls_sdk"); diff --git a/lib/ls-sdk-bindings/src/ls_sdk.udl b/lib/ls-sdk-bindings/src/ls_sdk.udl new file mode 100644 index 000000000..940ddd154 --- /dev/null +++ b/lib/ls-sdk-bindings/src/ls_sdk.udl @@ -0,0 +1,63 @@ +[Error] +enum LsSdkError { + "Generic", +}; + +[Error] +enum PaymentError { + "AmountOutOfRange", + "InvalidInvoice", + "SendError", + "WalletError", + "PersistError", + "InvalidPreimage", + "AlreadyClaimed", + "BoltzError", +}; + +enum Network { + "Liquid", + "LiquidTestnet", +}; + +dictionary WalletInfo { + u64 balance_sat; + string pubkey; + string active_address; +}; + +dictionary PreparePaymentResponse { + string id; + u64 funding_amount; + string funding_address; +}; + +dictionary ReceivePaymentRequest { + u64? invoice_amount_sat; + u64? onchain_amount_sat; +}; + +dictionary ReceivePaymentResponse { + string id; + string invoice; +}; + +dictionary SendPaymentResponse { + string txid; +}; + +namespace ls_sdk { + [Throws=LsSdkError] + BindingWallet init(string mnemonic, string? data_dir, Network network); +}; + +interface BindingWallet { + [Throws=LsSdkError] + WalletInfo get_info(boolean with_scan); + + [Throws=PaymentError] + SendPaymentResponse send_payment(PreparePaymentResponse req); + + [Throws=PaymentError] + ReceivePaymentResponse receive_payment(ReceivePaymentRequest req); +}; \ No newline at end of file diff --git a/lib/ls-sdk-bindings/uniffi-bindgen.rs b/lib/ls-sdk-bindings/uniffi-bindgen.rs new file mode 100644 index 000000000..f6cff6cf1 --- /dev/null +++ b/lib/ls-sdk-bindings/uniffi-bindgen.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::uniffi_bindgen_main() +} diff --git a/lib/ls-sdk-bindings/uniffi.toml b/lib/ls-sdk-bindings/uniffi.toml new file mode 100644 index 000000000..e9f8571cb --- /dev/null +++ b/lib/ls-sdk-bindings/uniffi.toml @@ -0,0 +1,12 @@ +# https://mozilla.github.io/uniffi-rs/swift/configuration.html +[bindings.swift] +cdylib_name = "ls_sdk_bindings" + +# https://mozilla.github.io/uniffi-rs/kotlin/configuration.html +[bindings.kotlin] +package_name = "ls_sdk" +cdylib_name = "ls_sdk_bindings" + +# https://mozilla.github.io/uniffi-rs/python/configuration.html +[bindings.python] +cdylib_name = "ls_sdk_bindings" diff --git a/lib/ls-sdk-core/Cargo.toml b/lib/ls-sdk-core/Cargo.toml new file mode 100644 index 000000000..61cb460f2 --- /dev/null +++ b/lib/ls-sdk-core/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "ls-sdk" +edition = "2021" +version.workspace = true + +[lib] +name = "ls_sdk" + +[dependencies] +anyhow = { workspace = true } +bip39 = { version = "2.0.0", features = ["serde"] } +boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", rev = "e55b8439f3311be7fcd18ec14a5747d0f3dbd74f" } +log = "0.4.20" +lwk_common = "0.3.0" +lwk_signer = "0.3.0" +lwk_wollet = "0.3.0" +rusqlite = "0.29" +rusqlite_migration = "1.0" +serde = { version = "1.0.197", features = ["derive"] } +thiserror = { workspace = true } + +[dev-dependencies] +tempdir = "0.3.7" +uuid = { version = "1.8.0", features = ["v4"] } \ No newline at end of file diff --git a/lib/README.md b/lib/ls-sdk-core/README.md similarity index 100% rename from lib/README.md rename to lib/ls-sdk-core/README.md diff --git a/lib/src/lib.rs b/lib/ls-sdk-core/src/lib.rs similarity index 99% rename from lib/src/lib.rs rename to lib/ls-sdk-core/src/lib.rs index cf74b6f97..88bc5d82b 100644 --- a/lib/src/lib.rs +++ b/lib/ls-sdk-core/src/lib.rs @@ -1,4 +1,4 @@ -mod model; +pub mod model; mod persist; mod wallet; diff --git a/lib/src/model.rs b/lib/ls-sdk-core/src/model.rs similarity index 96% rename from lib/src/model.rs rename to lib/ls-sdk-core/src/model.rs index 90ce6207d..87f072459 100644 --- a/lib/src/model.rs +++ b/lib/ls-sdk-core/src/model.rs @@ -104,8 +104,8 @@ pub enum PaymentError { #[error("The specified funds have already been claimed")] AlreadyClaimed, - #[error("Generic boltz error: {err}")] - BoltzGeneric { err: String }, + #[error("Boltz error: {err}")] + BoltzError { err: String }, } impl From for PaymentError { @@ -116,9 +116,9 @@ impl From for PaymentError { return PaymentError::AlreadyClaimed; } - PaymentError::BoltzGeneric { err: msg } + PaymentError::BoltzError { err: msg } } - _ => PaymentError::BoltzGeneric { + _ => PaymentError::BoltzError { err: format!("{err:?}"), }, } diff --git a/lib/src/persist/migrations.rs b/lib/ls-sdk-core/src/persist/migrations.rs similarity index 100% rename from lib/src/persist/migrations.rs rename to lib/ls-sdk-core/src/persist/migrations.rs diff --git a/lib/src/persist/mod.rs b/lib/ls-sdk-core/src/persist/mod.rs similarity index 100% rename from lib/src/persist/mod.rs rename to lib/ls-sdk-core/src/persist/mod.rs diff --git a/lib/src/wallet.rs b/lib/ls-sdk-core/src/wallet.rs similarity index 99% rename from lib/src/wallet.rs rename to lib/ls-sdk-core/src/wallet.rs index bc770f916..172bb562f 100644 --- a/lib/src/wallet.rs +++ b/lib/ls-sdk-core/src/wallet.rs @@ -376,7 +376,7 @@ impl Wallet { // TODO The request should not allow setting both invoice and onchain amounts, so this case shouldn't be possible. // See example of how it's done in the SDK. - _ => Err(PaymentError::BoltzGeneric { + _ => Err(PaymentError::BoltzError { err: "Both invoice and onchain amounts were specified".into(), }), }?;