Integrate sdk-common (#308)

* Rename Network to LiquidSdkNetwork to avoid naming conflicts with sdk-common

* Integrate sdk-common: re-use parse_invoice

* Fix UDL bindings tests

* Add input parser support

* CLI: Add input parser support

* Integrate lnurl-pay

* Cargo format, re-generate FRB and RN bindings

* Duplicate LnUrlPayError, update FRB/UniFFI bindings

* Move duplicate LnUrlPayError to FRB bindings.rs

* Add support for lnurl-withdraw

* Lnurl-withdraw: convert units, incorporate fees

* Bump sdk-common, rename InputType::LnUrlError

* Bump sdk-common, remove Wrapped prefix from LnUrlPaySuccessData, LnUrlPayResult

* LNURL-withdraw: add missing UDL mappings

* Add support for LNURL-auth

* Move LNURL structs into models.rs

* Rename LiquidSdkNetwork to LiquidNetwork

* Fix binding tests

* Fix tests

* Move FRB mirroring structs to bindings.rs

* Remove TODO

* Bump sdk-common, remove sdk-common dependency on rusqlite

* Propagate LiquidNetwork rename into flutter example app

* CI: install protobuf before running clippy

* CI: add rust cache, protobuf for remaining rust steps
This commit is contained in:
ok300
2024-06-20 16:18:50 +00:00
committed by GitHub
parent 5dca068619
commit bcb4743260
38 changed files with 13122 additions and 657 deletions

View File

@@ -33,6 +33,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
lib -> target
cli -> target
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check Rust Clippy
run: |
cd lib
@@ -46,6 +59,18 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
lib -> target
cli -> target
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run sdk-core tests
working-directory: lib/core
run: cargo test
@@ -57,6 +82,18 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
lib -> target
cli -> target
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build bindings
working-directory: lib/bindings
run: cargo build

534
cli/Cargo.lock generated
View File

@@ -33,11 +33,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
dependencies = [
"cfg-if",
"cipher",
"cipher 0.3.0",
"cpufeatures",
"opaque-debug",
]
[[package]]
name = "aes"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
dependencies = [
"cfg-if",
"cipher 0.4.4",
"cpufeatures",
]
[[package]]
name = "aes-gcm-siv"
version = "0.10.1"
@@ -45,8 +56,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfde8146762f3c5f3c5cd41aa17a71f3188df09d5857192b658510d850e16068"
dependencies = [
"aead",
"aes",
"cipher",
"aes 0.7.5",
"cipher 0.3.0",
"ctr",
"polyval",
"subtle",
@@ -86,12 +97,6 @@ dependencies = [
"chrono",
]
[[package]]
name = "allocator-api2"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "android-tzdata"
version = "0.1.1"
@@ -183,6 +188,28 @@ dependencies = [
"backtrace",
]
[[package]]
name = "async-stream"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51"
dependencies = [
"async-stream-impl",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-stream-impl"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.61",
]
[[package]]
name = "async-trait"
version = "0.1.80"
@@ -191,7 +218,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -223,6 +250,51 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "axum"
version = "0.6.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
dependencies = [
"async-trait",
"axum-core",
"bitflags 1.3.2",
"bytes",
"futures-util",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.29",
"itoa",
"matchit",
"memchr",
"mime",
"percent-encoding",
"pin-project-lite",
"rustversion",
"serde",
"sync_wrapper",
"tower",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum-core"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
dependencies = [
"async-trait",
"bytes",
"futures-util",
"http 0.2.12",
"http-body 0.4.6",
"mime",
"rustversion",
"tower-layer",
"tower-service",
]
[[package]]
name = "backtrace"
version = "0.3.71"
@@ -268,6 +340,16 @@ version = "0.10.0-beta"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea"
[[package]]
name = "bip21"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1998475af29ccfb7c761bb624a16e501fc321510366012bc9cce267bc134aedc"
dependencies = [
"bitcoin 0.29.2",
"percent-encoding-rfc3986",
]
[[package]]
name = "bip39"
version = "2.0.0"
@@ -281,6 +363,17 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "bitcoin"
version = "0.29.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3"
dependencies = [
"bech32 0.9.1",
"bitcoin_hashes 0.11.0",
"secp256k1 0.24.3",
]
[[package]]
name = "bitcoin"
version = "0.30.2"
@@ -372,6 +465,15 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block-padding"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
dependencies = [
"generic-array",
]
[[package]]
name = "bmp-monochrome"
version = "1.1.0"
@@ -388,7 +490,7 @@ dependencies = [
"electrum-client",
"elements",
"env_logger 0.7.1",
"lightning-invoice",
"lightning-invoice 0.30.0",
"log",
"native-tls",
"serde",
@@ -437,6 +539,7 @@ dependencies = [
"reqwest 0.11.20",
"rusqlite",
"rusqlite_migration",
"sdk-common",
"security-framework",
"security-framework-sys",
"serde",
@@ -478,6 +581,15 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
[[package]]
name = "cbc"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
dependencies = [
"cipher 0.4.4",
]
[[package]]
name = "cc"
version = "1.0.97"
@@ -513,6 +625,16 @@ dependencies = [
"generic-array",
]
[[package]]
name = "cipher"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
"crypto-common",
"inout",
]
[[package]]
name = "clap"
version = "4.5.4"
@@ -541,10 +663,10 @@ version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
dependencies = [
"heck",
"heck 0.5.0",
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -628,7 +750,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481"
dependencies = [
"cipher",
"cipher 0.3.0",
]
[[package]]
@@ -664,7 +786,7 @@ checksum = "51aac4c99b2e6775164b412ea33ae8441b2fde2dbf05a20bc0052a63d08c475b"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -677,6 +799,12 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "either"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
[[package]]
name = "electrum-client"
version = "0.19.0"
@@ -830,6 +958,12 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "fixedbitset"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flate2"
version = "1.0.30"
@@ -878,7 +1012,7 @@ dependencies = [
"md-5",
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -967,7 +1101,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -1056,7 +1190,7 @@ dependencies = [
"futures-sink",
"futures-util",
"http 0.2.12",
"indexmap",
"indexmap 2.2.6",
"slab",
"tokio",
"tokio-util",
@@ -1075,7 +1209,7 @@ dependencies = [
"futures-core",
"futures-sink",
"http 1.1.0",
"indexmap",
"indexmap 2.2.6",
"slab",
"tokio",
"tokio-util",
@@ -1088,6 +1222,12 @@ version = "1.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403"
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.5"
@@ -1095,18 +1235,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2",
]
[[package]]
name = "hashlink"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692eaaf7f7607518dd3cef090f1474b61edc5301d8012f09579920df68b725ee"
checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
dependencies = [
"hashbrown",
"hashbrown 0.14.5",
]
[[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"
@@ -1299,6 +1444,18 @@ dependencies = [
"tower-service",
]
[[package]]
name = "hyper-timeout"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
dependencies = [
"hyper 0.14.29",
"pin-project-lite",
"tokio",
"tokio-io-timeout",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
@@ -1375,6 +1532,16 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
]
[[package]]
name = "indexmap"
version = "2.2.6"
@@ -1382,7 +1549,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown",
"hashbrown 0.14.5",
]
[[package]]
name = "inout"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
dependencies = [
"block-padding",
"generic-array",
]
[[package]]
@@ -1406,6 +1583,15 @@ version = "1.70.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.11"
@@ -1444,6 +1630,15 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "lightning"
version = "0.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90a0f2155316f1570446a0447c993480673f840748c8ed25bbc59dfc442ac770"
dependencies = [
"bitcoin 0.29.2",
]
[[package]]
name = "lightning"
version = "0.0.122"
@@ -1454,6 +1649,20 @@ dependencies = [
"hex-conservative",
]
[[package]]
name = "lightning-invoice"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1788c0158526ec27a502043c2911ea6ea58fdc656bdf8749484942c07b790d23"
dependencies = [
"bech32 0.9.1",
"bitcoin 0.29.2",
"bitcoin_hashes 0.11.0",
"lightning 0.0.116",
"num-traits",
"secp256k1 0.24.3",
]
[[package]]
name = "lightning-invoice"
version = "0.30.0"
@@ -1462,7 +1671,7 @@ checksum = "106fdb897e69df697480f45bf0a564b425af488fb0f7407e770a770c39b19a21"
dependencies = [
"bech32 0.9.1",
"bitcoin 0.30.2",
"lightning",
"lightning 0.0.122",
"num-traits",
"secp256k1 0.27.0",
]
@@ -1563,6 +1772,12 @@ dependencies = [
"tracing",
]
[[package]]
name = "matchit"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "md-5"
version = "0.10.6"
@@ -1616,6 +1831,12 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "multimap"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]]
name = "native-tls"
version = "0.2.11"
@@ -1717,7 +1938,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -1790,6 +2011,22 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "percent-encoding-rfc3986"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3637c05577168127568a64e9dc5a6887da720efef07b3d9472d45f63ab191166"
[[package]]
name = "petgraph"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
dependencies = [
"fixedbitset",
"indexmap 2.2.6",
]
[[package]]
name = "pin-project"
version = "1.1.5"
@@ -1807,7 +2044,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -1846,6 +2083,16 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "prettyplease"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86"
dependencies = [
"proc-macro2",
"syn 1.0.109",
]
[[package]]
name = "proc-macro2"
version = "1.0.82"
@@ -1855,6 +2102,60 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "prost"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
dependencies = [
"bytes",
"prost-derive",
]
[[package]]
name = "prost-build"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270"
dependencies = [
"bytes",
"heck 0.4.1",
"itertools",
"lazy_static",
"log",
"multimap",
"petgraph",
"prettyplease",
"prost",
"prost-types",
"regex",
"syn 1.0.109",
"tempfile",
"which",
]
[[package]]
name = "prost-derive"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
dependencies = [
"anyhow",
"itertools",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "prost-types"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
dependencies = [
"prost",
]
[[package]]
name = "qr_code"
version = "2.0.0"
@@ -1870,6 +2171,12 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4680be54420a86f28b3e662bd8f76fd270c1eed5b2e3ebe9e404c12c4ec2b066"
[[package]]
name = "querystring"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9318ead08c799aad12a55a3e78b82e0b6167271ffd1f627b758891282f739187"
[[package]]
name = "quick-error"
version = "1.2.3"
@@ -2172,6 +2479,12 @@ dependencies = [
"untrusted",
]
[[package]]
name = "rustversion"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
[[package]]
name = "rustyline"
version = "13.0.0"
@@ -2203,7 +2516,7 @@ checksum = "e5af959c8bf6af1aff6d2b463a57f71aae53d1332da58419e30ad8dc7011d951"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -2237,6 +2550,43 @@ dependencies = [
"untrusted",
]
[[package]]
name = "sdk-common"
version = "0.4.1"
source = "git+https://github.com/breez/breez-sdk?branch=main#7c48c1e5a6f0450ae6f6150b8e40235ee31fd330"
dependencies = [
"aes 0.8.4",
"anyhow",
"base64 0.13.1",
"bip21",
"bitcoin 0.29.2",
"cbc",
"hex",
"lightning 0.0.116",
"lightning-invoice 0.24.0",
"log",
"prost",
"querystring",
"regex",
"reqwest 0.11.20",
"serde",
"serde_json",
"strum_macros",
"thiserror",
"tonic",
"tonic-build",
]
[[package]]
name = "secp256k1"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62"
dependencies = [
"bitcoin_hashes 0.11.0",
"secp256k1-sys 0.6.1",
]
[[package]]
name = "secp256k1"
version = "0.27.0"
@@ -2259,6 +2609,15 @@ dependencies = [
"serde",
]
[[package]]
name = "secp256k1-sys"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b"
dependencies = [
"cc",
]
[[package]]
name = "secp256k1-sys"
version = "0.8.1"
@@ -2357,7 +2716,7 @@ checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -2431,12 +2790,36 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum_macros"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.61",
]
[[package]]
name = "subtle"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.61"
@@ -2513,7 +2896,7 @@ checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -2557,6 +2940,16 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "tokio-io-timeout"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
dependencies = [
"pin-project-lite",
"tokio",
]
[[package]]
name = "tokio-macros"
version = "2.2.0"
@@ -2565,7 +2958,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -2628,6 +3021,51 @@ dependencies = [
"tokio",
]
[[package]]
name = "tonic"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb"
dependencies = [
"async-stream",
"async-trait",
"axum",
"base64 0.13.1",
"bytes",
"futures-core",
"futures-util",
"h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.29",
"hyper-timeout",
"percent-encoding",
"pin-project",
"prost",
"prost-derive",
"tokio",
"tokio-stream",
"tokio-util",
"tower",
"tower-layer",
"tower-service",
"tracing",
"tracing-futures",
]
[[package]]
name = "tonic-build"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4"
dependencies = [
"prettyplease",
"proc-macro2",
"prost-build",
"quote",
"syn 1.0.109",
]
[[package]]
name = "tower"
version = "0.4.13"
@@ -2636,9 +3074,13 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
"futures-core",
"futures-util",
"indexmap 1.9.3",
"pin-project",
"pin-project-lite",
"rand",
"slab",
"tokio",
"tokio-util",
"tower-layer",
"tower-service",
"tracing",
@@ -2676,7 +3118,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]
@@ -2688,6 +3130,16 @@ dependencies = [
"once_cell",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]]
name = "try-lock"
version = "0.2.5"
@@ -2860,7 +3312,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
"wasm-bindgen-shared",
]
@@ -2894,7 +3346,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -2945,6 +3397,18 @@ dependencies = [
"rustls-pki-types",
]
[[package]]
name = "which"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"home",
"once_cell",
"rustix",
]
[[package]]
name = "winapi"
version = "0.3.9"
@@ -3161,7 +3625,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.61",
]
[[package]]

View File

@@ -7,6 +7,7 @@ use std::time::Duration;
use anyhow::Result;
use breez_liquid_sdk::model::*;
use breez_liquid_sdk::sdk::LiquidSdk;
use breez_liquid_sdk::*;
use clap::{arg, Parser};
use qrcode_rs::render::unicode;
use qrcode_rs::{EcLevel, QrCode};
@@ -62,6 +63,24 @@ pub(crate) enum Command {
},
/// Shuts down all background threads of this SDK instance
Disconnect,
/// Parse a generic string to get its type and relevant metadata
Parse {
/// Generic input (URL, LNURL, BIP-21 BTC Address, LN invoice, etc)
input: String,
},
/// Pay using LNURL
LnurlPay {
/// LN Address or LNURL-pay endpoint
lnurl: String,
},
LnurlWithdraw {
/// LNURL-withdraw endpoint
lnurl: String,
},
LnurlAuth {
/// LNURL-auth endpoint
lnurl: String,
},
}
#[derive(Helper, Completer, Hinter, Validator)]
@@ -105,7 +124,7 @@ macro_rules! wait_confirmation {
}
pub(crate) async fn handle_command(
_rl: &mut Editor<CliHelper, DefaultHistory>,
rl: &mut Editor<CliHelper, DefaultHistory>,
sdk: &Arc<LiquidSdk>,
command: Command,
) -> Result<String> {
@@ -209,6 +228,72 @@ pub(crate) async fn handle_command(
sdk.disconnect().await?;
command_result!("Liquid SDK instance disconnected")
}
Command::Parse { input } => {
let res = LiquidSdk::parse(&input).await?;
command_result!(res)
}
Command::LnurlPay { lnurl } => {
let input = LiquidSdk::parse(&lnurl).await?;
let res = match input {
InputType::LnUrlPay { data: pd } => {
let prompt = format!(
"Amount to pay in millisatoshi (min {} msat, max {} msat): ",
pd.min_sendable, pd.max_sendable
);
let amount_msat = rl.readline(&prompt)?;
let pay_res = sdk
.lnurl_pay(LnUrlPayRequest {
data: pd,
amount_msat: amount_msat.parse::<u64>()?,
comment: None,
payment_label: None,
})
.await?;
Ok(pay_res)
}
_ => Err(anyhow::anyhow!("Invalid input")),
}?;
command_result!(res)
}
Command::LnurlWithdraw { lnurl } => {
let input = LiquidSdk::parse(&lnurl).await?;
let res = match input {
InputType::LnUrlWithdraw { data: pd } => {
let prompt = format!(
"Amount to withdraw in millisatoshi (min {} msat, max {} msat): ",
pd.min_withdrawable, pd.max_withdrawable
);
let amount_msat = rl.readline(&prompt)?;
let withdraw_res = sdk
.lnurl_withdraw(LnUrlWithdrawRequest {
data: pd,
amount_msat: amount_msat.parse()?,
description: Some("LNURL-withdraw".to_string()),
})
.await?;
Ok(withdraw_res)
}
_ => Err(anyhow::anyhow!("Invalid input")),
}?;
command_result!(res)
}
Command::LnurlAuth { lnurl } => {
let lnurl_endpoint = lnurl.trim();
let res = match parse(lnurl_endpoint).await? {
InputType::LnUrlAuth { data: ad } => {
let auth_res = sdk.lnurl_auth(ad).await?;
serde_json::to_string_pretty(&auth_res).map_err(|e| e.into())
}
_ => Err(anyhow::anyhow!("Unexpected result type")),
}?;
command_result!(res)
}
})
}

View File

@@ -23,11 +23,11 @@ pub(crate) struct Args {
pub(crate) log_file: Option<String>,
#[clap(short, long, value_parser = parse_network_arg)]
pub(crate) network: Option<Network>,
pub(crate) network: Option<LiquidNetwork>,
}
fn parse_network_arg(s: &str) -> Result<Network, String> {
Network::try_from(s).map_err(|e| e.to_string())
fn parse_network_arg(s: &str) -> Result<LiquidNetwork, String> {
LiquidNetwork::try_from(s).map_err(|e| e.to_string())
}
fn show_results(result: Result<String>) -> Result<()> {
@@ -73,7 +73,7 @@ async fn main() -> Result<()> {
}
let mnemonic = persistence.get_or_create_mnemonic()?;
let network = args.network.unwrap_or(Network::Testnet);
let network = args.network.unwrap_or(LiquidNetwork::Testnet);
let mut config = LiquidSdk::default_config(network);
config.working_dir = data_dir_str;
let sdk = LiquidSdk::connect(ConnectRequest {
@@ -86,8 +86,8 @@ async fn main() -> Result<()> {
.await?;
let cli_prompt = match network {
Network::Mainnet => "breez-liquid-cli [mainnet]> ",
Network::Testnet => "breez-liquid-cli [testnet]> ",
LiquidNetwork::Mainnet => "breez-liquid-cli [mainnet]> ",
LiquidNetwork::Testnet => "breez-liquid-cli [testnet]> ",
};
loop {

470
lib/Cargo.lock generated
View File

@@ -33,11 +33,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
dependencies = [
"cfg-if",
"cipher",
"cipher 0.3.0",
"cpufeatures",
"opaque-debug",
]
[[package]]
name = "aes"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
dependencies = [
"cfg-if",
"cipher 0.4.4",
"cpufeatures",
]
[[package]]
name = "aes-gcm-siv"
version = "0.10.1"
@@ -45,8 +56,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfde8146762f3c5f3c5cd41aa17a71f3188df09d5857192b658510d850e16068"
dependencies = [
"aead",
"aes",
"cipher",
"aes 0.7.5",
"cipher 0.3.0",
"ctr",
"polyval",
"subtle",
@@ -86,12 +97,6 @@ dependencies = [
"chrono",
]
[[package]]
name = "allocator-api2"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "android-tzdata"
version = "0.1.1"
@@ -263,6 +268,28 @@ dependencies = [
"toml",
]
[[package]]
name = "async-stream"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51"
dependencies = [
"async-stream-impl",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-stream-impl"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.61",
]
[[package]]
name = "async-trait"
version = "0.1.80"
@@ -303,6 +330,51 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "axum"
version = "0.6.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
dependencies = [
"async-trait",
"axum-core",
"bitflags 1.3.2",
"bytes",
"futures-util",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.29",
"itoa",
"matchit",
"memchr",
"mime",
"percent-encoding",
"pin-project-lite",
"rustversion",
"serde",
"sync_wrapper",
"tower",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum-core"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
dependencies = [
"async-trait",
"bytes",
"futures-util",
"http 0.2.12",
"http-body 0.4.6",
"mime",
"rustversion",
"tower-layer",
"tower-service",
]
[[package]]
name = "backtrace"
version = "0.3.71"
@@ -388,6 +460,16 @@ dependencies = [
"uniffi_macros 0.23.0",
]
[[package]]
name = "bip21"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1998475af29ccfb7c761bb624a16e501fc321510366012bc9cce267bc134aedc"
dependencies = [
"bitcoin 0.29.2",
"percent-encoding-rfc3986",
]
[[package]]
name = "bip39"
version = "2.0.0"
@@ -401,6 +483,17 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "bitcoin"
version = "0.29.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3"
dependencies = [
"bech32 0.9.1",
"bitcoin_hashes 0.11.0",
"secp256k1 0.24.3",
]
[[package]]
name = "bitcoin"
version = "0.30.2"
@@ -492,6 +585,15 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block-padding"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
dependencies = [
"generic-array",
]
[[package]]
name = "bmp-monochrome"
version = "1.1.0"
@@ -508,7 +610,7 @@ dependencies = [
"electrum-client",
"elements",
"env_logger 0.7.1",
"lightning-invoice",
"lightning-invoice 0.30.0",
"log",
"native-tls",
"serde",
@@ -541,6 +643,7 @@ dependencies = [
"reqwest 0.11.20",
"rusqlite",
"rusqlite_migration",
"sdk-common",
"security-framework",
"security-framework-sys",
"serde",
@@ -633,6 +736,15 @@ dependencies = [
"thiserror",
]
[[package]]
name = "cbc"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
dependencies = [
"cipher 0.4.4",
]
[[package]]
name = "cc"
version = "1.0.97"
@@ -668,6 +780,16 @@ dependencies = [
"generic-array",
]
[[package]]
name = "cipher"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
"crypto-common",
"inout",
]
[[package]]
name = "clap"
version = "3.2.25"
@@ -813,7 +935,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481"
dependencies = [
"cipher",
"cipher 0.3.0",
]
[[package]]
@@ -862,6 +984,12 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "either"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
[[package]]
name = "electrum-client"
version = "0.19.0"
@@ -992,6 +1120,12 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]]
name = "fixedbitset"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flate2"
version = "1.0.30"
@@ -1300,14 +1434,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2",
]
[[package]]
name = "hashlink"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692eaaf7f7607518dd3cef090f1474b61edc5301d8012f09579920df68b725ee"
checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
dependencies = [
"hashbrown 0.14.5",
]
@@ -1357,6 +1490,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "http"
version = "0.2.12"
@@ -1501,6 +1643,18 @@ dependencies = [
"tower-service",
]
[[package]]
name = "hyper-timeout"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
dependencies = [
"hyper 0.14.29",
"pin-project-lite",
"tokio",
"tokio-io-timeout",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
@@ -1616,6 +1770,16 @@ dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "inout"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
dependencies = [
"block-padding",
"generic-array",
]
[[package]]
name = "instant"
version = "0.1.12"
@@ -1637,6 +1801,15 @@ version = "1.70.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.11"
@@ -1675,6 +1848,15 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "lightning"
version = "0.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90a0f2155316f1570446a0447c993480673f840748c8ed25bbc59dfc442ac770"
dependencies = [
"bitcoin 0.29.2",
]
[[package]]
name = "lightning"
version = "0.0.122"
@@ -1685,6 +1867,20 @@ dependencies = [
"hex-conservative",
]
[[package]]
name = "lightning-invoice"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1788c0158526ec27a502043c2911ea6ea58fdc656bdf8749484942c07b790d23"
dependencies = [
"bech32 0.9.1",
"bitcoin 0.29.2",
"bitcoin_hashes 0.11.0",
"lightning 0.0.116",
"num-traits",
"secp256k1 0.24.3",
]
[[package]]
name = "lightning-invoice"
version = "0.30.0"
@@ -1693,7 +1889,7 @@ checksum = "106fdb897e69df697480f45bf0a564b425af488fb0f7407e770a770c39b19a21"
dependencies = [
"bech32 0.9.1",
"bitcoin 0.30.2",
"lightning",
"lightning 0.0.122",
"num-traits",
"secp256k1 0.27.0",
]
@@ -1794,6 +1990,12 @@ dependencies = [
"tracing",
]
[[package]]
name = "matchit"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "md-5"
version = "0.10.6"
@@ -1863,6 +2065,12 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "multimap"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]]
name = "native-tls"
version = "0.2.11"
@@ -2068,6 +2276,22 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "percent-encoding-rfc3986"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3637c05577168127568a64e9dc5a6887da720efef07b3d9472d45f63ab191166"
[[package]]
name = "petgraph"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
dependencies = [
"fixedbitset",
"indexmap 2.2.6",
]
[[package]]
name = "pin-project"
version = "1.1.5"
@@ -2130,6 +2354,16 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "prettyplease"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86"
dependencies = [
"proc-macro2",
"syn 1.0.109",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@@ -2163,6 +2397,60 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "prost"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
dependencies = [
"bytes",
"prost-derive",
]
[[package]]
name = "prost-build"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270"
dependencies = [
"bytes",
"heck 0.4.1",
"itertools",
"lazy_static",
"log",
"multimap",
"petgraph",
"prettyplease",
"prost",
"prost-types",
"regex",
"syn 1.0.109",
"tempfile",
"which",
]
[[package]]
name = "prost-derive"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
dependencies = [
"anyhow",
"itertools",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "prost-types"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
dependencies = [
"prost",
]
[[package]]
name = "qr_code"
version = "2.0.0"
@@ -2172,6 +2460,12 @@ dependencies = [
"bmp-monochrome",
]
[[package]]
name = "querystring"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9318ead08c799aad12a55a3e78b82e0b6167271ffd1f627b758891282f739187"
[[package]]
name = "quick-error"
version = "1.2.3"
@@ -2519,6 +2813,12 @@ dependencies = [
"untrusted",
]
[[package]]
name = "rustversion"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
[[package]]
name = "ryu"
version = "1.0.18"
@@ -2590,6 +2890,43 @@ dependencies = [
"untrusted",
]
[[package]]
name = "sdk-common"
version = "0.4.1"
source = "git+https://github.com/breez/breez-sdk?branch=main#7c48c1e5a6f0450ae6f6150b8e40235ee31fd330"
dependencies = [
"aes 0.8.4",
"anyhow",
"base64 0.13.1",
"bip21",
"bitcoin 0.29.2",
"cbc",
"hex",
"lightning 0.0.116",
"lightning-invoice 0.24.0",
"log",
"prost",
"querystring",
"regex",
"reqwest 0.11.20",
"serde",
"serde_json",
"strum_macros",
"thiserror",
"tonic",
"tonic-build",
]
[[package]]
name = "secp256k1"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62"
dependencies = [
"bitcoin_hashes 0.11.0",
"secp256k1-sys 0.6.1",
]
[[package]]
name = "secp256k1"
version = "0.27.0"
@@ -2612,6 +2949,15 @@ dependencies = [
"serde",
]
[[package]]
name = "secp256k1-sys"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b"
dependencies = [
"cc",
]
[[package]]
name = "secp256k1-sys"
version = "0.8.1"
@@ -2826,6 +3172,19 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum_macros"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.61",
]
[[package]]
name = "subtle"
version = "2.5.0"
@@ -2986,6 +3345,16 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "tokio-io-timeout"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
dependencies = [
"pin-project-lite",
"tokio",
]
[[package]]
name = "tokio-macros"
version = "2.2.0"
@@ -3066,6 +3435,51 @@ dependencies = [
"serde",
]
[[package]]
name = "tonic"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb"
dependencies = [
"async-stream",
"async-trait",
"axum",
"base64 0.13.1",
"bytes",
"futures-core",
"futures-util",
"h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.29",
"hyper-timeout",
"percent-encoding",
"pin-project",
"prost",
"prost-derive",
"tokio",
"tokio-stream",
"tokio-util",
"tower",
"tower-layer",
"tower-service",
"tracing",
"tracing-futures",
]
[[package]]
name = "tonic-build"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4"
dependencies = [
"prettyplease",
"proc-macro2",
"prost-build",
"quote",
"syn 1.0.109",
]
[[package]]
name = "tower"
version = "0.4.13"
@@ -3074,9 +3488,13 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
"futures-core",
"futures-util",
"indexmap 1.9.3",
"pin-project",
"pin-project-lite",
"rand 0.8.5",
"slab",
"tokio",
"tokio-util",
"tower-layer",
"tower-service",
"tracing",
@@ -3126,6 +3544,16 @@ dependencies = [
"once_cell",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]]
name = "try-lock"
version = "0.2.5"
@@ -3759,6 +4187,18 @@ dependencies = [
"nom",
]
[[package]]
name = "which"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"home",
"once_cell",
"rustix",
]
[[package]]
name = "winapi"
version = "0.3.9"

View File

@@ -35,6 +35,46 @@ typedef struct wire_cst_backup_request {
struct wire_cst_list_prim_u_8_strict *backup_path;
} wire_cst_backup_request;
typedef struct wire_cst_ln_url_auth_request_data {
struct wire_cst_list_prim_u_8_strict *k1;
struct wire_cst_list_prim_u_8_strict *action;
struct wire_cst_list_prim_u_8_strict *domain;
struct wire_cst_list_prim_u_8_strict *url;
} wire_cst_ln_url_auth_request_data;
typedef struct wire_cst_ln_url_pay_request_data {
struct wire_cst_list_prim_u_8_strict *callback;
uint64_t min_sendable;
uint64_t max_sendable;
struct wire_cst_list_prim_u_8_strict *metadata_str;
uint16_t comment_allowed;
struct wire_cst_list_prim_u_8_strict *domain;
bool allows_nostr;
struct wire_cst_list_prim_u_8_strict *nostr_pubkey;
struct wire_cst_list_prim_u_8_strict *ln_address;
} wire_cst_ln_url_pay_request_data;
typedef struct wire_cst_ln_url_pay_request {
struct wire_cst_ln_url_pay_request_data data;
uint64_t amount_msat;
struct wire_cst_list_prim_u_8_strict *comment;
struct wire_cst_list_prim_u_8_strict *payment_label;
} wire_cst_ln_url_pay_request;
typedef struct wire_cst_ln_url_withdraw_request_data {
struct wire_cst_list_prim_u_8_strict *callback;
struct wire_cst_list_prim_u_8_strict *k1;
struct wire_cst_list_prim_u_8_strict *default_description;
uint64_t min_withdrawable;
uint64_t max_withdrawable;
} wire_cst_ln_url_withdraw_request_data;
typedef struct wire_cst_ln_url_withdraw_request {
struct wire_cst_ln_url_withdraw_request_data data;
uint64_t amount_msat;
struct wire_cst_list_prim_u_8_strict *description;
} wire_cst_ln_url_withdraw_request;
typedef struct wire_cst_prepare_pay_onchain_response {
uint64_t amount_sat;
uint64_t fees_sat;
@@ -143,10 +183,36 @@ typedef struct wire_cst_connect_request {
struct wire_cst_config config;
} wire_cst_connect_request;
typedef struct wire_cst_list_payment {
struct wire_cst_payment *ptr;
int32_t len;
} wire_cst_list_payment;
typedef struct wire_cst_aes_success_action_data_decrypted {
struct wire_cst_list_prim_u_8_strict *description;
struct wire_cst_list_prim_u_8_strict *plaintext;
} wire_cst_aes_success_action_data_decrypted;
typedef struct wire_cst_AesSuccessActionDataResult_Decrypted {
struct wire_cst_aes_success_action_data_decrypted *data;
} wire_cst_AesSuccessActionDataResult_Decrypted;
typedef struct wire_cst_AesSuccessActionDataResult_ErrorStatus {
struct wire_cst_list_prim_u_8_strict *reason;
} wire_cst_AesSuccessActionDataResult_ErrorStatus;
typedef union AesSuccessActionDataResultKind {
struct wire_cst_AesSuccessActionDataResult_Decrypted Decrypted;
struct wire_cst_AesSuccessActionDataResult_ErrorStatus ErrorStatus;
} AesSuccessActionDataResultKind;
typedef struct wire_cst_aes_success_action_data_result {
int32_t tag;
union AesSuccessActionDataResultKind kind;
} wire_cst_aes_success_action_data_result;
typedef struct wire_cst_bitcoin_address_data {
struct wire_cst_list_prim_u_8_strict *address;
int32_t network;
uint64_t *amount_sat;
struct wire_cst_list_prim_u_8_strict *label;
struct wire_cst_list_prim_u_8_strict *message;
} wire_cst_bitcoin_address_data;
typedef struct wire_cst_route_hint_hop {
struct wire_cst_list_prim_u_8_strict *src_node_id;
@@ -172,6 +238,76 @@ typedef struct wire_cst_list_route_hint {
int32_t len;
} wire_cst_list_route_hint;
typedef struct wire_cst_ln_invoice {
struct wire_cst_list_prim_u_8_strict *bolt11;
int32_t network;
struct wire_cst_list_prim_u_8_strict *payee_pubkey;
struct wire_cst_list_prim_u_8_strict *payment_hash;
struct wire_cst_list_prim_u_8_strict *description;
struct wire_cst_list_prim_u_8_strict *description_hash;
uint64_t *amount_msat;
uint64_t timestamp;
uint64_t expiry;
struct wire_cst_list_route_hint *routing_hints;
struct wire_cst_list_prim_u_8_strict *payment_secret;
uint64_t min_final_cltv_expiry_delta;
} wire_cst_ln_invoice;
typedef struct wire_cst_ln_url_error_data {
struct wire_cst_list_prim_u_8_strict *reason;
} wire_cst_ln_url_error_data;
typedef struct wire_cst_ln_url_pay_error_data {
struct wire_cst_list_prim_u_8_strict *payment_hash;
struct wire_cst_list_prim_u_8_strict *reason;
} wire_cst_ln_url_pay_error_data;
typedef struct wire_cst_SuccessActionProcessed_Aes {
struct wire_cst_aes_success_action_data_result *result;
} wire_cst_SuccessActionProcessed_Aes;
typedef struct wire_cst_message_success_action_data {
struct wire_cst_list_prim_u_8_strict *message;
} wire_cst_message_success_action_data;
typedef struct wire_cst_SuccessActionProcessed_Message {
struct wire_cst_message_success_action_data *data;
} wire_cst_SuccessActionProcessed_Message;
typedef struct wire_cst_url_success_action_data {
struct wire_cst_list_prim_u_8_strict *description;
struct wire_cst_list_prim_u_8_strict *url;
} wire_cst_url_success_action_data;
typedef struct wire_cst_SuccessActionProcessed_Url {
struct wire_cst_url_success_action_data *data;
} wire_cst_SuccessActionProcessed_Url;
typedef union SuccessActionProcessedKind {
struct wire_cst_SuccessActionProcessed_Aes Aes;
struct wire_cst_SuccessActionProcessed_Message Message;
struct wire_cst_SuccessActionProcessed_Url Url;
} SuccessActionProcessedKind;
typedef struct wire_cst_success_action_processed {
int32_t tag;
union SuccessActionProcessedKind kind;
} wire_cst_success_action_processed;
typedef struct wire_cst_ln_url_pay_success_data {
struct wire_cst_payment payment;
struct wire_cst_success_action_processed *success_action;
} wire_cst_ln_url_pay_success_data;
typedef struct wire_cst_ln_url_withdraw_success_data {
struct wire_cst_ln_invoice invoice;
} wire_cst_ln_url_withdraw_success_data;
typedef struct wire_cst_list_payment {
struct wire_cst_payment *ptr;
int32_t len;
} wire_cst_list_payment;
typedef struct wire_cst_get_info_response {
uint64_t balance_sat;
uint64_t pending_send_sat;
@@ -179,6 +315,54 @@ typedef struct wire_cst_get_info_response {
struct wire_cst_list_prim_u_8_strict *pubkey;
} wire_cst_get_info_response;
typedef struct wire_cst_InputType_BitcoinAddress {
struct wire_cst_bitcoin_address_data *address;
} wire_cst_InputType_BitcoinAddress;
typedef struct wire_cst_InputType_Bolt11 {
struct wire_cst_ln_invoice *invoice;
} wire_cst_InputType_Bolt11;
typedef struct wire_cst_InputType_NodeId {
struct wire_cst_list_prim_u_8_strict *node_id;
} wire_cst_InputType_NodeId;
typedef struct wire_cst_InputType_Url {
struct wire_cst_list_prim_u_8_strict *url;
} wire_cst_InputType_Url;
typedef struct wire_cst_InputType_LnUrlPay {
struct wire_cst_ln_url_pay_request_data *data;
} wire_cst_InputType_LnUrlPay;
typedef struct wire_cst_InputType_LnUrlWithdraw {
struct wire_cst_ln_url_withdraw_request_data *data;
} wire_cst_InputType_LnUrlWithdraw;
typedef struct wire_cst_InputType_LnUrlAuth {
struct wire_cst_ln_url_auth_request_data *data;
} wire_cst_InputType_LnUrlAuth;
typedef struct wire_cst_InputType_LnUrlError {
struct wire_cst_ln_url_error_data *data;
} wire_cst_InputType_LnUrlError;
typedef union InputTypeKind {
struct wire_cst_InputType_BitcoinAddress BitcoinAddress;
struct wire_cst_InputType_Bolt11 Bolt11;
struct wire_cst_InputType_NodeId NodeId;
struct wire_cst_InputType_Url Url;
struct wire_cst_InputType_LnUrlPay LnUrlPay;
struct wire_cst_InputType_LnUrlWithdraw LnUrlWithdraw;
struct wire_cst_InputType_LnUrlAuth LnUrlAuth;
struct wire_cst_InputType_LnUrlError LnUrlError;
} InputTypeKind;
typedef struct wire_cst_input_type {
int32_t tag;
union InputTypeKind kind;
} wire_cst_input_type;
typedef struct wire_cst_LiquidSdkError_Generic {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LiquidSdkError_Generic;
@@ -197,20 +381,183 @@ typedef struct wire_cst_liquid_sdk_error {
union LiquidSdkErrorKind kind;
} wire_cst_liquid_sdk_error;
typedef struct wire_cst_ln_invoice {
struct wire_cst_list_prim_u_8_strict *bolt11;
int32_t network;
struct wire_cst_list_prim_u_8_strict *payee_pubkey;
struct wire_cst_list_prim_u_8_strict *payment_hash;
struct wire_cst_list_prim_u_8_strict *description;
struct wire_cst_list_prim_u_8_strict *description_hash;
uint64_t *amount_msat;
uint64_t timestamp;
uint64_t expiry;
struct wire_cst_list_route_hint *routing_hints;
struct wire_cst_list_prim_u_8_strict *payment_secret;
uint64_t min_final_cltv_expiry_delta;
} wire_cst_ln_invoice;
typedef struct wire_cst_LnUrlAuthError_Generic {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlAuthError_Generic;
typedef struct wire_cst_LnUrlAuthError_InvalidUri {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlAuthError_InvalidUri;
typedef struct wire_cst_LnUrlAuthError_ServiceConnectivity {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlAuthError_ServiceConnectivity;
typedef union LnUrlAuthErrorKind {
struct wire_cst_LnUrlAuthError_Generic Generic;
struct wire_cst_LnUrlAuthError_InvalidUri InvalidUri;
struct wire_cst_LnUrlAuthError_ServiceConnectivity ServiceConnectivity;
} LnUrlAuthErrorKind;
typedef struct wire_cst_ln_url_auth_error {
int32_t tag;
union LnUrlAuthErrorKind kind;
} wire_cst_ln_url_auth_error;
typedef struct wire_cst_LnUrlCallbackStatus_ErrorStatus {
struct wire_cst_ln_url_error_data *data;
} wire_cst_LnUrlCallbackStatus_ErrorStatus;
typedef union LnUrlCallbackStatusKind {
struct wire_cst_LnUrlCallbackStatus_ErrorStatus ErrorStatus;
} LnUrlCallbackStatusKind;
typedef struct wire_cst_ln_url_callback_status {
int32_t tag;
union LnUrlCallbackStatusKind kind;
} wire_cst_ln_url_callback_status;
typedef struct wire_cst_LnUrlPayError_Generic {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_Generic;
typedef struct wire_cst_LnUrlPayError_InvalidAmount {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_InvalidAmount;
typedef struct wire_cst_LnUrlPayError_InvalidInvoice {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_InvalidInvoice;
typedef struct wire_cst_LnUrlPayError_InvalidNetwork {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_InvalidNetwork;
typedef struct wire_cst_LnUrlPayError_InvalidUri {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_InvalidUri;
typedef struct wire_cst_LnUrlPayError_InvoiceExpired {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_InvoiceExpired;
typedef struct wire_cst_LnUrlPayError_PaymentFailed {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_PaymentFailed;
typedef struct wire_cst_LnUrlPayError_PaymentTimeout {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_PaymentTimeout;
typedef struct wire_cst_LnUrlPayError_RouteNotFound {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_RouteNotFound;
typedef struct wire_cst_LnUrlPayError_RouteTooExpensive {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_RouteTooExpensive;
typedef struct wire_cst_LnUrlPayError_ServiceConnectivity {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlPayError_ServiceConnectivity;
typedef union LnUrlPayErrorKind {
struct wire_cst_LnUrlPayError_Generic Generic;
struct wire_cst_LnUrlPayError_InvalidAmount InvalidAmount;
struct wire_cst_LnUrlPayError_InvalidInvoice InvalidInvoice;
struct wire_cst_LnUrlPayError_InvalidNetwork InvalidNetwork;
struct wire_cst_LnUrlPayError_InvalidUri InvalidUri;
struct wire_cst_LnUrlPayError_InvoiceExpired InvoiceExpired;
struct wire_cst_LnUrlPayError_PaymentFailed PaymentFailed;
struct wire_cst_LnUrlPayError_PaymentTimeout PaymentTimeout;
struct wire_cst_LnUrlPayError_RouteNotFound RouteNotFound;
struct wire_cst_LnUrlPayError_RouteTooExpensive RouteTooExpensive;
struct wire_cst_LnUrlPayError_ServiceConnectivity ServiceConnectivity;
} LnUrlPayErrorKind;
typedef struct wire_cst_ln_url_pay_error {
int32_t tag;
union LnUrlPayErrorKind kind;
} wire_cst_ln_url_pay_error;
typedef struct wire_cst_LnUrlPayResult_EndpointSuccess {
struct wire_cst_ln_url_pay_success_data *data;
} wire_cst_LnUrlPayResult_EndpointSuccess;
typedef struct wire_cst_LnUrlPayResult_EndpointError {
struct wire_cst_ln_url_error_data *data;
} wire_cst_LnUrlPayResult_EndpointError;
typedef struct wire_cst_LnUrlPayResult_PayError {
struct wire_cst_ln_url_pay_error_data *data;
} wire_cst_LnUrlPayResult_PayError;
typedef union LnUrlPayResultKind {
struct wire_cst_LnUrlPayResult_EndpointSuccess EndpointSuccess;
struct wire_cst_LnUrlPayResult_EndpointError EndpointError;
struct wire_cst_LnUrlPayResult_PayError PayError;
} LnUrlPayResultKind;
typedef struct wire_cst_ln_url_pay_result {
int32_t tag;
union LnUrlPayResultKind kind;
} wire_cst_ln_url_pay_result;
typedef struct wire_cst_LnUrlWithdrawError_Generic {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlWithdrawError_Generic;
typedef struct wire_cst_LnUrlWithdrawError_InvalidAmount {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlWithdrawError_InvalidAmount;
typedef struct wire_cst_LnUrlWithdrawError_InvalidInvoice {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlWithdrawError_InvalidInvoice;
typedef struct wire_cst_LnUrlWithdrawError_InvalidUri {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlWithdrawError_InvalidUri;
typedef struct wire_cst_LnUrlWithdrawError_InvoiceNoRoutingHints {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlWithdrawError_InvoiceNoRoutingHints;
typedef struct wire_cst_LnUrlWithdrawError_ServiceConnectivity {
struct wire_cst_list_prim_u_8_strict *err;
} wire_cst_LnUrlWithdrawError_ServiceConnectivity;
typedef union LnUrlWithdrawErrorKind {
struct wire_cst_LnUrlWithdrawError_Generic Generic;
struct wire_cst_LnUrlWithdrawError_InvalidAmount InvalidAmount;
struct wire_cst_LnUrlWithdrawError_InvalidInvoice InvalidInvoice;
struct wire_cst_LnUrlWithdrawError_InvalidUri InvalidUri;
struct wire_cst_LnUrlWithdrawError_InvoiceNoRoutingHints InvoiceNoRoutingHints;
struct wire_cst_LnUrlWithdrawError_ServiceConnectivity ServiceConnectivity;
} LnUrlWithdrawErrorKind;
typedef struct wire_cst_ln_url_withdraw_error {
int32_t tag;
union LnUrlWithdrawErrorKind kind;
} wire_cst_ln_url_withdraw_error;
typedef struct wire_cst_LnUrlWithdrawResult_Ok {
struct wire_cst_ln_url_withdraw_success_data *data;
} wire_cst_LnUrlWithdrawResult_Ok;
typedef struct wire_cst_LnUrlWithdrawResult_ErrorStatus {
struct wire_cst_ln_url_error_data *data;
} wire_cst_LnUrlWithdrawResult_ErrorStatus;
typedef union LnUrlWithdrawResultKind {
struct wire_cst_LnUrlWithdrawResult_Ok Ok;
struct wire_cst_LnUrlWithdrawResult_ErrorStatus ErrorStatus;
} LnUrlWithdrawResultKind;
typedef struct wire_cst_ln_url_withdraw_result {
int32_t tag;
union LnUrlWithdrawResultKind kind;
} wire_cst_ln_url_withdraw_result;
typedef struct wire_cst_log_entry {
struct wire_cst_list_prim_u_8_strict *line;
@@ -288,6 +635,18 @@ void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info(int64_
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_payments(int64_t port_,
uintptr_t that);
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_auth(int64_t port_,
uintptr_t that,
struct wire_cst_ln_url_auth_request_data *req_data);
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_pay(int64_t port_,
uintptr_t that,
struct wire_cst_ln_url_pay_request *req);
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdraw(int64_t port_,
uintptr_t that,
struct wire_cst_ln_url_withdraw_request *req);
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_pay_onchain(int64_t port_,
uintptr_t that,
struct wire_cst_pay_onchain_request *req);
@@ -330,20 +689,51 @@ void frbgen_breez_liquid_wire__crate__bindings__connect(int64_t port_,
WireSyncRust2DartDco frbgen_breez_liquid_wire__crate__bindings__default_config(int32_t network);
void frbgen_breez_liquid_wire__crate__bindings__parse(int64_t port_,
struct wire_cst_list_prim_u_8_strict *input);
WireSyncRust2DartDco frbgen_breez_liquid_wire__crate__bindings__parse_invoice(struct wire_cst_list_prim_u_8_strict *input);
void frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(const void *ptr);
void frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(const void *ptr);
struct wire_cst_aes_success_action_data_decrypted *frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decrypted(void);
struct wire_cst_aes_success_action_data_result *frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_result(void);
struct wire_cst_backup_request *frbgen_breez_liquid_cst_new_box_autoadd_backup_request(void);
struct wire_cst_binding_event_listener *frbgen_breez_liquid_cst_new_box_autoadd_binding_event_listener(void);
struct wire_cst_bitcoin_address_data *frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data(void);
struct wire_cst_connect_request *frbgen_breez_liquid_cst_new_box_autoadd_connect_request(void);
struct wire_cst_liquid_sdk_event *frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event(void);
struct wire_cst_ln_invoice *frbgen_breez_liquid_cst_new_box_autoadd_ln_invoice(void);
struct wire_cst_ln_url_auth_request_data *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_data(void);
struct wire_cst_ln_url_error_data *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_data(void);
struct wire_cst_ln_url_pay_error_data *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_data(void);
struct wire_cst_ln_url_pay_request *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request(void);
struct wire_cst_ln_url_pay_request_data *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_data(void);
struct wire_cst_ln_url_pay_success_data *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_data(void);
struct wire_cst_ln_url_withdraw_request *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request(void);
struct wire_cst_ln_url_withdraw_request_data *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_data(void);
struct wire_cst_ln_url_withdraw_success_data *frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_data(void);
struct wire_cst_message_success_action_data *frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data(void);
struct wire_cst_pay_onchain_request *frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request(void);
struct wire_cst_payment *frbgen_breez_liquid_cst_new_box_autoadd_payment(void);
@@ -360,8 +750,12 @@ struct wire_cst_prepare_send_response *frbgen_breez_liquid_cst_new_box_autoadd_p
struct wire_cst_restore_request *frbgen_breez_liquid_cst_new_box_autoadd_restore_request(void);
struct wire_cst_success_action_processed *frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed(void);
uint64_t *frbgen_breez_liquid_cst_new_box_autoadd_u_64(uint64_t value);
struct wire_cst_url_success_action_data *frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data(void);
struct wire_cst_list_payment *frbgen_breez_liquid_cst_new_list_payment(int32_t len);
struct wire_cst_list_prim_u_8_strict *frbgen_breez_liquid_cst_new_list_prim_u_8_strict(int32_t len);
@@ -371,10 +765,24 @@ struct wire_cst_list_route_hint *frbgen_breez_liquid_cst_new_list_route_hint(int
struct wire_cst_list_route_hint_hop *frbgen_breez_liquid_cst_new_list_route_hint_hop(int32_t len);
static int64_t dummy_method_to_enforce_bundling(void) {
int64_t dummy_var = 0;
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decrypted);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_result);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_backup_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_binding_event_listener);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_connect_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_invoice);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_payment);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_pay_onchain_request);
@@ -383,7 +791,9 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_restore_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_64);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_payment);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_prim_u_8_strict);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_route_hint);
@@ -396,6 +806,9 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_empty_wallet_cache);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_payments);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_auth);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_pay);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdraw);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_pay_onchain);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_pay_onchain);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment);
@@ -408,6 +821,7 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__breez_log_stream);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__connect);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__default_config);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__parse);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__parse_invoice);
dummy_var ^= ((int64_t) (void*) store_dart_post_cobject);
return dummy_var;

View File

@@ -1,3 +1,218 @@
//////////////////////////////////
// BEGIN sdk-common mirror imports
// These are structs defined in sdk-common, which we want to make available in this project's UDL bindings
dictionary LNInvoice {
string bolt11;
Network network;
string payee_pubkey;
string payment_hash;
string? description;
string? description_hash;
u64? amount_msat;
u64 timestamp;
u64 expiry;
sequence<RouteHint> routing_hints;
sequence<u8> payment_secret;
u64 min_final_cltv_expiry_delta;
};
enum Network {
"Bitcoin",
"Testnet",
"Signet",
"Regtest",
};
dictionary RouteHint {
sequence<RouteHintHop> hops;
};
dictionary RouteHintHop {
string src_node_id;
u64 short_channel_id;
u32 fees_base_msat;
u32 fees_proportional_millionths;
u64 cltv_expiry_delta;
u64? htlc_minimum_msat;
u64? htlc_maximum_msat;
};
[Enum]
interface InputType {
BitcoinAddress(BitcoinAddressData address);
Bolt11(LNInvoice invoice);
NodeId(string node_id);
Url(string url);
LnUrlPay(LnUrlPayRequestData data);
LnUrlWithdraw(LnUrlWithdrawRequestData data);
LnUrlAuth(LnUrlAuthRequestData data);
LnUrlError(LnUrlErrorData data);
};
dictionary BitcoinAddressData {
string address;
Network network;
u64? amount_sat;
string? label;
string? message;
};
dictionary LnUrlPayRequestData {
string callback;
u64 min_sendable;
u64 max_sendable;
string metadata_str;
u16 comment_allowed;
string domain;
boolean allows_nostr;
string? nostr_pubkey;
string? ln_address;
};
dictionary LnUrlWithdrawRequestData {
string callback;
string k1;
string default_description;
u64 min_withdrawable;
u64 max_withdrawable;
};
dictionary LnUrlAuthRequestData {
string k1;
string domain;
string url;
string? action = null;
};
dictionary LnUrlErrorData {
string reason;
};
[Enum]
interface SuccessActionProcessed {
Aes(AesSuccessActionDataResult result);
Message(MessageSuccessActionData data);
Url(UrlSuccessActionData data);
};
[Enum]
interface AesSuccessActionDataResult {
Decrypted(AesSuccessActionDataDecrypted data);
ErrorStatus(string reason);
};
dictionary AesSuccessActionDataDecrypted {
string description;
string plaintext;
};
dictionary MessageSuccessActionData {
string message;
};
dictionary UrlSuccessActionData {
string description;
string url;
};
dictionary LnUrlPayErrorData {
string payment_hash;
string reason;
};
dictionary LnUrlPayRequest {
LnUrlPayRequestData data;
u64 amount_msat;
string? comment = null;
string? payment_label = null;
};
[Error]
interface LnUrlPayError {
AlreadyPaid();
Generic(string err);
InvalidAmount(string err);
InvalidInvoice(string err);
InvalidNetwork(string err);
InvalidUri(string err);
InvoiceExpired(string err);
PaymentFailed(string err);
PaymentTimeout(string err);
RouteNotFound(string err);
RouteTooExpensive(string err);
ServiceConnectivity(string err);
};
[Error]
interface LnUrlWithdrawError {
Generic(string err);
InvalidAmount(string err);
InvalidInvoice(string err);
InvalidUri(string err);
ServiceConnectivity(string err);
InvoiceNoRoutingHints(string err);
};
[Enum]
interface LnUrlWithdrawResult {
Ok(LnUrlWithdrawSuccessData data);
ErrorStatus(LnUrlErrorData data);
};
dictionary LnUrlWithdrawSuccessData {
LNInvoice invoice;
};
dictionary LnUrlWithdrawRequestData {
string callback;
string k1;
string default_description;
u64 min_withdrawable;
u64 max_withdrawable;
};
dictionary LnUrlWithdrawRequest {
LnUrlWithdrawRequestData data;
u64 amount_msat;
string? description = null;
};
[Enum]
interface LnUrlCallbackStatus {
Ok();
ErrorStatus(LnUrlErrorData data);
};
[Error]
interface LnUrlAuthError {
Generic(string err);
InvalidUri(string err);
ServiceConnectivity(string err);
};
// END sdk-common mirror imports
////////////////////////////////
//////////////////////////////////
// BEGIN sdk-common wrappers
// These are connecting structures that glue relevant sdk-common structs to the SDK
[Enum]
interface LnUrlPayResult {
EndpointSuccess(LnUrlPaySuccessData data);
EndpointError(LnUrlErrorData data);
PayError(LnUrlPayErrorData data);
};
dictionary LnUrlPaySuccessData {
SuccessActionProcessed? success_action;
Payment payment;
};
// END sdk-common wrappers
////////////////////////////////
[Error]
enum LiquidSdkError {
"AlreadyStarted",
@@ -33,13 +248,13 @@ dictionary Config {
string liquid_electrum_url;
string bitcoin_electrum_url;
string working_dir;
Network network;
LiquidNetwork network;
u64 payment_timeout_sec;
f32 zero_conf_min_fee_rate;
u64? zero_conf_max_amount_sat;
};
enum Network {
enum LiquidNetwork {
"Mainnet",
"Testnet",
};
@@ -105,35 +320,6 @@ dictionary RestoreRequest {
string? backup_path = null;
};
dictionary RouteHint {
sequence<RouteHintHop> hops;
};
dictionary RouteHintHop {
string src_node_id;
u64 short_channel_id;
u32 fees_base_msat;
u32 fees_proportional_millionths;
u64 cltv_expiry_delta;
u64? htlc_minimum_msat;
u64? htlc_maximum_msat;
};
dictionary LNInvoice {
string bolt11;
Network network;
string payee_pubkey;
string payment_hash;
string? description;
string? description_hash;
u64? amount_msat;
u64 timestamp;
u64 expiry;
sequence<RouteHint> routing_hints;
sequence<u8> payment_secret;
u64 min_final_cltv_expiry_delta;
};
dictionary Payment {
string? tx_id = null;
string? swap_id = null;
@@ -192,10 +378,13 @@ namespace breez_liquid_sdk {
[Throws=LiquidSdkError]
void set_logger(Logger logger);
Config default_config(Network network);
Config default_config(LiquidNetwork network);
[Throws=PaymentError]
LNInvoice parse_invoice(string invoice);
InputType parse(string input);
[Throws=PaymentError]
LNInvoice parse_invoice(string input);
};
interface BindingLiquidSdk {
@@ -240,4 +429,13 @@ interface BindingLiquidSdk {
[Throws=LiquidSdkError]
void disconnect();
[Throws=LnUrlPayError]
LnUrlPayResult lnurl_pay(LnUrlPayRequest req);
[Throws=LnUrlWithdrawError]
LnUrlWithdrawResult lnurl_withdraw(LnUrlWithdrawRequest req);
[Throws=LnUrlAuthError]
LnUrlCallbackStatus lnurl_auth(LnUrlAuthRequestData req_data);
};

View File

@@ -4,7 +4,14 @@ use std::sync::Arc;
use anyhow::Result;
use breez_liquid_sdk::logger::Logger;
use breez_liquid_sdk::{error::*, model::*, sdk::LiquidSdk};
use breez_liquid_sdk::{
error::*, model::*, sdk::LiquidSdk, AesSuccessActionDataDecrypted, AesSuccessActionDataResult,
BitcoinAddressData, InputType, LNInvoice, LnUrlAuthError, LnUrlAuthRequestData,
LnUrlCallbackStatus, LnUrlErrorData, LnUrlPayError, LnUrlPayErrorData, LnUrlPayRequest,
LnUrlPayRequestData, LnUrlWithdrawError, LnUrlWithdrawRequest, LnUrlWithdrawRequestData,
LnUrlWithdrawResult, LnUrlWithdrawSuccessData, MessageSuccessActionData, Network, RouteHint,
RouteHintHop, SuccessActionProcessed, UrlSuccessActionData,
};
use log::{Metadata, Record, SetLoggerError};
use once_cell::sync::Lazy;
use tokio::runtime::Runtime;
@@ -58,10 +65,13 @@ pub fn connect(req: ConnectRequest) -> Result<Arc<BindingLiquidSdk>, LiquidSdkEr
})
}
pub fn default_config(network: Network) -> Config {
pub fn default_config(network: LiquidNetwork) -> Config {
LiquidSdk::default_config(network)
}
pub fn parse(input: String) -> Result<InputType, PaymentError> {
rt().block_on(async { LiquidSdk::parse(&input).await })
}
pub fn parse_invoice(input: String) -> Result<LNInvoice, PaymentError> {
LiquidSdk::parse_invoice(&input)
}
@@ -126,6 +136,25 @@ impl BindingLiquidSdk {
rt().block_on(self.sdk.list_payments())
}
pub fn lnurl_pay(&self, req: LnUrlPayRequest) -> Result<LnUrlPayResult, LnUrlPayError> {
rt().block_on(self.sdk.lnurl_pay(req)).map_err(Into::into)
}
pub fn lnurl_withdraw(
&self,
req: LnUrlWithdrawRequest,
) -> Result<LnUrlWithdrawResult, LnUrlWithdrawError> {
rt().block_on(self.sdk.lnurl_withdraw(req))
.map_err(Into::into)
}
pub fn lnurl_auth(
&self,
req_data: LnUrlAuthRequestData,
) -> Result<LnUrlCallbackStatus, LnUrlAuthError> {
rt().block_on(self.sdk.lnurl_auth(req_data))
}
pub fn sync(&self) -> LiquidSdkResult<()> {
rt().block_on(self.sdk.sync()).map_err(Into::into)
}

View File

@@ -7,7 +7,7 @@ class SDKListener: breez_liquid_sdk.EventListener {
try {
var mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
var config = breez_liquid_sdk.defaultConfig(breez_liquid_sdk.Network.TESTNET)
var config = breez_liquid_sdk.defaultConfig(breez_liquid_sdk.LiquidNetwork.TESTNET)
var connectRequest = breez_liquid_sdk.ConnectRequest(config, mnemonic)
var sdk = breez_liquid_sdk.connect(connectRequest)

View File

@@ -8,7 +8,7 @@ class SDKListener(breez_liquid_sdk.EventListener):
def test():
mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
config = breez_liquid_sdk.default_config(breez_liquid_sdk.Network.TESTNET)
config = breez_liquid_sdk.default_config(breez_liquid_sdk.LiquidNetwork.TESTNET)
connect_request = breez_liquid_sdk.ConnectRequest(config=config, mnemonic=mnemonic)
sdk = breez_liquid_sdk.connect(connect_request)

View File

@@ -27,6 +27,7 @@ lwk_wollet = { git = "https://github.com/Blockstream/lwk", rev = "ffd793d0a1b112
#lwk_wollet = "0.5.1"
rusqlite = { version = "0.31", features = ["backup", "bundled"] }
rusqlite_migration = "1.0"
sdk-common = { git = "https://github.com/breez/breez-sdk", branch = "main" }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.116"
thiserror = { workspace = true }

View File

@@ -5,6 +5,12 @@ use std::sync::Arc;
use anyhow::Result;
use flutter_rust_bridge::frb;
use log::{Level, LevelFilter, Metadata, Record, SetLoggerError};
pub use sdk_common::prelude::{
AesSuccessActionDataDecrypted, AesSuccessActionDataResult, BitcoinAddressData, InputType,
LNInvoice, LnUrlAuthRequestData, LnUrlErrorData, LnUrlPayErrorData, LnUrlPayRequest,
LnUrlPayRequestData, LnUrlWithdrawRequest, LnUrlWithdrawRequestData, MessageSuccessActionData,
Network, RouteHint, RouteHintHop, SuccessActionProcessed, UrlSuccessActionData,
};
use crate::{error::*, frb_generated::StreamSink, model::*, sdk::LiquidSdk};
@@ -60,10 +66,14 @@ pub fn breez_log_stream(s: StreamSink<LogEntry>) -> Result<()> {
}
#[frb(sync)]
pub fn default_config(network: Network) -> Config {
pub fn default_config(network: LiquidNetwork) -> Config {
LiquidSdk::default_config(network)
}
pub async fn parse(input: String) -> Result<InputType, PaymentError> {
LiquidSdk::parse(&input).await
}
#[frb(sync)]
pub fn parse_invoice(input: String) -> Result<LNInvoice, PaymentError> {
LiquidSdk::parse_invoice(&input)
@@ -133,6 +143,35 @@ impl BindingLiquidSdk {
self.sdk.list_payments().await
}
pub async fn lnurl_pay(
&self,
req: LnUrlPayRequest,
) -> Result<LnUrlPayResult, duplicates::LnUrlPayError> {
self.sdk.lnurl_pay(req).await.map_err(Into::into)
}
pub async fn lnurl_withdraw(
&self,
req: LnUrlWithdrawRequest,
) -> Result<duplicates::LnUrlWithdrawResult, duplicates::LnUrlWithdrawError> {
self.sdk
.lnurl_withdraw(req)
.await
.map(Into::into)
.map_err(Into::into)
}
pub async fn lnurl_auth(
&self,
req_data: LnUrlAuthRequestData,
) -> Result<duplicates::LnUrlCallbackStatus, duplicates::LnUrlAuthError> {
self.sdk
.lnurl_auth(req_data)
.await
.map(Into::into)
.map_err(Into::into)
}
pub async fn sync(&self) -> Result<(), LiquidSdkError> {
self.sdk.sync().await.map_err(Into::into)
}
@@ -156,3 +195,413 @@ impl BindingLiquidSdk {
self.sdk.disconnect().await
}
}
// === FRB mirroring
//
// This section contains frb "mirroring" structs and enums.
// These are needed by the flutter bridge in order to use structs defined in an external crate.
// See <https://cjycode.com/flutter_rust_bridge/v1/feature/lang_external.html#types-in-other-crates>
#[frb(mirror(Network))]
pub enum _Network {
Bitcoin,
Testnet,
Signet,
Regtest,
}
#[frb(mirror(LNInvoice))]
pub struct _LNInvoice {
pub bolt11: String,
pub network: Network,
pub payee_pubkey: String,
pub payment_hash: String,
pub description: Option<String>,
pub description_hash: Option<String>,
pub amount_msat: Option<u64>,
pub timestamp: u64,
pub expiry: u64,
pub routing_hints: Vec<RouteHint>,
pub payment_secret: Vec<u8>,
pub min_final_cltv_expiry_delta: u64,
}
#[frb(mirror(RouteHint))]
pub struct _RouteHint {
pub hops: Vec<RouteHintHop>,
}
#[frb(mirror(RouteHintHop))]
pub struct _RouteHintHop {
pub src_node_id: String,
pub short_channel_id: u64,
pub fees_base_msat: u32,
pub fees_proportional_millionths: u32,
pub cltv_expiry_delta: u64,
pub htlc_minimum_msat: Option<u64>,
pub htlc_maximum_msat: Option<u64>,
}
#[frb(mirror(InputType))]
pub enum _InputType {
BitcoinAddress { address: BitcoinAddressData },
Bolt11 { invoice: LNInvoice },
NodeId { node_id: String },
Url { url: String },
LnUrlPay { data: LnUrlPayRequestData },
LnUrlWithdraw { data: LnUrlWithdrawRequestData },
LnUrlAuth { data: LnUrlAuthRequestData },
LnUrlError { data: LnUrlErrorData },
}
#[frb(mirror(BitcoinAddressData))]
pub struct _BitcoinAddressData {
pub address: String,
pub network: sdk_common::prelude::Network,
pub amount_sat: Option<u64>,
pub label: Option<String>,
pub message: Option<String>,
}
#[frb(mirror(LnUrlPayRequestData))]
pub struct _LnUrlPayRequestData {
pub callback: String,
pub min_sendable: u64,
pub max_sendable: u64,
pub metadata_str: String,
pub comment_allowed: u16,
pub domain: String,
pub allows_nostr: bool,
pub nostr_pubkey: Option<String>,
pub ln_address: Option<String>,
}
#[frb(mirror(LnUrlPayRequest))]
pub struct _LnUrlPayRequest {
pub data: LnUrlPayRequestData,
pub amount_msat: u64,
pub comment: Option<String>,
pub payment_label: Option<String>,
}
#[frb(mirror(SuccessActionProcessed))]
pub enum _SuccessActionProcessed {
Aes { result: AesSuccessActionDataResult },
Message { data: MessageSuccessActionData },
Url { data: UrlSuccessActionData },
}
#[frb(mirror(AesSuccessActionDataResult))]
pub enum _AesSuccessActionDataResult {
Decrypted { data: AesSuccessActionDataDecrypted },
ErrorStatus { reason: String },
}
#[frb(mirror(AesSuccessActionDataDecrypted))]
pub struct _AesSuccessActionDataDecrypted {
pub description: String,
pub plaintext: String,
}
#[frb(mirror(MessageSuccessActionData))]
pub struct _MessageSuccessActionData {
pub message: String,
}
#[frb(mirror(UrlSuccessActionData))]
pub struct _UrlSuccessActionData {
pub description: String,
pub url: String,
}
#[frb(mirror(LnUrlPayErrorData))]
pub struct _LnUrlPayErrorData {
pub payment_hash: String,
pub reason: String,
}
#[frb(mirror(LnUrlWithdrawRequestData))]
pub struct _LnUrlWithdrawRequestData {
pub callback: String,
pub k1: String,
pub default_description: String,
pub min_withdrawable: u64,
pub max_withdrawable: u64,
}
#[frb(mirror(LnUrlAuthRequestData))]
pub struct _LnUrlAuthRequestData {
pub k1: String,
pub action: Option<String>,
pub domain: String,
pub url: String,
}
#[frb(mirror(LnUrlErrorData))]
pub struct _LnUrlErrorData {
pub reason: String,
}
#[frb(mirror(LnUrlWithdrawRequest))]
pub struct _LnUrlWithdrawRequest {
pub data: LnUrlWithdrawRequestData,
pub amount_msat: u64,
pub description: Option<String>,
}
/// External structs that cannot be mirrored for FRB, so are therefore duplicated instead
pub mod duplicates {
use sdk_common::prelude::*;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use crate::error::PaymentError;
#[derive(Clone, Debug, Error)]
pub enum LnUrlPayError {
/// This error is raised when attempting to pay an invoice that has already being paid.
#[error("Invoice already paid")]
AlreadyPaid,
/// This error is raised when a general error occurs not specific to other error variants
/// in this enum.
#[error("Generic: {err}")]
Generic { err: String },
/// This error is raised when the amount from the parsed invoice is not set.
#[error("Invalid amount: {err}")]
InvalidAmount { err: String },
/// This error is raised when the lightning invoice cannot be parsed.
#[error("Invalid invoice: {err}")]
InvalidInvoice { err: String },
/// This error is raised when the lightning invoice is for a different Bitcoin network.
#[error("Invalid network: {err}")]
InvalidNetwork { err: String },
/// This error is raised when the decoded LNURL URI is not compliant to the specification.
#[error("Invalid uri: {err}")]
InvalidUri { err: String },
/// This error is raised when the lightning invoice has passed it's expiry time.
#[error("Invoice expired: {err}")]
InvoiceExpired { err: String },
/// This error is raised when attempting to make a payment by the node fails.
#[error("Payment failed: {err}")]
PaymentFailed { err: String },
/// This error is raised when attempting to make a payment takes too long.
#[error("Payment timeout: {err}")]
PaymentTimeout { err: String },
/// This error is raised when no route can be found when attempting to make a
/// payment by the node.
#[error("Route not found: {err}")]
RouteNotFound { err: String },
/// This error is raised when the route is considered too expensive when
/// attempting to make a payment by the node.
#[error("Route too expensive: {err}")]
RouteTooExpensive { err: String },
/// This error is raised when a connection to an external service fails.
#[error("Service connectivity: {err}")]
ServiceConnectivity { err: String },
}
impl From<sdk_common::prelude::LnUrlPayError> for LnUrlPayError {
fn from(value: sdk_common::prelude::LnUrlPayError) -> Self {
match value {
sdk_common::prelude::LnUrlPayError::AlreadyPaid => Self::AlreadyPaid,
sdk_common::prelude::LnUrlPayError::Generic { err } => Self::Generic { err },
sdk_common::prelude::LnUrlPayError::InvalidAmount { err } => {
Self::InvalidAmount { err }
}
sdk_common::prelude::LnUrlPayError::InvalidInvoice { err } => {
Self::InvalidInvoice { err }
}
sdk_common::prelude::LnUrlPayError::InvalidNetwork { err } => {
Self::InvalidNetwork { err }
}
sdk_common::prelude::LnUrlPayError::InvalidUri { err } => Self::InvalidUri { err },
sdk_common::prelude::LnUrlPayError::InvoiceExpired { err } => {
Self::InvoiceExpired { err }
}
sdk_common::prelude::LnUrlPayError::PaymentFailed { err } => {
Self::PaymentFailed { err }
}
sdk_common::prelude::LnUrlPayError::PaymentTimeout { err } => {
Self::PaymentTimeout { err }
}
sdk_common::prelude::LnUrlPayError::RouteNotFound { err } => {
Self::RouteNotFound { err }
}
sdk_common::prelude::LnUrlPayError::RouteTooExpensive { err } => {
Self::RouteTooExpensive { err }
}
sdk_common::prelude::LnUrlPayError::ServiceConnectivity { err } => {
Self::ServiceConnectivity { err }
}
}
}
}
impl From<PaymentError> for sdk_common::prelude::LnUrlPayError {
fn from(value: PaymentError) -> Self {
Self::Generic {
err: format!("{value}"),
}
}
}
#[derive(Debug, Error)]
pub enum LnUrlWithdrawError {
/// This error is raised when a general error occurs not specific to other error variants
/// in this enum.
#[error("Generic: {err}")]
Generic { err: String },
/// This error is raised when the amount is zero or the amount does not cover
/// the cost to open a new channel.
#[error("Invalid amount: {err}")]
InvalidAmount { err: String },
/// This error is raised when the lightning invoice cannot be parsed.
#[error("Invalid invoice: {err}")]
InvalidInvoice { err: String },
/// This error is raised when the decoded LNURL URI is not compliant to the specification.
#[error("Invalid uri: {err}")]
InvalidUri { err: String },
/// This error is raised when no routing hints were able to be added to the invoice
/// while trying to receive a payment.
#[error("No routing hints: {err}")]
InvoiceNoRoutingHints { err: String },
/// This error is raised when a connection to an external service fails.
#[error("Service connectivity: {err}")]
ServiceConnectivity { err: String },
}
impl From<sdk_common::prelude::LnUrlWithdrawError> for LnUrlWithdrawError {
fn from(value: sdk_common::prelude::LnUrlWithdrawError) -> Self {
match value {
sdk_common::prelude::LnUrlWithdrawError::Generic { err } => Self::Generic { err },
sdk_common::prelude::LnUrlWithdrawError::InvalidAmount { err } => {
Self::InvalidAmount { err }
}
sdk_common::prelude::LnUrlWithdrawError::InvalidInvoice { err } => {
Self::InvalidInvoice { err }
}
sdk_common::prelude::LnUrlWithdrawError::InvalidUri { err } => {
Self::InvalidUri { err }
}
sdk_common::prelude::LnUrlWithdrawError::InvoiceNoRoutingHints { err } => {
Self::InvoiceNoRoutingHints { err }
}
sdk_common::prelude::LnUrlWithdrawError::ServiceConnectivity { err } => {
Self::ServiceConnectivity { err }
}
}
}
}
impl From<PaymentError> for sdk_common::prelude::LnUrlWithdrawError {
fn from(value: PaymentError) -> Self {
Self::Generic {
err: format!("{value}"),
}
}
}
#[derive(Clone, Serialize)]
pub enum LnUrlWithdrawResult {
Ok { data: LnUrlWithdrawSuccessData },
ErrorStatus { data: LnUrlErrorData },
}
impl From<sdk_common::prelude::LnUrlWithdrawResult> for LnUrlWithdrawResult {
fn from(value: sdk_common::prelude::LnUrlWithdrawResult) -> Self {
match value {
sdk_common::prelude::LnUrlWithdrawResult::Ok { data } => {
Self::Ok { data: data.into() }
}
sdk_common::prelude::LnUrlWithdrawResult::ErrorStatus { data } => {
Self::ErrorStatus { data }
}
}
}
}
#[derive(Clone, Deserialize, Debug, Serialize)]
pub struct LnUrlWithdrawSuccessData {
pub invoice: LNInvoice,
}
impl From<sdk_common::prelude::LnUrlWithdrawSuccessData> for LnUrlWithdrawSuccessData {
fn from(value: sdk_common::prelude::LnUrlWithdrawSuccessData) -> Self {
Self {
invoice: value.invoice,
}
}
}
#[derive(Debug, Error)]
pub enum LnUrlAuthError {
/// This error is raised when a general error occurs not specific to other error variants
/// in this enum.
#[error("Generic: {err}")]
Generic { err: String },
/// This error is raised when the decoded LNURL URI is not compliant to the specification.
#[error("Invalid uri: {err}")]
InvalidUri { err: String },
/// This error is raised when a connection to an external service fails.
#[error("Service connectivity: {err}")]
ServiceConnectivity { err: String },
}
impl From<sdk_common::prelude::LnUrlAuthError> for LnUrlAuthError {
fn from(value: prelude::LnUrlAuthError) -> Self {
match value {
sdk_common::prelude::LnUrlAuthError::Generic { err } => Self::Generic { err },
sdk_common::prelude::LnUrlAuthError::InvalidUri { err } => Self::InvalidUri { err },
sdk_common::prelude::LnUrlAuthError::ServiceConnectivity { err } => {
Self::ServiceConnectivity { err }
}
}
}
}
/// Contains the result of the entire LNURL interaction, as reported by the LNURL endpoint.
///
/// * `Ok` indicates the interaction with the endpoint was valid, and the endpoint
/// - started to pay the invoice asynchronously in the case of LNURL-withdraw,
/// - verified the client signature in the case of LNURL-auth,////// * `Error` indicates a generic issue the LNURL endpoint encountered, including a freetext
/// description of the reason.
///
/// Both cases are described in LUD-03 <https://github.com/lnurl/luds/blob/luds/03.md> & LUD-04: <https://github.com/lnurl/luds/blob/luds/04.md>
#[derive(Clone, Deserialize, Debug, Serialize)]
#[serde(rename_all = "UPPERCASE")]
#[serde(tag = "status")]
pub enum LnUrlCallbackStatus {
/// On-wire format is: `{"status": "OK"}`
Ok,
/// On-wire format is: `{"status": "ERROR", "reason": "error details..."}`
#[serde(rename = "ERROR")]
ErrorStatus {
#[serde(flatten)]
data: LnUrlErrorData,
},
}
impl From<sdk_common::prelude::LnUrlCallbackStatus> for LnUrlCallbackStatus {
fn from(value: prelude::LnUrlCallbackStatus) -> Self {
match value {
sdk_common::prelude::LnUrlCallbackStatus::Ok => Self::Ok,
sdk_common::prelude::LnUrlCallbackStatus::ErrorStatus { data } => {
Self::ErrorStatus { data }
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
use anyhow::Error;
use sdk_common::prelude::LnUrlAuthError;
pub type LiquidSdkResult<T, E = LiquidSdkError> = Result<T, E>;
@@ -149,3 +150,19 @@ impl From<LiquidSdkError> for PaymentError {
}
}
}
impl From<crate::bitcoin::util::bip32::Error> for PaymentError {
fn from(err: crate::bitcoin::util::bip32::Error) -> Self {
Self::SignerError {
err: err.to_string(),
}
}
}
impl From<PaymentError> for LnUrlAuthError {
fn from(value: PaymentError) -> Self {
Self::Generic {
err: format!("Failed to perform LNURL-auth: {value:?}"),
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -16,3 +16,5 @@ pub(crate) mod swapper;
pub(crate) mod test_utils;
pub(crate) mod utils;
pub(crate) mod wallet;
pub use sdk_common::prelude::*;

View File

@@ -4,10 +4,11 @@ use boltz_client::swaps::boltzv2::{
CreateChainResponse, CreateReverseResponse, CreateSubmarineResponse, Leaf, Side, SwapTree,
BOLTZ_MAINNET_URL_V2, BOLTZ_TESTNET_URL_V2,
};
use boltz_client::{BtcSwapScriptV2, BtcSwapTxV2, Keypair, LBtcSwapScriptV2, LBtcSwapTxV2, ToHex};
use boltz_client::{BtcSwapScriptV2, BtcSwapTxV2, Keypair, LBtcSwapScriptV2, LBtcSwapTxV2};
use lwk_wollet::ElementsNetwork;
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
use rusqlite::ToSql;
use sdk_common::prelude::*;
use serde::{Deserialize, Serialize};
use crate::error::PaymentError;
@@ -27,7 +28,7 @@ pub struct Config {
///
/// Prefix can be a relative or absolute path to this directory.
pub working_dir: String,
pub network: Network,
pub network: LiquidNetwork,
/// Send payment timeout. See [crate::sdk::LiquidSdk::send_payment]
pub payment_timeout_sec: u64,
/// Zero-conf minimum accepted fee-rate in sat/vbyte
@@ -44,7 +45,7 @@ impl Config {
liquid_electrum_url: "blockstream.info:995".to_string(),
bitcoin_electrum_url: "blockstream.info:700".to_string(),
working_dir: ".".to_string(),
network: Network::Mainnet,
network: LiquidNetwork::Mainnet,
payment_timeout_sec: 15,
zero_conf_min_fee_rate: DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET,
zero_conf_max_amount_sat: None,
@@ -57,7 +58,7 @@ impl Config {
liquid_electrum_url: "blockstream.info:465".to_string(),
bitcoin_electrum_url: "blockstream.info:993".to_string(),
working_dir: ".".to_string(),
network: Network::Testnet,
network: LiquidNetwork::Testnet,
payment_timeout_sec: 15,
zero_conf_min_fee_rate: DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET,
zero_conf_max_amount_sat: None,
@@ -70,62 +71,68 @@ impl Config {
}
}
/// Network chosen for this Liquid SDK instance. Note that it represents both the Liquid and the
/// Bitcoin network used.
#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
pub enum Network {
pub enum LiquidNetwork {
/// Mainnet Bitcoin and Liquid chains
Mainnet,
/// Testnet Bitcoin and Liquid chains
Testnet,
}
impl Network {
impl LiquidNetwork {
pub fn as_bitcoin_chain(&self) -> Chain {
match self {
Network::Mainnet => Chain::Bitcoin,
Network::Testnet => Chain::BitcoinTestnet,
LiquidNetwork::Mainnet => Chain::Bitcoin,
LiquidNetwork::Testnet => Chain::BitcoinTestnet,
}
}
}
impl From<Network> for ElementsNetwork {
fn from(value: Network) -> Self {
impl From<LiquidNetwork> for ElementsNetwork {
fn from(value: LiquidNetwork) -> Self {
match value {
Network::Mainnet => ElementsNetwork::Liquid,
Network::Testnet => ElementsNetwork::LiquidTestnet,
LiquidNetwork::Mainnet => ElementsNetwork::Liquid,
LiquidNetwork::Testnet => ElementsNetwork::LiquidTestnet,
}
}
}
impl From<Network> for Chain {
fn from(value: Network) -> Self {
impl From<LiquidNetwork> for Chain {
fn from(value: LiquidNetwork) -> Self {
match value {
Network::Mainnet => Chain::Liquid,
Network::Testnet => Chain::LiquidTestnet,
LiquidNetwork::Mainnet => Chain::Liquid,
LiquidNetwork::Testnet => Chain::LiquidTestnet,
}
}
}
impl TryFrom<&str> for Network {
impl TryFrom<&str> for LiquidNetwork {
type Error = anyhow::Error;
fn try_from(value: &str) -> Result<Network, anyhow::Error> {
fn try_from(value: &str) -> Result<LiquidNetwork, anyhow::Error> {
match value.to_lowercase().as_str() {
"mainnet" => Ok(Network::Mainnet),
"testnet" => Ok(Network::Testnet),
"mainnet" => Ok(LiquidNetwork::Mainnet),
"testnet" => Ok(LiquidNetwork::Testnet),
_ => Err(anyhow!("Invalid network")),
}
}
}
impl TryFrom<boltz_client::lightning_invoice::Currency> for Network {
type Error = anyhow::Error;
fn try_from(
value: boltz_client::lightning_invoice::Currency,
) -> Result<Network, anyhow::Error> {
impl From<LiquidNetwork> for sdk_common::prelude::Network {
fn from(value: LiquidNetwork) -> Self {
match value {
boltz_client::lightning_invoice::Currency::Bitcoin => Ok(Network::Mainnet),
boltz_client::lightning_invoice::Currency::BitcoinTestnet => Ok(Network::Testnet),
_ => Err(anyhow!("Invalid network")),
LiquidNetwork::Mainnet => Self::Bitcoin,
LiquidNetwork::Testnet => Self::Testnet,
}
}
}
impl From<LiquidNetwork> for sdk_common::bitcoin::Network {
fn from(value: LiquidNetwork) -> Self {
match value {
LiquidNetwork::Mainnet => Self::Bitcoin,
LiquidNetwork::Testnet => Self::Testnet,
}
}
}
@@ -879,69 +886,6 @@ pub struct LogEntry {
pub level: String,
}
/// Wrapper for a BOLT11 LN invoice
#[derive(Clone, Debug, PartialEq)]
pub struct LNInvoice {
pub bolt11: String,
pub network: Network,
pub payee_pubkey: String,
pub payment_hash: String,
pub description: Option<String>,
pub description_hash: Option<String>,
pub amount_msat: Option<u64>,
pub timestamp: u64,
pub expiry: u64,
pub routing_hints: Vec<RouteHint>,
pub payment_secret: Vec<u8>,
pub min_final_cltv_expiry_delta: u64,
}
/// A route hint for a LN payment
#[derive(Clone, Debug, PartialEq)]
pub struct RouteHint {
pub hops: Vec<RouteHintHop>,
}
impl RouteHint {
pub fn from_ldk_hint(hint: &boltz_client::lightning_invoice::RouteHint) -> RouteHint {
let mut hops = Vec::new();
for hop in hint.0.iter() {
let pubkey_res = hop.src_node_id.serialize().to_hex();
let router_hop = RouteHintHop {
src_node_id: pubkey_res,
short_channel_id: hop.short_channel_id,
fees_base_msat: hop.fees.base_msat,
fees_proportional_millionths: hop.fees.proportional_millionths,
cltv_expiry_delta: u64::from(hop.cltv_expiry_delta),
htlc_minimum_msat: hop.htlc_minimum_msat,
htlc_maximum_msat: hop.htlc_maximum_msat,
};
hops.push(router_hop);
}
RouteHint { hops }
}
}
/// Details of a specific hop in a larger route hint
#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct RouteHintHop {
/// The node_id of the non-target end of the route
pub src_node_id: String,
/// The short_channel_id of this channel
pub short_channel_id: u64,
/// The fees which must be paid to use this channel
pub fees_base_msat: u32,
pub fees_proportional_millionths: u32,
/// The difference in CLTV values between this node and the next node.
pub cltv_expiry_delta: u64,
/// The minimum value, in msat, which must be relayed to the next hop.
pub htlc_minimum_msat: Option<u64>,
/// The maximum value in msat available for routing with a single HTLC.
pub htlc_maximum_msat: Option<u64>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
struct InternalLeaf {
pub output: String,
@@ -986,6 +930,30 @@ impl From<SwapTree> for InternalSwapTree {
}
}
/// Contains the result of the entire LNURL-pay interaction, as reported by the LNURL endpoint.
///
/// * `EndpointSuccess` indicates the payment is complete. The endpoint may return a `SuccessActionProcessed`,
/// in which case, the wallet has to present it to the user as described in
/// <https://github.com/lnurl/luds/blob/luds/09.md>
///
/// * `EndpointError` indicates a generic issue the LNURL endpoint encountered, including a freetext
/// field with the reason.
///
/// * `PayError` indicates that an error occurred while trying to pay the invoice from the LNURL endpoint.
/// This includes the payment hash of the failed invoice and the failure reason.
#[derive(Serialize)]
pub enum LnUrlPayResult {
EndpointSuccess { data: LnUrlPaySuccessData },
EndpointError { data: LnUrlErrorData },
PayError { data: LnUrlPayErrorData },
}
#[derive(Serialize)]
pub struct LnUrlPaySuccessData {
pub payment: Payment,
pub success_action: Option<SuccessActionProcessed>,
}
#[macro_export]
macro_rules! get_invoice_amount {
($invoice:expr) => {

View File

@@ -4,13 +4,13 @@ use anyhow::Result;
use rusqlite::{backup::Backup, Connection};
use super::Persister;
use crate::model::Network;
use crate::model::LiquidNetwork;
impl Persister {
pub(crate) fn get_default_backup_path(&self) -> PathBuf {
self.main_db_dir.join(match self.network {
Network::Mainnet => "backup.sql",
Network::Testnet => "backup-testnet.sql",
LiquidNetwork::Mainnet => "backup.sql",
LiquidNetwork::Testnet => "backup-testnet.sql",
})
}

View File

@@ -11,16 +11,16 @@ use migrations::current_migrations;
use rusqlite::{params, Connection, OptionalExtension, Row};
use rusqlite_migration::{Migrations, M};
use crate::model::{Network::*, *};
use crate::model::{LiquidNetwork::*, *};
use crate::utils;
pub(crate) struct Persister {
main_db_dir: PathBuf,
network: Network,
network: LiquidNetwork,
}
impl Persister {
pub fn new(working_dir: &str, network: Network) -> Result<Self> {
pub fn new(working_dir: &str, network: LiquidNetwork) -> Result<Self> {
let main_db_dir = PathBuf::from_str(working_dir)?;
if !main_db_dir.exists() {
create_dir_all(&main_db_dir)?;

View File

@@ -1,16 +1,9 @@
use std::collections::HashMap;
use std::time::Instant;
use std::{
fs,
path::PathBuf,
str::FromStr,
sync::Arc,
time::{Duration, UNIX_EPOCH},
};
use std::{fs, path::PathBuf, str::FromStr, sync::Arc, time::Duration};
use anyhow::Result;
use async_trait::async_trait;
use boltz_client::lightning_invoice::Bolt11InvoiceDescription;
use boltz_client::ToHex;
use boltz_client::{swaps::boltzv2::*, util::secrets::Preimage, Bolt11Invoice};
use futures_util::stream::select_all;
@@ -18,11 +11,15 @@ use futures_util::StreamExt;
use log::{debug, error, info, warn};
use lwk_wollet::bitcoin::hex::DisplayHex;
use lwk_wollet::hashes::{sha256, Hash};
use lwk_wollet::secp256k1::ThirtyTwoByteHash;
use lwk_wollet::{elements::LockTime, ElementsNetwork};
use lwk_wollet::{ElectrumClient, ElectrumUrl};
use sdk_common::bitcoin::secp256k1::Secp256k1;
use sdk_common::bitcoin::util::bip32::ChildNumber;
use tokio::sync::{watch, Mutex, RwLock};
use tokio::time::MissedTickBehavior;
use tokio_stream::wrappers::BroadcastStream;
use url::Url;
use crate::chain::ChainService;
use crate::chain_swap::ChainSwapStateHandler;
@@ -33,13 +30,11 @@ use crate::send_swap::SendSwapStateHandler;
use crate::swapper::{BoltzSwapper, ReconnectHandler, Swapper, SwapperStatusStream};
use crate::wallet::{LiquidOnchainWallet, OnchainWallet};
use crate::{
ensure_sdk,
error::{LiquidSdkResult, PaymentError},
event::EventManager,
get_invoice_amount,
model::*,
persist::Persister,
utils,
utils, *,
};
pub const DEFAULT_DATA_DIR: &str = ".data";
@@ -511,8 +506,8 @@ impl LiquidSdk {
})?;
match (invoice.network().to_string().as_str(), self.config.network) {
("bitcoin", Network::Mainnet) => {}
("testnet", Network::Testnet) => {}
("bitcoin", LiquidNetwork::Mainnet) => {}
("testnet", LiquidNetwork::Testnet) => {}
_ => {
return Err(PaymentError::InvalidInvoice {
err: "Invoice cannot be paid on the current network".to_string(),
@@ -585,8 +580,8 @@ impl LiquidSdk {
// TODO Replace this with own address when LWK supports taproot
// https://github.com/Blockstream/lwk/issues/31
let temp_p2tr_addr = match self.config.network {
Network::Mainnet => "lq1pqvzxvqhrf54dd4sny4cag7497pe38252qefk46t92frs7us8r80ja9ha8r5me09nn22m4tmdqp5p4wafq3s59cql3v9n45t5trwtxrmxfsyxjnstkctj",
Network::Testnet => "tlq1pq0wqu32e2xacxeyps22x8gjre4qk3u6r70pj4r62hzczxeyz8x3yxucrpn79zy28plc4x37aaf33kwt6dz2nn6gtkya6h02mwpzy4eh69zzexq7cf5y5"
LiquidNetwork::Mainnet => "lq1pqvzxvqhrf54dd4sny4cag7497pe38252qefk46t92frs7us8r80ja9ha8r5me09nn22m4tmdqp5p4wafq3s59cql3v9n45t5trwtxrmxfsyxjnstkctj",
LiquidNetwork::Testnet => "tlq1pq0wqu32e2xacxeyps22x8gjre4qk3u6r70pj4r62hzczxeyz8x3yxucrpn79zy28plc4x37aaf33kwt6dz2nn6gtkya6h02mwpzy4eh69zzexq7cf5y5"
};
self.estimate_onchain_tx_fee(amount_sat, temp_p2tr_addr)
@@ -1288,64 +1283,144 @@ impl LiquidSdk {
self.persister.restore_from_backup(backup_path)
}
pub fn default_config(network: Network) -> Config {
match network {
Network::Mainnet => Config::mainnet(),
Network::Testnet => Config::testnet(),
/// Second step of LNURL-pay. The first step is `parse()`, which also validates the LNURL destination
/// and generates the `LnUrlPayRequest` payload needed here.
///
/// This call will validate the `amount_msat` and `comment` parameters of `req` against the parameters
/// of the LNURL endpoint (`req_data`). If they match the endpoint requirements, the LNURL payment
/// is made.
pub async fn lnurl_pay(&self, req: LnUrlPayRequest) -> Result<LnUrlPayResult, LnUrlPayError> {
match validate_lnurl_pay(
req.amount_msat,
&req.comment,
&req.data,
self.config.network.into(),
)
.await?
{
ValidatedCallbackResponse::EndpointError { data: e } => {
Ok(LnUrlPayResult::EndpointError { data: e })
}
ValidatedCallbackResponse::EndpointSuccess { data: cb } => {
let pay_req = self
.prepare_send_payment(&PrepareSendRequest {
invoice: cb.pr.clone(),
})
.await?;
let payment = self.send_payment(&pay_req).await?.payment;
let maybe_sa_processed: Option<SuccessActionProcessed> = match cb.success_action {
Some(sa) => {
let processed_sa = match sa {
// For AES, we decrypt the contents on the fly
SuccessAction::Aes(data) => {
let preimage_str = payment
.preimage
.clone()
.ok_or(LiquidSdkError::Generic {
err: "Payment successful but no preimage found".to_string(),
})
.unwrap();
let preimage =
sha256::Hash::from_str(&preimage_str).map_err(|_| {
sdk_common::prelude::LnUrlPayError::Generic {
err: "Invalid preimage".to_string(),
}
})?;
let preimage_arr: [u8; 32] = preimage.into_32();
let result = match (data, &preimage_arr).try_into() {
Ok(data) => AesSuccessActionDataResult::Decrypted { data },
Err(e) => AesSuccessActionDataResult::ErrorStatus {
reason: e.to_string(),
},
};
SuccessActionProcessed::Aes { result }
}
SuccessAction::Message(data) => {
SuccessActionProcessed::Message { data }
}
SuccessAction::Url(data) => SuccessActionProcessed::Url { data },
};
Some(processed_sa)
}
None => None,
};
Ok(LnUrlPayResult::EndpointSuccess {
data: model::LnUrlPaySuccessData {
payment,
success_action: maybe_sa_processed,
},
})
}
}
}
/// Second step of LNURL-withdraw. The first step is `parse()`, which also validates the LNURL destination
/// and generates the `LnUrlWithdrawRequest` payload needed here.
///
/// This call will validate the given `amount_msat` against the parameters
/// of the LNURL endpoint (`data`). If they match the endpoint requirements, the LNURL withdraw
/// request is made. A successful result here means the endpoint started the payment.
pub async fn lnurl_withdraw(
&self,
req: LnUrlWithdrawRequest,
) -> Result<LnUrlWithdrawResult, sdk_common::prelude::LnUrlWithdrawError> {
let prepare_receive_res = self
.prepare_receive_payment(&{
PrepareReceiveRequest {
payer_amount_sat: req.amount_msat / 1_000,
}
})
.await?;
let receive_res = self.receive_payment(&prepare_receive_res).await?;
let invoice = parse_invoice(&receive_res.invoice)?;
let res = validate_lnurl_withdraw(req.data, invoice).await?;
Ok(res)
}
/// Third and last step of LNURL-auth. The first step is `parse()`, which also validates the LNURL destination
/// and generates the `LnUrlAuthRequestData` payload needed here. The second step is user approval of auth action.
///
/// This call will sign `k1` of the LNURL endpoint (`req_data`) on `secp256k1` using `linkingPrivKey` and DER-encodes the signature.
/// If they match the endpoint requirements, the LNURL auth request is made. A successful result here means the client signature is verified.
pub async fn lnurl_auth(
&self,
req_data: LnUrlAuthRequestData,
) -> Result<LnUrlCallbackStatus, LnUrlAuthError> {
// m/138'/0
let hashing_key = self.onchain_wallet.derive_bip32_key(vec![
ChildNumber::from_hardened_idx(138).map_err(Into::<LnUrlError>::into)?,
ChildNumber::from(0),
])?;
let url =
Url::from_str(&req_data.url).map_err(|e| LnUrlError::InvalidUri(e.to_string()))?;
let derivation_path = get_derivation_path(hashing_key, url)?;
let linking_key = self.onchain_wallet.derive_bip32_key(derivation_path)?;
let linking_keys = linking_key.to_keypair(&Secp256k1::new());
Ok(perform_lnurl_auth(linking_keys, req_data).await?)
}
pub fn default_config(network: LiquidNetwork) -> Config {
match network {
LiquidNetwork::Mainnet => Config::mainnet(),
LiquidNetwork::Testnet => Config::testnet(),
}
}
pub async fn parse(input: &str) -> Result<InputType, PaymentError> {
parse(input)
.await
.map_err(|e| PaymentError::Generic { err: e.to_string() })
}
pub fn parse_invoice(input: &str) -> Result<LNInvoice, PaymentError> {
let input = input
.strip_prefix("lightning:")
.or(input.strip_prefix("LIGHTNING:"))
.unwrap_or(input);
let invoice =
Bolt11Invoice::from_str(input).map_err(|err| PaymentError::InvalidInvoice {
err: err.to_string(),
})?;
// Try to take payee pubkey from the tagged fields, if doesn't exist recover it from the signature
let payee_pubkey: String = match invoice.payee_pub_key() {
Some(key) => key.serialize().to_hex(),
None => invoice.recover_payee_pub_key().serialize().to_hex(),
};
let description = match invoice.description() {
Bolt11InvoiceDescription::Direct(msg) => Some(msg.to_string()),
Bolt11InvoiceDescription::Hash(_) => None,
};
let description_hash = match invoice.description() {
Bolt11InvoiceDescription::Direct(_) => None,
Bolt11InvoiceDescription::Hash(h) => Some(h.0.to_string()),
};
let timestamp = invoice
.timestamp()
.duration_since(UNIX_EPOCH)
.map_err(|err| PaymentError::InvalidInvoice {
err: err.to_string(),
})?
.as_secs();
let routing_hints = invoice
.route_hints()
.iter()
.map(RouteHint::from_ldk_hint)
.collect();
let res = LNInvoice {
bolt11: input.to_string(),
network: invoice.currency().try_into()?,
payee_pubkey,
payment_hash: invoice.payment_hash().to_hex(),
description,
description_hash,
amount_msat: invoice.amount_milli_satoshis(),
timestamp,
expiry: invoice.expiry_time().as_secs(),
routing_hints,
payment_secret: invoice.payment_secret().0.to_vec(),
min_final_cltv_expiry_delta: invoice.min_final_cltv_expiry_delta(),
};
Ok(res)
parse_invoice(input).map_err(|e| PaymentError::InvalidInvoice { err: e.to_string() })
}
/// Configures a global SDK logger that will log to file and will forward log events to

View File

@@ -23,7 +23,7 @@ use tokio::sync::{broadcast, watch};
use crate::error::PaymentError;
use crate::model::{
ChainSwap, Config, Direction, Network, ReceiveSwap, SendSwap, SwapScriptV2, SwapTxV2,
ChainSwap, Config, Direction, LiquidNetwork, ReceiveSwap, SendSwap, SwapScriptV2, SwapTxV2,
};
use crate::utils;
@@ -349,8 +349,8 @@ impl BoltzSwapper {
is_cooperative,
)?;
let is_lowball = match self.config.network {
Network::Mainnet => None,
Network::Testnet => {
LiquidNetwork::Mainnet => None,
LiquidNetwork::Testnet => {
Some((&self.client, boltz_client::network::Chain::LiquidTestnet))
}
};
@@ -423,8 +423,8 @@ impl BoltzSwapper {
None,
)?;
let is_lowball = match self.config.network {
Network::Mainnet => None,
Network::Testnet => {
LiquidNetwork::Mainnet => None,
LiquidNetwork::Testnet => {
Some((&self.client, boltz_client::network::Chain::LiquidTestnet))
}
};

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use crate::{
chain_swap::ChainSwapStateHandler,
model::{
ChainSwap, Config, Direction, Network, PaymentState, PaymentTxData, PaymentType,
ChainSwap, Config, Direction, LiquidNetwork, PaymentState, PaymentTxData, PaymentType,
ReceiveSwap, SendSwap,
},
persist::Persister,
@@ -162,7 +162,7 @@ pub(crate) fn new_persister() -> Result<(TempDir, Persister)> {
.path()
.to_str()
.ok_or(anyhow!("Could not create temporary directory"))?,
Network::Testnet,
LiquidNetwork::Testnet,
)?;
persister.init()?;
Ok((temp_dir, persister))

View File

@@ -11,11 +11,13 @@ use lwk_wollet::{
ElectrumClient, ElectrumUrl, ElementsNetwork, FsPersister, Tip, WalletTx, Wollet,
WolletDescriptor,
};
use sdk_common::bitcoin::secp256k1::Secp256k1;
use sdk_common::bitcoin::util::bip32::{ChildNumber, ExtendedPrivKey};
use tokio::sync::Mutex;
use crate::{
error::PaymentError,
model::{Config, Network},
model::{Config, LiquidNetwork},
};
#[async_trait]
@@ -40,6 +42,8 @@ pub trait OnchainWallet: Send + Sync {
/// Get the public key of the wallet
fn pubkey(&self) -> String;
fn derive_bip32_key(&self, path: Vec<ChildNumber>) -> Result<ExtendedPrivKey, PaymentError>;
/// Perform a full scan of the wallet
async fn full_scan(&self) -> Result<(), PaymentError>;
}
@@ -52,7 +56,7 @@ pub(crate) struct LiquidOnchainWallet {
impl LiquidOnchainWallet {
pub(crate) fn new(mnemonic: String, config: Config) -> Result<Self> {
let is_mainnet = config.network == Network::Mainnet;
let is_mainnet = config.network == LiquidNetwork::Mainnet;
let lwk_signer = SwSigner::new(&mnemonic, is_mainnet)?;
let descriptor = LiquidOnchainWallet::get_descriptor(&lwk_signer, config.network)?;
let elements_network: ElementsNetwork = config.network.into();
@@ -69,9 +73,9 @@ impl LiquidOnchainWallet {
fn get_descriptor(
signer: &SwSigner,
network: Network,
network: LiquidNetwork,
) -> Result<WolletDescriptor, PaymentError> {
let is_mainnet = network == Network::Mainnet;
let is_mainnet = network == LiquidNetwork::Mainnet;
let descriptor_str = singlesig_desc(
signer,
Singlesig::Wpkh,
@@ -145,4 +149,14 @@ impl OnchainWallet for LiquidOnchainWallet {
lwk_wollet::full_scan_with_electrum_client(&mut wallet, &mut electrum_client)?;
Ok(())
}
fn derive_bip32_key(&self, path: Vec<ChildNumber>) -> Result<ExtendedPrivKey, PaymentError> {
let seed = self.lwk_signer.seed().ok_or(PaymentError::SignerError {
err: "Could not get signer seed".to_string(),
})?;
let bip32_xpriv = ExtendedPrivKey::new_master(self.config.network.into(), &seed)?
.derive_priv(&Secp256k1::new(), &path)?;
Ok(bip32_xpriv)
}
}

View File

@@ -3,10 +3,13 @@
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
import 'bindings/duplicates.dart';
import 'error.dart';
import 'frb_generated.dart';
import 'model.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'bindings.freezed.dart';
// These functions are ignored because they are not marked as `pub`: `init`
// These types are ignored because they are not used by any `pub` functions: `DartBindingLogger`
@@ -17,9 +20,11 @@ Future<BindingLiquidSdk> connect({required ConnectRequest req}) =>
/// If used, this must be called before `connect`. It can only be called once.
Stream<LogEntry> breezLogStream() => RustLib.instance.api.crateBindingsBreezLogStream();
Config defaultConfig({required Network network}) =>
Config defaultConfig({required LiquidNetwork network}) =>
RustLib.instance.api.crateBindingsDefaultConfig(network: network);
Future<InputType> parse({required String input}) => RustLib.instance.api.crateBindingsParse(input: input);
LNInvoice parseInvoice({required String input}) =>
RustLib.instance.api.crateBindingsParseInvoice(input: input);
@@ -37,6 +42,12 @@ abstract class BindingLiquidSdk implements RustOpaqueInterface {
Future<List<Payment>> listPayments();
Future<LnUrlCallbackStatus> lnurlAuth({required LnUrlAuthRequestData reqData});
Future<LnUrlPayResult> lnurlPay({required LnUrlPayRequest req});
Future<LnUrlWithdrawResult> lnurlWithdraw({required LnUrlWithdrawRequest req});
Future<SendPaymentResponse> payOnchain({required PayOnchainRequest req});
Future<PreparePayOnchainResponse> preparePayOnchain({required PreparePayOnchainRequest req});
@@ -54,6 +65,39 @@ abstract class BindingLiquidSdk implements RustOpaqueInterface {
Future<void> sync();
}
class AesSuccessActionDataDecrypted {
final String description;
final String plaintext;
const AesSuccessActionDataDecrypted({
required this.description,
required this.plaintext,
});
@override
int get hashCode => description.hashCode ^ plaintext.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is AesSuccessActionDataDecrypted &&
runtimeType == other.runtimeType &&
description == other.description &&
plaintext == other.plaintext;
}
@freezed
sealed class AesSuccessActionDataResult with _$AesSuccessActionDataResult {
const AesSuccessActionDataResult._();
const factory AesSuccessActionDataResult.decrypted({
required AesSuccessActionDataDecrypted data,
}) = AesSuccessActionDataResult_Decrypted;
const factory AesSuccessActionDataResult.errorStatus({
required String reason,
}) = AesSuccessActionDataResult_ErrorStatus;
}
class BindingEventListener {
final RustStreamSink<LiquidSdkEvent> stream;
@@ -72,3 +116,446 @@ class BindingEventListener {
identical(this, other) ||
other is BindingEventListener && runtimeType == other.runtimeType && stream == other.stream;
}
class BitcoinAddressData {
final String address;
final Network network;
final BigInt? amountSat;
final String? label;
final String? message;
const BitcoinAddressData({
required this.address,
required this.network,
this.amountSat,
this.label,
this.message,
});
@override
int get hashCode =>
address.hashCode ^ network.hashCode ^ amountSat.hashCode ^ label.hashCode ^ message.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BitcoinAddressData &&
runtimeType == other.runtimeType &&
address == other.address &&
network == other.network &&
amountSat == other.amountSat &&
label == other.label &&
message == other.message;
}
@freezed
sealed class InputType with _$InputType {
const InputType._();
const factory InputType.bitcoinAddress({
required BitcoinAddressData address,
}) = InputType_BitcoinAddress;
const factory InputType.bolt11({
required LNInvoice invoice,
}) = InputType_Bolt11;
const factory InputType.nodeId({
required String nodeId,
}) = InputType_NodeId;
const factory InputType.url({
required String url,
}) = InputType_Url;
const factory InputType.lnUrlPay({
required LnUrlPayRequestData data,
}) = InputType_LnUrlPay;
const factory InputType.lnUrlWithdraw({
required LnUrlWithdrawRequestData data,
}) = InputType_LnUrlWithdraw;
const factory InputType.lnUrlAuth({
required LnUrlAuthRequestData data,
}) = InputType_LnUrlAuth;
const factory InputType.lnUrlError({
required LnUrlErrorData data,
}) = InputType_LnUrlError;
}
class LNInvoice {
final String bolt11;
final Network network;
final String payeePubkey;
final String paymentHash;
final String? description;
final String? descriptionHash;
final BigInt? amountMsat;
final BigInt timestamp;
final BigInt expiry;
final List<RouteHint> routingHints;
final Uint8List paymentSecret;
final BigInt minFinalCltvExpiryDelta;
const LNInvoice({
required this.bolt11,
required this.network,
required this.payeePubkey,
required this.paymentHash,
this.description,
this.descriptionHash,
this.amountMsat,
required this.timestamp,
required this.expiry,
required this.routingHints,
required this.paymentSecret,
required this.minFinalCltvExpiryDelta,
});
@override
int get hashCode =>
bolt11.hashCode ^
network.hashCode ^
payeePubkey.hashCode ^
paymentHash.hashCode ^
description.hashCode ^
descriptionHash.hashCode ^
amountMsat.hashCode ^
timestamp.hashCode ^
expiry.hashCode ^
routingHints.hashCode ^
paymentSecret.hashCode ^
minFinalCltvExpiryDelta.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LNInvoice &&
runtimeType == other.runtimeType &&
bolt11 == other.bolt11 &&
network == other.network &&
payeePubkey == other.payeePubkey &&
paymentHash == other.paymentHash &&
description == other.description &&
descriptionHash == other.descriptionHash &&
amountMsat == other.amountMsat &&
timestamp == other.timestamp &&
expiry == other.expiry &&
routingHints == other.routingHints &&
paymentSecret == other.paymentSecret &&
minFinalCltvExpiryDelta == other.minFinalCltvExpiryDelta;
}
class LnUrlAuthRequestData {
final String k1;
final String? action;
final String domain;
final String url;
const LnUrlAuthRequestData({
required this.k1,
this.action,
required this.domain,
required this.url,
});
@override
int get hashCode => k1.hashCode ^ action.hashCode ^ domain.hashCode ^ url.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlAuthRequestData &&
runtimeType == other.runtimeType &&
k1 == other.k1 &&
action == other.action &&
domain == other.domain &&
url == other.url;
}
class LnUrlErrorData {
final String reason;
const LnUrlErrorData({
required this.reason,
});
@override
int get hashCode => reason.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlErrorData && runtimeType == other.runtimeType && reason == other.reason;
}
class LnUrlPayErrorData {
final String paymentHash;
final String reason;
const LnUrlPayErrorData({
required this.paymentHash,
required this.reason,
});
@override
int get hashCode => paymentHash.hashCode ^ reason.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlPayErrorData &&
runtimeType == other.runtimeType &&
paymentHash == other.paymentHash &&
reason == other.reason;
}
class LnUrlPayRequest {
final LnUrlPayRequestData data;
final BigInt amountMsat;
final String? comment;
final String? paymentLabel;
const LnUrlPayRequest({
required this.data,
required this.amountMsat,
this.comment,
this.paymentLabel,
});
@override
int get hashCode => data.hashCode ^ amountMsat.hashCode ^ comment.hashCode ^ paymentLabel.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlPayRequest &&
runtimeType == other.runtimeType &&
data == other.data &&
amountMsat == other.amountMsat &&
comment == other.comment &&
paymentLabel == other.paymentLabel;
}
class LnUrlPayRequestData {
final String callback;
final BigInt minSendable;
final BigInt maxSendable;
final String metadataStr;
final int commentAllowed;
final String domain;
final bool allowsNostr;
final String? nostrPubkey;
final String? lnAddress;
const LnUrlPayRequestData({
required this.callback,
required this.minSendable,
required this.maxSendable,
required this.metadataStr,
required this.commentAllowed,
required this.domain,
required this.allowsNostr,
this.nostrPubkey,
this.lnAddress,
});
@override
int get hashCode =>
callback.hashCode ^
minSendable.hashCode ^
maxSendable.hashCode ^
metadataStr.hashCode ^
commentAllowed.hashCode ^
domain.hashCode ^
allowsNostr.hashCode ^
nostrPubkey.hashCode ^
lnAddress.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlPayRequestData &&
runtimeType == other.runtimeType &&
callback == other.callback &&
minSendable == other.minSendable &&
maxSendable == other.maxSendable &&
metadataStr == other.metadataStr &&
commentAllowed == other.commentAllowed &&
domain == other.domain &&
allowsNostr == other.allowsNostr &&
nostrPubkey == other.nostrPubkey &&
lnAddress == other.lnAddress;
}
class LnUrlWithdrawRequest {
final LnUrlWithdrawRequestData data;
final BigInt amountMsat;
final String? description;
const LnUrlWithdrawRequest({
required this.data,
required this.amountMsat,
this.description,
});
@override
int get hashCode => data.hashCode ^ amountMsat.hashCode ^ description.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlWithdrawRequest &&
runtimeType == other.runtimeType &&
data == other.data &&
amountMsat == other.amountMsat &&
description == other.description;
}
class LnUrlWithdrawRequestData {
final String callback;
final String k1;
final String defaultDescription;
final BigInt minWithdrawable;
final BigInt maxWithdrawable;
const LnUrlWithdrawRequestData({
required this.callback,
required this.k1,
required this.defaultDescription,
required this.minWithdrawable,
required this.maxWithdrawable,
});
@override
int get hashCode =>
callback.hashCode ^
k1.hashCode ^
defaultDescription.hashCode ^
minWithdrawable.hashCode ^
maxWithdrawable.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlWithdrawRequestData &&
runtimeType == other.runtimeType &&
callback == other.callback &&
k1 == other.k1 &&
defaultDescription == other.defaultDescription &&
minWithdrawable == other.minWithdrawable &&
maxWithdrawable == other.maxWithdrawable;
}
class MessageSuccessActionData {
final String message;
const MessageSuccessActionData({
required this.message,
});
@override
int get hashCode => message.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is MessageSuccessActionData && runtimeType == other.runtimeType && message == other.message;
}
enum Network {
bitcoin,
testnet,
signet,
regtest,
;
}
class RouteHint {
final List<RouteHintHop> hops;
const RouteHint({
required this.hops,
});
@override
int get hashCode => hops.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) || other is RouteHint && runtimeType == other.runtimeType && hops == other.hops;
}
class RouteHintHop {
final String srcNodeId;
final BigInt shortChannelId;
final int feesBaseMsat;
final int feesProportionalMillionths;
final BigInt cltvExpiryDelta;
final BigInt? htlcMinimumMsat;
final BigInt? htlcMaximumMsat;
const RouteHintHop({
required this.srcNodeId,
required this.shortChannelId,
required this.feesBaseMsat,
required this.feesProportionalMillionths,
required this.cltvExpiryDelta,
this.htlcMinimumMsat,
this.htlcMaximumMsat,
});
@override
int get hashCode =>
srcNodeId.hashCode ^
shortChannelId.hashCode ^
feesBaseMsat.hashCode ^
feesProportionalMillionths.hashCode ^
cltvExpiryDelta.hashCode ^
htlcMinimumMsat.hashCode ^
htlcMaximumMsat.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RouteHintHop &&
runtimeType == other.runtimeType &&
srcNodeId == other.srcNodeId &&
shortChannelId == other.shortChannelId &&
feesBaseMsat == other.feesBaseMsat &&
feesProportionalMillionths == other.feesProportionalMillionths &&
cltvExpiryDelta == other.cltvExpiryDelta &&
htlcMinimumMsat == other.htlcMinimumMsat &&
htlcMaximumMsat == other.htlcMaximumMsat;
}
@freezed
sealed class SuccessActionProcessed with _$SuccessActionProcessed {
const SuccessActionProcessed._();
const factory SuccessActionProcessed.aes({
required AesSuccessActionDataResult result,
}) = SuccessActionProcessed_Aes;
const factory SuccessActionProcessed.message({
required MessageSuccessActionData data,
}) = SuccessActionProcessed_Message;
const factory SuccessActionProcessed.url({
required UrlSuccessActionData data,
}) = SuccessActionProcessed_Url;
}
class UrlSuccessActionData {
final String description;
final String url;
const UrlSuccessActionData({
required this.description,
required this.url,
});
@override
int get hashCode => description.hashCode ^ url.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is UrlSuccessActionData &&
runtimeType == other.runtimeType &&
description == other.description &&
url == other.url;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
import 'bindings.dart';
import 'frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
@@ -38,7 +39,7 @@ class Config {
///
/// Prefix can be a relative or absolute path to this directory.
final String workingDir;
final Network network;
final LiquidNetwork network;
/// Send payment timeout. See [crate::sdk::LiquidSdk::send_payment]
final BigInt paymentTimeoutSec;
@@ -141,6 +142,17 @@ class GetInfoResponse {
pubkey == other.pubkey;
}
/// Network chosen for this Liquid SDK instance. Note that it represents both the Liquid and the
/// Bitcoin network used.
enum LiquidNetwork {
/// Mainnet Bitcoin and Liquid chains
mainnet,
/// Testnet Bitcoin and Liquid chains
testnet,
;
}
@freezed
sealed class LiquidSdkEvent with _$LiquidSdkEvent {
const LiquidSdkEvent._();
@@ -166,68 +178,40 @@ sealed class LiquidSdkEvent with _$LiquidSdkEvent {
const factory LiquidSdkEvent.synced() = LiquidSdkEvent_Synced;
}
/// Wrapper for a BOLT11 LN invoice
class LNInvoice {
final String bolt11;
final Network network;
final String payeePubkey;
final String paymentHash;
final String? description;
final String? descriptionHash;
final BigInt? amountMsat;
final BigInt timestamp;
final BigInt expiry;
final List<RouteHint> routingHints;
final Uint8List paymentSecret;
final BigInt minFinalCltvExpiryDelta;
@freezed
sealed class LnUrlPayResult with _$LnUrlPayResult {
const LnUrlPayResult._();
const LNInvoice({
required this.bolt11,
required this.network,
required this.payeePubkey,
required this.paymentHash,
this.description,
this.descriptionHash,
this.amountMsat,
required this.timestamp,
required this.expiry,
required this.routingHints,
required this.paymentSecret,
required this.minFinalCltvExpiryDelta,
const factory LnUrlPayResult.endpointSuccess({
required LnUrlPaySuccessData data,
}) = LnUrlPayResult_EndpointSuccess;
const factory LnUrlPayResult.endpointError({
required LnUrlErrorData data,
}) = LnUrlPayResult_EndpointError;
const factory LnUrlPayResult.payError({
required LnUrlPayErrorData data,
}) = LnUrlPayResult_PayError;
}
class LnUrlPaySuccessData {
final Payment payment;
final SuccessActionProcessed? successAction;
const LnUrlPaySuccessData({
required this.payment,
this.successAction,
});
@override
int get hashCode =>
bolt11.hashCode ^
network.hashCode ^
payeePubkey.hashCode ^
paymentHash.hashCode ^
description.hashCode ^
descriptionHash.hashCode ^
amountMsat.hashCode ^
timestamp.hashCode ^
expiry.hashCode ^
routingHints.hashCode ^
paymentSecret.hashCode ^
minFinalCltvExpiryDelta.hashCode;
int get hashCode => payment.hashCode ^ successAction.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LNInvoice &&
other is LnUrlPaySuccessData &&
runtimeType == other.runtimeType &&
bolt11 == other.bolt11 &&
network == other.network &&
payeePubkey == other.payeePubkey &&
paymentHash == other.paymentHash &&
description == other.description &&
descriptionHash == other.descriptionHash &&
amountMsat == other.amountMsat &&
timestamp == other.timestamp &&
expiry == other.expiry &&
routingHints == other.routingHints &&
paymentSecret == other.paymentSecret &&
minFinalCltvExpiryDelta == other.minFinalCltvExpiryDelta;
payment == other.payment &&
successAction == other.successAction;
}
/// Internal SDK log entry used in the Uniffi and Dart bindings
@@ -249,15 +233,6 @@ class LogEntry {
other is LogEntry && runtimeType == other.runtimeType && line == other.line && level == other.level;
}
enum Network {
/// Mainnet Bitcoin and Liquid chains
mainnet,
/// Testnet Bitcoin and Liquid chains
testnet,
;
}
class PayOnchainRequest {
final String address;
final PreparePayOnchainResponse prepareRes;
@@ -593,77 +568,6 @@ class RestoreRequest {
other is RestoreRequest && runtimeType == other.runtimeType && backupPath == other.backupPath;
}
/// A route hint for a LN payment
class RouteHint {
final List<RouteHintHop> hops;
const RouteHint({
required this.hops,
});
@override
int get hashCode => hops.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) || other is RouteHint && runtimeType == other.runtimeType && hops == other.hops;
}
/// Details of a specific hop in a larger route hint
class RouteHintHop {
/// The node_id of the non-target end of the route
final String srcNodeId;
/// The short_channel_id of this channel
final BigInt shortChannelId;
/// The fees which must be paid to use this channel
final int feesBaseMsat;
final int feesProportionalMillionths;
/// The difference in CLTV values between this node and the next node.
final BigInt cltvExpiryDelta;
/// The minimum value, in msat, which must be relayed to the next hop.
final BigInt? htlcMinimumMsat;
/// The maximum value in msat available for routing with a single HTLC.
final BigInt? htlcMaximumMsat;
const RouteHintHop({
required this.srcNodeId,
required this.shortChannelId,
required this.feesBaseMsat,
required this.feesProportionalMillionths,
required this.cltvExpiryDelta,
this.htlcMinimumMsat,
this.htlcMaximumMsat,
});
@override
int get hashCode =>
srcNodeId.hashCode ^
shortChannelId.hashCode ^
feesBaseMsat.hashCode ^
feesProportionalMillionths.hashCode ^
cltvExpiryDelta.hashCode ^
htlcMinimumMsat.hashCode ^
htlcMaximumMsat.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RouteHintHop &&
runtimeType == other.runtimeType &&
srcNodeId == other.srcNodeId &&
shortChannelId == other.shortChannelId &&
feesBaseMsat == other.feesBaseMsat &&
feesProportionalMillionths == other.feesProportionalMillionths &&
cltvExpiryDelta == other.cltvExpiryDelta &&
htlcMinimumMsat == other.htlcMinimumMsat &&
htlcMaximumMsat == other.htlcMaximumMsat;
}
class SendPaymentResponse {
final Payment payment;

View File

@@ -520,3 +520,248 @@ abstract class LiquidSdkEvent_Synced extends LiquidSdkEvent {
const factory LiquidSdkEvent_Synced() = _$LiquidSdkEvent_SyncedImpl;
const LiquidSdkEvent_Synced._() : super._();
}
/// @nodoc
mixin _$LnUrlPayResult {
Object get data => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LnUrlPayResultCopyWith<$Res> {
factory $LnUrlPayResultCopyWith(LnUrlPayResult value, $Res Function(LnUrlPayResult) then) =
_$LnUrlPayResultCopyWithImpl<$Res, LnUrlPayResult>;
}
/// @nodoc
class _$LnUrlPayResultCopyWithImpl<$Res, $Val extends LnUrlPayResult>
implements $LnUrlPayResultCopyWith<$Res> {
_$LnUrlPayResultCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
}
/// @nodoc
abstract class _$$LnUrlPayResult_EndpointSuccessImplCopyWith<$Res> {
factory _$$LnUrlPayResult_EndpointSuccessImplCopyWith(_$LnUrlPayResult_EndpointSuccessImpl value,
$Res Function(_$LnUrlPayResult_EndpointSuccessImpl) then) =
__$$LnUrlPayResult_EndpointSuccessImplCopyWithImpl<$Res>;
@useResult
$Res call({LnUrlPaySuccessData data});
}
/// @nodoc
class __$$LnUrlPayResult_EndpointSuccessImplCopyWithImpl<$Res>
extends _$LnUrlPayResultCopyWithImpl<$Res, _$LnUrlPayResult_EndpointSuccessImpl>
implements _$$LnUrlPayResult_EndpointSuccessImplCopyWith<$Res> {
__$$LnUrlPayResult_EndpointSuccessImplCopyWithImpl(
_$LnUrlPayResult_EndpointSuccessImpl _value, $Res Function(_$LnUrlPayResult_EndpointSuccessImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? data = null,
}) {
return _then(_$LnUrlPayResult_EndpointSuccessImpl(
data: null == data
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as LnUrlPaySuccessData,
));
}
}
/// @nodoc
class _$LnUrlPayResult_EndpointSuccessImpl extends LnUrlPayResult_EndpointSuccess {
const _$LnUrlPayResult_EndpointSuccessImpl({required this.data}) : super._();
@override
final LnUrlPaySuccessData data;
@override
String toString() {
return 'LnUrlPayResult.endpointSuccess(data: $data)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LnUrlPayResult_EndpointSuccessImpl &&
(identical(other.data, data) || other.data == data));
}
@override
int get hashCode => Object.hash(runtimeType, data);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$LnUrlPayResult_EndpointSuccessImplCopyWith<_$LnUrlPayResult_EndpointSuccessImpl> get copyWith =>
__$$LnUrlPayResult_EndpointSuccessImplCopyWithImpl<_$LnUrlPayResult_EndpointSuccessImpl>(
this, _$identity);
}
abstract class LnUrlPayResult_EndpointSuccess extends LnUrlPayResult {
const factory LnUrlPayResult_EndpointSuccess({required final LnUrlPaySuccessData data}) =
_$LnUrlPayResult_EndpointSuccessImpl;
const LnUrlPayResult_EndpointSuccess._() : super._();
@override
LnUrlPaySuccessData get data;
@JsonKey(ignore: true)
_$$LnUrlPayResult_EndpointSuccessImplCopyWith<_$LnUrlPayResult_EndpointSuccessImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$LnUrlPayResult_EndpointErrorImplCopyWith<$Res> {
factory _$$LnUrlPayResult_EndpointErrorImplCopyWith(
_$LnUrlPayResult_EndpointErrorImpl value, $Res Function(_$LnUrlPayResult_EndpointErrorImpl) then) =
__$$LnUrlPayResult_EndpointErrorImplCopyWithImpl<$Res>;
@useResult
$Res call({LnUrlErrorData data});
}
/// @nodoc
class __$$LnUrlPayResult_EndpointErrorImplCopyWithImpl<$Res>
extends _$LnUrlPayResultCopyWithImpl<$Res, _$LnUrlPayResult_EndpointErrorImpl>
implements _$$LnUrlPayResult_EndpointErrorImplCopyWith<$Res> {
__$$LnUrlPayResult_EndpointErrorImplCopyWithImpl(
_$LnUrlPayResult_EndpointErrorImpl _value, $Res Function(_$LnUrlPayResult_EndpointErrorImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? data = null,
}) {
return _then(_$LnUrlPayResult_EndpointErrorImpl(
data: null == data
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as LnUrlErrorData,
));
}
}
/// @nodoc
class _$LnUrlPayResult_EndpointErrorImpl extends LnUrlPayResult_EndpointError {
const _$LnUrlPayResult_EndpointErrorImpl({required this.data}) : super._();
@override
final LnUrlErrorData data;
@override
String toString() {
return 'LnUrlPayResult.endpointError(data: $data)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LnUrlPayResult_EndpointErrorImpl &&
(identical(other.data, data) || other.data == data));
}
@override
int get hashCode => Object.hash(runtimeType, data);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$LnUrlPayResult_EndpointErrorImplCopyWith<_$LnUrlPayResult_EndpointErrorImpl> get copyWith =>
__$$LnUrlPayResult_EndpointErrorImplCopyWithImpl<_$LnUrlPayResult_EndpointErrorImpl>(this, _$identity);
}
abstract class LnUrlPayResult_EndpointError extends LnUrlPayResult {
const factory LnUrlPayResult_EndpointError({required final LnUrlErrorData data}) =
_$LnUrlPayResult_EndpointErrorImpl;
const LnUrlPayResult_EndpointError._() : super._();
@override
LnUrlErrorData get data;
@JsonKey(ignore: true)
_$$LnUrlPayResult_EndpointErrorImplCopyWith<_$LnUrlPayResult_EndpointErrorImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$LnUrlPayResult_PayErrorImplCopyWith<$Res> {
factory _$$LnUrlPayResult_PayErrorImplCopyWith(
_$LnUrlPayResult_PayErrorImpl value, $Res Function(_$LnUrlPayResult_PayErrorImpl) then) =
__$$LnUrlPayResult_PayErrorImplCopyWithImpl<$Res>;
@useResult
$Res call({LnUrlPayErrorData data});
}
/// @nodoc
class __$$LnUrlPayResult_PayErrorImplCopyWithImpl<$Res>
extends _$LnUrlPayResultCopyWithImpl<$Res, _$LnUrlPayResult_PayErrorImpl>
implements _$$LnUrlPayResult_PayErrorImplCopyWith<$Res> {
__$$LnUrlPayResult_PayErrorImplCopyWithImpl(
_$LnUrlPayResult_PayErrorImpl _value, $Res Function(_$LnUrlPayResult_PayErrorImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? data = null,
}) {
return _then(_$LnUrlPayResult_PayErrorImpl(
data: null == data
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as LnUrlPayErrorData,
));
}
}
/// @nodoc
class _$LnUrlPayResult_PayErrorImpl extends LnUrlPayResult_PayError {
const _$LnUrlPayResult_PayErrorImpl({required this.data}) : super._();
@override
final LnUrlPayErrorData data;
@override
String toString() {
return 'LnUrlPayResult.payError(data: $data)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LnUrlPayResult_PayErrorImpl &&
(identical(other.data, data) || other.data == data));
}
@override
int get hashCode => Object.hash(runtimeType, data);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$LnUrlPayResult_PayErrorImplCopyWith<_$LnUrlPayResult_PayErrorImpl> get copyWith =>
__$$LnUrlPayResult_PayErrorImplCopyWithImpl<_$LnUrlPayResult_PayErrorImpl>(this, _$identity);
}
abstract class LnUrlPayResult_PayError extends LnUrlPayResult {
const factory LnUrlPayResult_PayError({required final LnUrlPayErrorData data}) =
_$LnUrlPayResult_PayErrorImpl;
const LnUrlPayResult_PayError._() : super._();
@override
LnUrlPayErrorData get data;
@JsonKey(ignore: true)
_$$LnUrlPayResult_PayErrorImplCopyWith<_$LnUrlPayResult_PayErrorImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -23,7 +23,7 @@ void main() async {
Future<BindingLiquidSdk> reconnect({
required BreezLiquidSDK liquidSDK,
required String mnemonic,
Network network = Network.mainnet,
LiquidNetwork network = LiquidNetwork.mainnet,
}) async {
final config = await getConfig(network: network);
final req = ConnectRequest(

View File

@@ -97,7 +97,7 @@ class _ConnectPageState extends State<ConnectPage> {
Future<BindingLiquidSdk> initializeWallet({
required String mnemonic,
Network network = Network.mainnet,
LiquidNetwork network = LiquidNetwork.mainnet,
}) async {
final config = await getConfig(network: network);
final req = ConnectRequest(

View File

@@ -3,7 +3,7 @@ import 'package:flutter_breez_liquid/flutter_breez_liquid.dart';
import 'package:path_provider/path_provider.dart';
Future<Config> getConfig({
Network network = Network.mainnet,
LiquidNetwork network = LiquidNetwork.mainnet,
}) async {
debugPrint("Getting default SDK config for network: $network");
final defaultConf = defaultConfig(network: network);
@@ -19,7 +19,7 @@ extension ConfigCopyWith on Config {
String? boltzUrl,
String? electrumUrl,
String? workingDir,
Network? network,
LiquidNetwork? network,
BigInt? paymentTimeoutSec,
}) {
return Config(

View File

@@ -141,6 +141,66 @@ class FlutterBreezLiquidBindings {
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_paymentsPtr
.asFunction<void Function(int, int)>();
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_auth(
int port_,
int that,
ffi.Pointer<wire_cst_ln_url_auth_request_data> req_data,
) {
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_auth(
port_,
that,
req_data,
);
}
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_authPtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_ln_url_auth_request_data>)>>(
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_auth');
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_auth =
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_authPtr
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_ln_url_auth_request_data>)>();
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_pay(
int port_,
int that,
ffi.Pointer<wire_cst_ln_url_pay_request> req,
) {
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_pay(
port_,
that,
req,
);
}
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_payPtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_ln_url_pay_request>)>>(
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_pay');
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_pay =
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_payPtr
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_ln_url_pay_request>)>();
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdraw(
int port_,
int that,
ffi.Pointer<wire_cst_ln_url_withdraw_request> req,
) {
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdraw(
port_,
that,
req,
);
}
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdrawPtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_ln_url_withdraw_request>)>>(
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdraw');
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdraw =
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_withdrawPtr
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_ln_url_withdraw_request>)>();
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_pay_onchain(
int port_,
int that,
@@ -368,6 +428,23 @@ class FlutterBreezLiquidBindings {
_frbgen_breez_liquid_wire__crate__bindings__default_configPtr
.asFunction<WireSyncRust2DartDco Function(int)>();
void frbgen_breez_liquid_wire__crate__bindings__parse(
int port_,
ffi.Pointer<wire_cst_list_prim_u_8_strict> input,
) {
return _frbgen_breez_liquid_wire__crate__bindings__parse(
port_,
input,
);
}
late final _frbgen_breez_liquid_wire__crate__bindings__parsePtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
'frbgen_breez_liquid_wire__crate__bindings__parse');
late final _frbgen_breez_liquid_wire__crate__bindings__parse =
_frbgen_breez_liquid_wire__crate__bindings__parsePtr
.asFunction<void Function(int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
WireSyncRust2DartDco frbgen_breez_liquid_wire__crate__bindings__parse_invoice(
ffi.Pointer<wire_cst_list_prim_u_8_strict> input,
) {
@@ -415,6 +492,30 @@ class FlutterBreezLiquidBindings {
_frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdkPtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
ffi.Pointer<wire_cst_aes_success_action_data_decrypted>
frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decrypted() {
return _frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decrypted();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decryptedPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_aes_success_action_data_decrypted> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decrypted');
late final _frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decrypted =
_frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_decryptedPtr
.asFunction<ffi.Pointer<wire_cst_aes_success_action_data_decrypted> Function()>();
ffi.Pointer<wire_cst_aes_success_action_data_result>
frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_result() {
return _frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_result();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_resultPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_aes_success_action_data_result> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_result');
late final _frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_result =
_frbgen_breez_liquid_cst_new_box_autoadd_aes_success_action_data_resultPtr
.asFunction<ffi.Pointer<wire_cst_aes_success_action_data_result> Function()>();
ffi.Pointer<wire_cst_backup_request> frbgen_breez_liquid_cst_new_box_autoadd_backup_request() {
return _frbgen_breez_liquid_cst_new_box_autoadd_backup_request();
}
@@ -438,6 +539,17 @@ class FlutterBreezLiquidBindings {
_frbgen_breez_liquid_cst_new_box_autoadd_binding_event_listenerPtr
.asFunction<ffi.Pointer<wire_cst_binding_event_listener> Function()>();
ffi.Pointer<wire_cst_bitcoin_address_data> frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_bitcoin_address_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data =
_frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_dataPtr
.asFunction<ffi.Pointer<wire_cst_bitcoin_address_data> Function()>();
ffi.Pointer<wire_cst_connect_request> frbgen_breez_liquid_cst_new_box_autoadd_connect_request() {
return _frbgen_breez_liquid_cst_new_box_autoadd_connect_request();
}
@@ -460,6 +572,135 @@ class FlutterBreezLiquidBindings {
_frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_eventPtr
.asFunction<ffi.Pointer<wire_cst_liquid_sdk_event> Function()>();
ffi.Pointer<wire_cst_ln_invoice> frbgen_breez_liquid_cst_new_box_autoadd_ln_invoice() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_invoice();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_invoicePtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_invoice> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_invoice');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_invoice =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_invoicePtr
.asFunction<ffi.Pointer<wire_cst_ln_invoice> Function()>();
ffi.Pointer<wire_cst_ln_url_auth_request_data>
frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_auth_request_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_data =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_auth_request_dataPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_auth_request_data> Function()>();
ffi.Pointer<wire_cst_ln_url_error_data> frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_error_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_data =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_error_dataPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_error_data> Function()>();
ffi.Pointer<wire_cst_ln_url_pay_error_data>
frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_pay_error_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_data =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_error_dataPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_pay_error_data> Function()>();
ffi.Pointer<wire_cst_ln_url_pay_request> frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_requestPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_pay_request> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_requestPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_pay_request> Function()>();
ffi.Pointer<wire_cst_ln_url_pay_request_data>
frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_pay_request_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_data =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_request_dataPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_pay_request_data> Function()>();
ffi.Pointer<wire_cst_ln_url_pay_success_data>
frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_pay_success_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_data =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_pay_success_dataPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_pay_success_data> Function()>();
ffi.Pointer<wire_cst_ln_url_withdraw_request>
frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_requestPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_withdraw_request> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_requestPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_withdraw_request> Function()>();
ffi.Pointer<wire_cst_ln_url_withdraw_request_data>
frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_withdraw_request_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_data =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_dataPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_withdraw_request_data> Function()>();
ffi.Pointer<wire_cst_ln_url_withdraw_success_data>
frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_ln_url_withdraw_success_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_data =
_frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_dataPtr
.asFunction<ffi.Pointer<wire_cst_ln_url_withdraw_success_data> Function()>();
ffi.Pointer<wire_cst_message_success_action_data>
frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_message_success_action_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data =
_frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_dataPtr
.asFunction<ffi.Pointer<wire_cst_message_success_action_data> Function()>();
ffi.Pointer<wire_cst_pay_onchain_request> frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request() {
return _frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request();
}
@@ -552,6 +793,18 @@ class FlutterBreezLiquidBindings {
_frbgen_breez_liquid_cst_new_box_autoadd_restore_requestPtr
.asFunction<ffi.Pointer<wire_cst_restore_request> Function()>();
ffi.Pointer<wire_cst_success_action_processed>
frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed() {
return _frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_success_action_processedPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_success_action_processed> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed');
late final _frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed =
_frbgen_breez_liquid_cst_new_box_autoadd_success_action_processedPtr
.asFunction<ffi.Pointer<wire_cst_success_action_processed> Function()>();
ffi.Pointer<ffi.Uint64> frbgen_breez_liquid_cst_new_box_autoadd_u_64(
int value,
) {
@@ -566,6 +819,18 @@ class FlutterBreezLiquidBindings {
late final _frbgen_breez_liquid_cst_new_box_autoadd_u_64 =
_frbgen_breez_liquid_cst_new_box_autoadd_u_64Ptr.asFunction<ffi.Pointer<ffi.Uint64> Function(int)>();
ffi.Pointer<wire_cst_url_success_action_data>
frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data() {
return _frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data();
}
late final _frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_dataPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_url_success_action_data> Function()>>(
'frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data');
late final _frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data =
_frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_dataPtr
.asFunction<ffi.Pointer<wire_cst_url_success_action_data> Function()>();
ffi.Pointer<wire_cst_list_payment> frbgen_breez_liquid_cst_new_list_payment(
int len,
) {
@@ -663,6 +928,74 @@ final class wire_cst_backup_request extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> backup_path;
}
final class wire_cst_ln_url_auth_request_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> k1;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> action;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> domain;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> url;
}
final class wire_cst_ln_url_pay_request_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> callback;
@ffi.Uint64()
external int min_sendable;
@ffi.Uint64()
external int max_sendable;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> metadata_str;
@ffi.Uint16()
external int comment_allowed;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> domain;
@ffi.Bool()
external bool allows_nostr;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> nostr_pubkey;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> ln_address;
}
final class wire_cst_ln_url_pay_request extends ffi.Struct {
external wire_cst_ln_url_pay_request_data data;
@ffi.Uint64()
external int amount_msat;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> comment;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> payment_label;
}
final class wire_cst_ln_url_withdraw_request_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> callback;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> k1;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> default_description;
@ffi.Uint64()
external int min_withdrawable;
@ffi.Uint64()
external int max_withdrawable;
}
final class wire_cst_ln_url_withdraw_request extends ffi.Struct {
external wire_cst_ln_url_withdraw_request_data data;
@ffi.Uint64()
external int amount_msat;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> description;
}
final class wire_cst_prepare_pay_onchain_response extends ffi.Struct {
@ffi.Uint64()
external int amount_sat;
@@ -815,11 +1148,44 @@ final class wire_cst_connect_request extends ffi.Struct {
external wire_cst_config config;
}
final class wire_cst_list_payment extends ffi.Struct {
external ffi.Pointer<wire_cst_payment> ptr;
final class wire_cst_aes_success_action_data_decrypted extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> description;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> plaintext;
}
final class wire_cst_AesSuccessActionDataResult_Decrypted extends ffi.Struct {
external ffi.Pointer<wire_cst_aes_success_action_data_decrypted> data;
}
final class wire_cst_AesSuccessActionDataResult_ErrorStatus extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> reason;
}
final class AesSuccessActionDataResultKind extends ffi.Union {
external wire_cst_AesSuccessActionDataResult_Decrypted Decrypted;
external wire_cst_AesSuccessActionDataResult_ErrorStatus ErrorStatus;
}
final class wire_cst_aes_success_action_data_result extends ffi.Struct {
@ffi.Int32()
external int tag;
external AesSuccessActionDataResultKind kind;
}
final class wire_cst_bitcoin_address_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> address;
@ffi.Int32()
external int len;
external int network;
external ffi.Pointer<ffi.Uint64> amount_sat;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> label;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> message;
}
final class wire_cst_route_hint_hop extends ffi.Struct {
@@ -860,40 +1226,6 @@ final class wire_cst_list_route_hint extends ffi.Struct {
external int len;
}
final class wire_cst_get_info_response extends ffi.Struct {
@ffi.Uint64()
external int balance_sat;
@ffi.Uint64()
external int pending_send_sat;
@ffi.Uint64()
external int pending_receive_sat;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> pubkey;
}
final class wire_cst_LiquidSdkError_Generic extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LiquidSdkError_ServiceConnectivity extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class LiquidSdkErrorKind extends ffi.Union {
external wire_cst_LiquidSdkError_Generic Generic;
external wire_cst_LiquidSdkError_ServiceConnectivity ServiceConnectivity;
}
final class wire_cst_liquid_sdk_error extends ffi.Struct {
@ffi.Int32()
external int tag;
external LiquidSdkErrorKind kind;
}
final class wire_cst_ln_invoice extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> bolt11;
@@ -924,6 +1256,371 @@ final class wire_cst_ln_invoice extends ffi.Struct {
external int min_final_cltv_expiry_delta;
}
final class wire_cst_ln_url_error_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> reason;
}
final class wire_cst_ln_url_pay_error_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> payment_hash;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> reason;
}
final class wire_cst_SuccessActionProcessed_Aes extends ffi.Struct {
external ffi.Pointer<wire_cst_aes_success_action_data_result> result;
}
final class wire_cst_message_success_action_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> message;
}
final class wire_cst_SuccessActionProcessed_Message extends ffi.Struct {
external ffi.Pointer<wire_cst_message_success_action_data> data;
}
final class wire_cst_url_success_action_data extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> description;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> url;
}
final class wire_cst_SuccessActionProcessed_Url extends ffi.Struct {
external ffi.Pointer<wire_cst_url_success_action_data> data;
}
final class SuccessActionProcessedKind extends ffi.Union {
external wire_cst_SuccessActionProcessed_Aes Aes;
external wire_cst_SuccessActionProcessed_Message Message;
external wire_cst_SuccessActionProcessed_Url Url;
}
final class wire_cst_success_action_processed extends ffi.Struct {
@ffi.Int32()
external int tag;
external SuccessActionProcessedKind kind;
}
final class wire_cst_ln_url_pay_success_data extends ffi.Struct {
external wire_cst_payment payment;
external ffi.Pointer<wire_cst_success_action_processed> success_action;
}
final class wire_cst_ln_url_withdraw_success_data extends ffi.Struct {
external wire_cst_ln_invoice invoice;
}
final class wire_cst_list_payment extends ffi.Struct {
external ffi.Pointer<wire_cst_payment> ptr;
@ffi.Int32()
external int len;
}
final class wire_cst_get_info_response extends ffi.Struct {
@ffi.Uint64()
external int balance_sat;
@ffi.Uint64()
external int pending_send_sat;
@ffi.Uint64()
external int pending_receive_sat;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> pubkey;
}
final class wire_cst_InputType_BitcoinAddress extends ffi.Struct {
external ffi.Pointer<wire_cst_bitcoin_address_data> address;
}
final class wire_cst_InputType_Bolt11 extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_invoice> invoice;
}
final class wire_cst_InputType_NodeId extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> node_id;
}
final class wire_cst_InputType_Url extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> url;
}
final class wire_cst_InputType_LnUrlPay extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_pay_request_data> data;
}
final class wire_cst_InputType_LnUrlWithdraw extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_withdraw_request_data> data;
}
final class wire_cst_InputType_LnUrlAuth extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_auth_request_data> data;
}
final class wire_cst_InputType_LnUrlError extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_error_data> data;
}
final class InputTypeKind extends ffi.Union {
external wire_cst_InputType_BitcoinAddress BitcoinAddress;
external wire_cst_InputType_Bolt11 Bolt11;
external wire_cst_InputType_NodeId NodeId;
external wire_cst_InputType_Url Url;
external wire_cst_InputType_LnUrlPay LnUrlPay;
external wire_cst_InputType_LnUrlWithdraw LnUrlWithdraw;
external wire_cst_InputType_LnUrlAuth LnUrlAuth;
external wire_cst_InputType_LnUrlError LnUrlError;
}
final class wire_cst_input_type extends ffi.Struct {
@ffi.Int32()
external int tag;
external InputTypeKind kind;
}
final class wire_cst_LiquidSdkError_Generic extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LiquidSdkError_ServiceConnectivity extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class LiquidSdkErrorKind extends ffi.Union {
external wire_cst_LiquidSdkError_Generic Generic;
external wire_cst_LiquidSdkError_ServiceConnectivity ServiceConnectivity;
}
final class wire_cst_liquid_sdk_error extends ffi.Struct {
@ffi.Int32()
external int tag;
external LiquidSdkErrorKind kind;
}
final class wire_cst_LnUrlAuthError_Generic extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlAuthError_InvalidUri extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlAuthError_ServiceConnectivity extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class LnUrlAuthErrorKind extends ffi.Union {
external wire_cst_LnUrlAuthError_Generic Generic;
external wire_cst_LnUrlAuthError_InvalidUri InvalidUri;
external wire_cst_LnUrlAuthError_ServiceConnectivity ServiceConnectivity;
}
final class wire_cst_ln_url_auth_error extends ffi.Struct {
@ffi.Int32()
external int tag;
external LnUrlAuthErrorKind kind;
}
final class wire_cst_LnUrlCallbackStatus_ErrorStatus extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_error_data> data;
}
final class LnUrlCallbackStatusKind extends ffi.Union {
external wire_cst_LnUrlCallbackStatus_ErrorStatus ErrorStatus;
}
final class wire_cst_ln_url_callback_status extends ffi.Struct {
@ffi.Int32()
external int tag;
external LnUrlCallbackStatusKind kind;
}
final class wire_cst_LnUrlPayError_Generic extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_InvalidAmount extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_InvalidInvoice extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_InvalidNetwork extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_InvalidUri extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_InvoiceExpired extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_PaymentFailed extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_PaymentTimeout extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_RouteNotFound extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_RouteTooExpensive extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlPayError_ServiceConnectivity extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class LnUrlPayErrorKind extends ffi.Union {
external wire_cst_LnUrlPayError_Generic Generic;
external wire_cst_LnUrlPayError_InvalidAmount InvalidAmount;
external wire_cst_LnUrlPayError_InvalidInvoice InvalidInvoice;
external wire_cst_LnUrlPayError_InvalidNetwork InvalidNetwork;
external wire_cst_LnUrlPayError_InvalidUri InvalidUri;
external wire_cst_LnUrlPayError_InvoiceExpired InvoiceExpired;
external wire_cst_LnUrlPayError_PaymentFailed PaymentFailed;
external wire_cst_LnUrlPayError_PaymentTimeout PaymentTimeout;
external wire_cst_LnUrlPayError_RouteNotFound RouteNotFound;
external wire_cst_LnUrlPayError_RouteTooExpensive RouteTooExpensive;
external wire_cst_LnUrlPayError_ServiceConnectivity ServiceConnectivity;
}
final class wire_cst_ln_url_pay_error extends ffi.Struct {
@ffi.Int32()
external int tag;
external LnUrlPayErrorKind kind;
}
final class wire_cst_LnUrlPayResult_EndpointSuccess extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_pay_success_data> data;
}
final class wire_cst_LnUrlPayResult_EndpointError extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_error_data> data;
}
final class wire_cst_LnUrlPayResult_PayError extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_pay_error_data> data;
}
final class LnUrlPayResultKind extends ffi.Union {
external wire_cst_LnUrlPayResult_EndpointSuccess EndpointSuccess;
external wire_cst_LnUrlPayResult_EndpointError EndpointError;
external wire_cst_LnUrlPayResult_PayError PayError;
}
final class wire_cst_ln_url_pay_result extends ffi.Struct {
@ffi.Int32()
external int tag;
external LnUrlPayResultKind kind;
}
final class wire_cst_LnUrlWithdrawError_Generic extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlWithdrawError_InvalidAmount extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlWithdrawError_InvalidInvoice extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlWithdrawError_InvalidUri extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlWithdrawError_InvoiceNoRoutingHints extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class wire_cst_LnUrlWithdrawError_ServiceConnectivity extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
}
final class LnUrlWithdrawErrorKind extends ffi.Union {
external wire_cst_LnUrlWithdrawError_Generic Generic;
external wire_cst_LnUrlWithdrawError_InvalidAmount InvalidAmount;
external wire_cst_LnUrlWithdrawError_InvalidInvoice InvalidInvoice;
external wire_cst_LnUrlWithdrawError_InvalidUri InvalidUri;
external wire_cst_LnUrlWithdrawError_InvoiceNoRoutingHints InvoiceNoRoutingHints;
external wire_cst_LnUrlWithdrawError_ServiceConnectivity ServiceConnectivity;
}
final class wire_cst_ln_url_withdraw_error extends ffi.Struct {
@ffi.Int32()
external int tag;
external LnUrlWithdrawErrorKind kind;
}
final class wire_cst_LnUrlWithdrawResult_Ok extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_withdraw_success_data> data;
}
final class wire_cst_LnUrlWithdrawResult_ErrorStatus extends ffi.Struct {
external ffi.Pointer<wire_cst_ln_url_error_data> data;
}
final class LnUrlWithdrawResultKind extends ffi.Union {
external wire_cst_LnUrlWithdrawResult_Ok Ok;
external wire_cst_LnUrlWithdrawResult_ErrorStatus ErrorStatus;
}
final class wire_cst_ln_url_withdraw_result extends ffi.Struct {
@ffi.Int32()
external int tag;
external LnUrlWithdrawResultKind kind;
}
final class wire_cst_log_entry extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> line;

View File

@@ -3,6 +3,42 @@ import breez_liquid_sdk.*
import com.facebook.react.bridge.*
import java.util.*
fun asAesSuccessActionDataDecrypted(aesSuccessActionDataDecrypted: ReadableMap): AesSuccessActionDataDecrypted? {
if (!validateMandatoryFields(
aesSuccessActionDataDecrypted,
arrayOf(
"description",
"plaintext",
),
)
) {
return null
}
val description = aesSuccessActionDataDecrypted.getString("description")!!
val plaintext = aesSuccessActionDataDecrypted.getString("plaintext")!!
return AesSuccessActionDataDecrypted(
description,
plaintext,
)
}
fun readableMapOf(aesSuccessActionDataDecrypted: AesSuccessActionDataDecrypted): ReadableMap =
readableMapOf(
"description" to aesSuccessActionDataDecrypted.description,
"plaintext" to aesSuccessActionDataDecrypted.plaintext,
)
fun asAesSuccessActionDataDecryptedList(arr: ReadableArray): List<AesSuccessActionDataDecrypted> {
val list = ArrayList<AesSuccessActionDataDecrypted>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asAesSuccessActionDataDecrypted(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asBackupRequest(backupRequest: ReadableMap): BackupRequest? {
if (!validateMandatoryFields(
backupRequest,
@@ -33,6 +69,51 @@ fun asBackupRequestList(arr: ReadableArray): List<BackupRequest> {
return list
}
fun asBitcoinAddressData(bitcoinAddressData: ReadableMap): BitcoinAddressData? {
if (!validateMandatoryFields(
bitcoinAddressData,
arrayOf(
"address",
"network",
),
)
) {
return null
}
val address = bitcoinAddressData.getString("address")!!
val network = bitcoinAddressData.getString("network")?.let { asNetwork(it) }!!
val amountSat = if (hasNonNullKey(bitcoinAddressData, "amountSat")) bitcoinAddressData.getDouble("amountSat").toULong() else null
val label = if (hasNonNullKey(bitcoinAddressData, "label")) bitcoinAddressData.getString("label") else null
val message = if (hasNonNullKey(bitcoinAddressData, "message")) bitcoinAddressData.getString("message") else null
return BitcoinAddressData(
address,
network,
amountSat,
label,
message,
)
}
fun readableMapOf(bitcoinAddressData: BitcoinAddressData): ReadableMap =
readableMapOf(
"address" to bitcoinAddressData.address,
"network" to bitcoinAddressData.network.name.lowercase(),
"amountSat" to bitcoinAddressData.amountSat,
"label" to bitcoinAddressData.label,
"message" to bitcoinAddressData.message,
)
fun asBitcoinAddressDataList(arr: ReadableArray): List<BitcoinAddressData> {
val list = ArrayList<BitcoinAddressData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asBitcoinAddressData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asConfig(config: ReadableMap): Config? {
if (!validateMandatoryFields(
config,
@@ -53,7 +134,7 @@ fun asConfig(config: ReadableMap): Config? {
val liquidElectrumUrl = config.getString("liquidElectrumUrl")!!
val bitcoinElectrumUrl = config.getString("bitcoinElectrumUrl")!!
val workingDir = config.getString("workingDir")!!
val network = config.getString("network")?.let { asNetwork(it) }!!
val network = config.getString("network")?.let { asLiquidNetwork(it) }!!
val paymentTimeoutSec = config.getDouble("paymentTimeoutSec").toULong()
val zeroConfMinFeeRate = config.getDouble("zeroConfMinFeeRate")
val zeroConfMaxAmountSat =
@@ -254,6 +335,382 @@ fun asLnInvoiceList(arr: ReadableArray): List<LnInvoice> {
return list
}
fun asLnUrlAuthRequestData(lnUrlAuthRequestData: ReadableMap): LnUrlAuthRequestData? {
if (!validateMandatoryFields(
lnUrlAuthRequestData,
arrayOf(
"k1",
"domain",
"url",
),
)
) {
return null
}
val k1 = lnUrlAuthRequestData.getString("k1")!!
val domain = lnUrlAuthRequestData.getString("domain")!!
val url = lnUrlAuthRequestData.getString("url")!!
val action = if (hasNonNullKey(lnUrlAuthRequestData, "action")) lnUrlAuthRequestData.getString("action") else null
return LnUrlAuthRequestData(
k1,
domain,
url,
action,
)
}
fun readableMapOf(lnUrlAuthRequestData: LnUrlAuthRequestData): ReadableMap =
readableMapOf(
"k1" to lnUrlAuthRequestData.k1,
"domain" to lnUrlAuthRequestData.domain,
"url" to lnUrlAuthRequestData.url,
"action" to lnUrlAuthRequestData.action,
)
fun asLnUrlAuthRequestDataList(arr: ReadableArray): List<LnUrlAuthRequestData> {
val list = ArrayList<LnUrlAuthRequestData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlAuthRequestData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlErrorData(lnUrlErrorData: ReadableMap): LnUrlErrorData? {
if (!validateMandatoryFields(
lnUrlErrorData,
arrayOf(
"reason",
),
)
) {
return null
}
val reason = lnUrlErrorData.getString("reason")!!
return LnUrlErrorData(
reason,
)
}
fun readableMapOf(lnUrlErrorData: LnUrlErrorData): ReadableMap =
readableMapOf(
"reason" to lnUrlErrorData.reason,
)
fun asLnUrlErrorDataList(arr: ReadableArray): List<LnUrlErrorData> {
val list = ArrayList<LnUrlErrorData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlErrorData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlPayErrorData(lnUrlPayErrorData: ReadableMap): LnUrlPayErrorData? {
if (!validateMandatoryFields(
lnUrlPayErrorData,
arrayOf(
"paymentHash",
"reason",
),
)
) {
return null
}
val paymentHash = lnUrlPayErrorData.getString("paymentHash")!!
val reason = lnUrlPayErrorData.getString("reason")!!
return LnUrlPayErrorData(
paymentHash,
reason,
)
}
fun readableMapOf(lnUrlPayErrorData: LnUrlPayErrorData): ReadableMap =
readableMapOf(
"paymentHash" to lnUrlPayErrorData.paymentHash,
"reason" to lnUrlPayErrorData.reason,
)
fun asLnUrlPayErrorDataList(arr: ReadableArray): List<LnUrlPayErrorData> {
val list = ArrayList<LnUrlPayErrorData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlPayErrorData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlPayRequest(lnUrlPayRequest: ReadableMap): LnUrlPayRequest? {
if (!validateMandatoryFields(
lnUrlPayRequest,
arrayOf(
"data",
"amountMsat",
),
)
) {
return null
}
val data = lnUrlPayRequest.getMap("data")?.let { asLnUrlPayRequestData(it) }!!
val amountMsat = lnUrlPayRequest.getDouble("amountMsat").toULong()
val comment = if (hasNonNullKey(lnUrlPayRequest, "comment")) lnUrlPayRequest.getString("comment") else null
val paymentLabel = if (hasNonNullKey(lnUrlPayRequest, "paymentLabel")) lnUrlPayRequest.getString("paymentLabel") else null
return LnUrlPayRequest(
data,
amountMsat,
comment,
paymentLabel,
)
}
fun readableMapOf(lnUrlPayRequest: LnUrlPayRequest): ReadableMap =
readableMapOf(
"data" to readableMapOf(lnUrlPayRequest.data),
"amountMsat" to lnUrlPayRequest.amountMsat,
"comment" to lnUrlPayRequest.comment,
"paymentLabel" to lnUrlPayRequest.paymentLabel,
)
fun asLnUrlPayRequestList(arr: ReadableArray): List<LnUrlPayRequest> {
val list = ArrayList<LnUrlPayRequest>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlPayRequest(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlPayRequestData(lnUrlPayRequestData: ReadableMap): LnUrlPayRequestData? {
if (!validateMandatoryFields(
lnUrlPayRequestData,
arrayOf(
"callback",
"minSendable",
"maxSendable",
"metadataStr",
"commentAllowed",
"domain",
"allowsNostr",
),
)
) {
return null
}
val callback = lnUrlPayRequestData.getString("callback")!!
val minSendable = lnUrlPayRequestData.getDouble("minSendable").toULong()
val maxSendable = lnUrlPayRequestData.getDouble("maxSendable").toULong()
val metadataStr = lnUrlPayRequestData.getString("metadataStr")!!
val commentAllowed = lnUrlPayRequestData.getInt("commentAllowed").toUShort()
val domain = lnUrlPayRequestData.getString("domain")!!
val allowsNostr = lnUrlPayRequestData.getBoolean("allowsNostr")
val nostrPubkey = if (hasNonNullKey(lnUrlPayRequestData, "nostrPubkey")) lnUrlPayRequestData.getString("nostrPubkey") else null
val lnAddress = if (hasNonNullKey(lnUrlPayRequestData, "lnAddress")) lnUrlPayRequestData.getString("lnAddress") else null
return LnUrlPayRequestData(
callback,
minSendable,
maxSendable,
metadataStr,
commentAllowed,
domain,
allowsNostr,
nostrPubkey,
lnAddress,
)
}
fun readableMapOf(lnUrlPayRequestData: LnUrlPayRequestData): ReadableMap =
readableMapOf(
"callback" to lnUrlPayRequestData.callback,
"minSendable" to lnUrlPayRequestData.minSendable,
"maxSendable" to lnUrlPayRequestData.maxSendable,
"metadataStr" to lnUrlPayRequestData.metadataStr,
"commentAllowed" to lnUrlPayRequestData.commentAllowed,
"domain" to lnUrlPayRequestData.domain,
"allowsNostr" to lnUrlPayRequestData.allowsNostr,
"nostrPubkey" to lnUrlPayRequestData.nostrPubkey,
"lnAddress" to lnUrlPayRequestData.lnAddress,
)
fun asLnUrlPayRequestDataList(arr: ReadableArray): List<LnUrlPayRequestData> {
val list = ArrayList<LnUrlPayRequestData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlPayRequestData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlPaySuccessData(lnUrlPaySuccessData: ReadableMap): LnUrlPaySuccessData? {
if (!validateMandatoryFields(
lnUrlPaySuccessData,
arrayOf(
"payment",
),
)
) {
return null
}
val successAction =
if (hasNonNullKey(lnUrlPaySuccessData, "successAction")) {
lnUrlPaySuccessData.getMap("successAction")?.let {
asSuccessActionProcessed(it)
}
} else {
null
}
val payment = lnUrlPaySuccessData.getMap("payment")?.let { asPayment(it) }!!
return LnUrlPaySuccessData(
successAction,
payment,
)
}
fun readableMapOf(lnUrlPaySuccessData: LnUrlPaySuccessData): ReadableMap =
readableMapOf(
"successAction" to lnUrlPaySuccessData.successAction?.let { readableMapOf(it) },
"payment" to readableMapOf(lnUrlPaySuccessData.payment),
)
fun asLnUrlPaySuccessDataList(arr: ReadableArray): List<LnUrlPaySuccessData> {
val list = ArrayList<LnUrlPaySuccessData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlPaySuccessData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlWithdrawRequest(lnUrlWithdrawRequest: ReadableMap): LnUrlWithdrawRequest? {
if (!validateMandatoryFields(
lnUrlWithdrawRequest,
arrayOf(
"data",
"amountMsat",
),
)
) {
return null
}
val data = lnUrlWithdrawRequest.getMap("data")?.let { asLnUrlWithdrawRequestData(it) }!!
val amountMsat = lnUrlWithdrawRequest.getDouble("amountMsat").toULong()
val description = if (hasNonNullKey(lnUrlWithdrawRequest, "description")) lnUrlWithdrawRequest.getString("description") else null
return LnUrlWithdrawRequest(
data,
amountMsat,
description,
)
}
fun readableMapOf(lnUrlWithdrawRequest: LnUrlWithdrawRequest): ReadableMap =
readableMapOf(
"data" to readableMapOf(lnUrlWithdrawRequest.data),
"amountMsat" to lnUrlWithdrawRequest.amountMsat,
"description" to lnUrlWithdrawRequest.description,
)
fun asLnUrlWithdrawRequestList(arr: ReadableArray): List<LnUrlWithdrawRequest> {
val list = ArrayList<LnUrlWithdrawRequest>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlWithdrawRequest(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlWithdrawRequestData(lnUrlWithdrawRequestData: ReadableMap): LnUrlWithdrawRequestData? {
if (!validateMandatoryFields(
lnUrlWithdrawRequestData,
arrayOf(
"callback",
"k1",
"defaultDescription",
"minWithdrawable",
"maxWithdrawable",
),
)
) {
return null
}
val callback = lnUrlWithdrawRequestData.getString("callback")!!
val k1 = lnUrlWithdrawRequestData.getString("k1")!!
val defaultDescription = lnUrlWithdrawRequestData.getString("defaultDescription")!!
val minWithdrawable = lnUrlWithdrawRequestData.getDouble("minWithdrawable").toULong()
val maxWithdrawable = lnUrlWithdrawRequestData.getDouble("maxWithdrawable").toULong()
return LnUrlWithdrawRequestData(
callback,
k1,
defaultDescription,
minWithdrawable,
maxWithdrawable,
)
}
fun readableMapOf(lnUrlWithdrawRequestData: LnUrlWithdrawRequestData): ReadableMap =
readableMapOf(
"callback" to lnUrlWithdrawRequestData.callback,
"k1" to lnUrlWithdrawRequestData.k1,
"defaultDescription" to lnUrlWithdrawRequestData.defaultDescription,
"minWithdrawable" to lnUrlWithdrawRequestData.minWithdrawable,
"maxWithdrawable" to lnUrlWithdrawRequestData.maxWithdrawable,
)
fun asLnUrlWithdrawRequestDataList(arr: ReadableArray): List<LnUrlWithdrawRequestData> {
val list = ArrayList<LnUrlWithdrawRequestData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlWithdrawRequestData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlWithdrawSuccessData(lnUrlWithdrawSuccessData: ReadableMap): LnUrlWithdrawSuccessData? {
if (!validateMandatoryFields(
lnUrlWithdrawSuccessData,
arrayOf(
"invoice",
),
)
) {
return null
}
val invoice = lnUrlWithdrawSuccessData.getMap("invoice")?.let { asLnInvoice(it) }!!
return LnUrlWithdrawSuccessData(
invoice,
)
}
fun readableMapOf(lnUrlWithdrawSuccessData: LnUrlWithdrawSuccessData): ReadableMap =
readableMapOf(
"invoice" to readableMapOf(lnUrlWithdrawSuccessData.invoice),
)
fun asLnUrlWithdrawSuccessDataList(arr: ReadableArray): List<LnUrlWithdrawSuccessData> {
val list = ArrayList<LnUrlWithdrawSuccessData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlWithdrawSuccessData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLogEntry(logEntry: ReadableMap): LogEntry? {
if (!validateMandatoryFields(
logEntry,
@@ -290,6 +747,38 @@ fun asLogEntryList(arr: ReadableArray): List<LogEntry> {
return list
}
fun asMessageSuccessActionData(messageSuccessActionData: ReadableMap): MessageSuccessActionData? {
if (!validateMandatoryFields(
messageSuccessActionData,
arrayOf(
"message",
),
)
) {
return null
}
val message = messageSuccessActionData.getString("message")!!
return MessageSuccessActionData(
message,
)
}
fun readableMapOf(messageSuccessActionData: MessageSuccessActionData): ReadableMap =
readableMapOf(
"message" to messageSuccessActionData.message,
)
fun asMessageSuccessActionDataList(arr: ReadableArray): List<MessageSuccessActionData> {
val list = ArrayList<MessageSuccessActionData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asMessageSuccessActionData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asPayOnchainRequest(payOnchainRequest: ReadableMap): PayOnchainRequest? {
if (!validateMandatoryFields(
payOnchainRequest,
@@ -780,6 +1269,175 @@ fun asSendPaymentResponseList(arr: ReadableArray): List<SendPaymentResponse> {
return list
}
fun asUrlSuccessActionData(urlSuccessActionData: ReadableMap): UrlSuccessActionData? {
if (!validateMandatoryFields(
urlSuccessActionData,
arrayOf(
"description",
"url",
),
)
) {
return null
}
val description = urlSuccessActionData.getString("description")!!
val url = urlSuccessActionData.getString("url")!!
return UrlSuccessActionData(
description,
url,
)
}
fun readableMapOf(urlSuccessActionData: UrlSuccessActionData): ReadableMap =
readableMapOf(
"description" to urlSuccessActionData.description,
"url" to urlSuccessActionData.url,
)
fun asUrlSuccessActionDataList(arr: ReadableArray): List<UrlSuccessActionData> {
val list = ArrayList<UrlSuccessActionData>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asUrlSuccessActionData(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asAesSuccessActionDataResult(aesSuccessActionDataResult: ReadableMap): AesSuccessActionDataResult? {
val type = aesSuccessActionDataResult.getString("type")
if (type == "decrypted") {
return AesSuccessActionDataResult.Decrypted(
aesSuccessActionDataResult.getMap("data")?.let { asAesSuccessActionDataDecrypted(it) }!!,
)
}
if (type == "errorStatus") {
return AesSuccessActionDataResult.ErrorStatus(aesSuccessActionDataResult.getString("reason")!!)
}
return null
}
fun readableMapOf(aesSuccessActionDataResult: AesSuccessActionDataResult): ReadableMap? {
val map = Arguments.createMap()
when (aesSuccessActionDataResult) {
is AesSuccessActionDataResult.Decrypted -> {
pushToMap(map, "type", "decrypted")
pushToMap(map, "data", readableMapOf(aesSuccessActionDataResult.data))
}
is AesSuccessActionDataResult.ErrorStatus -> {
pushToMap(map, "type", "errorStatus")
pushToMap(map, "reason", aesSuccessActionDataResult.reason)
}
}
return map
}
fun asAesSuccessActionDataResultList(arr: ReadableArray): List<AesSuccessActionDataResult> {
val list = ArrayList<AesSuccessActionDataResult>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asAesSuccessActionDataResult(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asInputType(inputType: ReadableMap): InputType? {
val type = inputType.getString("type")
if (type == "bitcoinAddress") {
return InputType.BitcoinAddress(inputType.getMap("address")?.let { asBitcoinAddressData(it) }!!)
}
if (type == "bolt11") {
return InputType.Bolt11(inputType.getMap("invoice")?.let { asLnInvoice(it) }!!)
}
if (type == "nodeId") {
return InputType.NodeId(inputType.getString("nodeId")!!)
}
if (type == "url") {
return InputType.Url(inputType.getString("url")!!)
}
if (type == "lnUrlPay") {
return InputType.LnUrlPay(inputType.getMap("data")?.let { asLnUrlPayRequestData(it) }!!)
}
if (type == "lnUrlWithdraw") {
return InputType.LnUrlWithdraw(inputType.getMap("data")?.let { asLnUrlWithdrawRequestData(it) }!!)
}
if (type == "lnUrlAuth") {
return InputType.LnUrlAuth(inputType.getMap("data")?.let { asLnUrlAuthRequestData(it) }!!)
}
if (type == "lnUrlError") {
return InputType.LnUrlError(inputType.getMap("data")?.let { asLnUrlErrorData(it) }!!)
}
return null
}
fun readableMapOf(inputType: InputType): ReadableMap? {
val map = Arguments.createMap()
when (inputType) {
is InputType.BitcoinAddress -> {
pushToMap(map, "type", "bitcoinAddress")
pushToMap(map, "address", readableMapOf(inputType.address))
}
is InputType.Bolt11 -> {
pushToMap(map, "type", "bolt11")
pushToMap(map, "invoice", readableMapOf(inputType.invoice))
}
is InputType.NodeId -> {
pushToMap(map, "type", "nodeId")
pushToMap(map, "nodeId", inputType.nodeId)
}
is InputType.Url -> {
pushToMap(map, "type", "url")
pushToMap(map, "url", inputType.url)
}
is InputType.LnUrlPay -> {
pushToMap(map, "type", "lnUrlPay")
pushToMap(map, "data", readableMapOf(inputType.data))
}
is InputType.LnUrlWithdraw -> {
pushToMap(map, "type", "lnUrlWithdraw")
pushToMap(map, "data", readableMapOf(inputType.data))
}
is InputType.LnUrlAuth -> {
pushToMap(map, "type", "lnUrlAuth")
pushToMap(map, "data", readableMapOf(inputType.data))
}
is InputType.LnUrlError -> {
pushToMap(map, "type", "lnUrlError")
pushToMap(map, "data", readableMapOf(inputType.data))
}
}
return map
}
fun asInputTypeList(arr: ReadableArray): List<InputType> {
val list = ArrayList<InputType>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asInputType(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLiquidNetwork(type: String): LiquidNetwork = LiquidNetwork.valueOf(camelToUpperSnakeCase(type))
fun asLiquidNetworkList(arr: ReadableArray): List<LiquidNetwork> {
val list = ArrayList<LiquidNetwork>()
for (value in arr.toArrayList()) {
when (value) {
is String -> list.add(asLiquidNetwork(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLiquidSdkEvent(liquidSdkEvent: ReadableMap): LiquidSdkEvent? {
val type = liquidSdkEvent.getString("type")
@@ -852,6 +1510,126 @@ fun asLiquidSdkEventList(arr: ReadableArray): List<LiquidSdkEvent> {
return list
}
fun asLnUrlCallbackStatus(lnUrlCallbackStatus: ReadableMap): LnUrlCallbackStatus? {
val type = lnUrlCallbackStatus.getString("type")
if (type == "ok") {
return LnUrlCallbackStatus.Ok
}
if (type == "errorStatus") {
return LnUrlCallbackStatus.ErrorStatus(lnUrlCallbackStatus.getMap("data")?.let { asLnUrlErrorData(it) }!!)
}
return null
}
fun readableMapOf(lnUrlCallbackStatus: LnUrlCallbackStatus): ReadableMap? {
val map = Arguments.createMap()
when (lnUrlCallbackStatus) {
is LnUrlCallbackStatus.Ok -> {
pushToMap(map, "type", "ok")
}
is LnUrlCallbackStatus.ErrorStatus -> {
pushToMap(map, "type", "errorStatus")
pushToMap(map, "data", readableMapOf(lnUrlCallbackStatus.data))
}
}
return map
}
fun asLnUrlCallbackStatusList(arr: ReadableArray): List<LnUrlCallbackStatus> {
val list = ArrayList<LnUrlCallbackStatus>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlCallbackStatus(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlPayResult(lnUrlPayResult: ReadableMap): LnUrlPayResult? {
val type = lnUrlPayResult.getString("type")
if (type == "endpointSuccess") {
return LnUrlPayResult.EndpointSuccess(lnUrlPayResult.getMap("data")?.let { asLnUrlPaySuccessData(it) }!!)
}
if (type == "endpointError") {
return LnUrlPayResult.EndpointError(lnUrlPayResult.getMap("data")?.let { asLnUrlErrorData(it) }!!)
}
if (type == "payError") {
return LnUrlPayResult.PayError(lnUrlPayResult.getMap("data")?.let { asLnUrlPayErrorData(it) }!!)
}
return null
}
fun readableMapOf(lnUrlPayResult: LnUrlPayResult): ReadableMap? {
val map = Arguments.createMap()
when (lnUrlPayResult) {
is LnUrlPayResult.EndpointSuccess -> {
pushToMap(map, "type", "endpointSuccess")
pushToMap(map, "data", readableMapOf(lnUrlPayResult.data))
}
is LnUrlPayResult.EndpointError -> {
pushToMap(map, "type", "endpointError")
pushToMap(map, "data", readableMapOf(lnUrlPayResult.data))
}
is LnUrlPayResult.PayError -> {
pushToMap(map, "type", "payError")
pushToMap(map, "data", readableMapOf(lnUrlPayResult.data))
}
}
return map
}
fun asLnUrlPayResultList(arr: ReadableArray): List<LnUrlPayResult> {
val list = ArrayList<LnUrlPayResult>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlPayResult(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asLnUrlWithdrawResult(lnUrlWithdrawResult: ReadableMap): LnUrlWithdrawResult? {
val type = lnUrlWithdrawResult.getString("type")
if (type == "ok") {
return LnUrlWithdrawResult.Ok(lnUrlWithdrawResult.getMap("data")?.let { asLnUrlWithdrawSuccessData(it) }!!)
}
if (type == "errorStatus") {
return LnUrlWithdrawResult.ErrorStatus(lnUrlWithdrawResult.getMap("data")?.let { asLnUrlErrorData(it) }!!)
}
return null
}
fun readableMapOf(lnUrlWithdrawResult: LnUrlWithdrawResult): ReadableMap? {
val map = Arguments.createMap()
when (lnUrlWithdrawResult) {
is LnUrlWithdrawResult.Ok -> {
pushToMap(map, "type", "ok")
pushToMap(map, "data", readableMapOf(lnUrlWithdrawResult.data))
}
is LnUrlWithdrawResult.ErrorStatus -> {
pushToMap(map, "type", "errorStatus")
pushToMap(map, "data", readableMapOf(lnUrlWithdrawResult.data))
}
}
return map
}
fun asLnUrlWithdrawResultList(arr: ReadableArray): List<LnUrlWithdrawResult> {
val list = ArrayList<LnUrlWithdrawResult>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asLnUrlWithdrawResult(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun asNetwork(type: String): Network = Network.valueOf(camelToUpperSnakeCase(type))
fun asNetworkList(arr: ReadableArray): List<Network> {
@@ -891,6 +1669,51 @@ fun asPaymentTypeList(arr: ReadableArray): List<PaymentType> {
return list
}
fun asSuccessActionProcessed(successActionProcessed: ReadableMap): SuccessActionProcessed? {
val type = successActionProcessed.getString("type")
if (type == "aes") {
return SuccessActionProcessed.Aes(successActionProcessed.getMap("result")?.let { asAesSuccessActionDataResult(it) }!!)
}
if (type == "message") {
return SuccessActionProcessed.Message(successActionProcessed.getMap("data")?.let { asMessageSuccessActionData(it) }!!)
}
if (type == "url") {
return SuccessActionProcessed.Url(successActionProcessed.getMap("data")?.let { asUrlSuccessActionData(it) }!!)
}
return null
}
fun readableMapOf(successActionProcessed: SuccessActionProcessed): ReadableMap? {
val map = Arguments.createMap()
when (successActionProcessed) {
is SuccessActionProcessed.Aes -> {
pushToMap(map, "type", "aes")
pushToMap(map, "result", readableMapOf(successActionProcessed.result))
}
is SuccessActionProcessed.Message -> {
pushToMap(map, "type", "message")
pushToMap(map, "data", readableMapOf(successActionProcessed.data))
}
is SuccessActionProcessed.Url -> {
pushToMap(map, "type", "url")
pushToMap(map, "data", readableMapOf(successActionProcessed.data))
}
}
return map
}
fun asSuccessActionProcessedList(arr: ReadableArray): List<SuccessActionProcessed> {
val list = ArrayList<SuccessActionProcessed>()
for (value in arr.toArrayList()) {
when (value) {
is ReadableMap -> list.add(asSuccessActionProcessed(value)!!)
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
}
}
return list
}
fun readableMapOf(vararg values: Pair<String, *>): ReadableMap {
val map = Arguments.createMap()
for ((key, value) in values) {

View File

@@ -61,7 +61,7 @@ class BreezLiquidSDKModule(
) {
executor.execute {
try {
val networkTmp = asNetwork(network)
val networkTmp = asLiquidNetwork(network)
val res = defaultConfig(networkTmp)
val workingDir = File(reactApplicationContext.filesDir.toString() + "/breezLiquidSdk")
@@ -74,13 +74,28 @@ class BreezLiquidSDKModule(
}
@ReactMethod
fun parseInvoice(
invoice: String,
fun parse(
input: String,
promise: Promise,
) {
executor.execute {
try {
val res = parseInvoice(invoice)
val res = parse(input)
promise.resolve(readableMapOf(res))
} catch (e: Exception) {
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
}
}
}
@ReactMethod
fun parseInvoice(
input: String,
promise: Promise,
) {
executor.execute {
try {
val res = parseInvoice(input)
promise.resolve(readableMapOf(res))
} catch (e: Exception) {
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
@@ -349,4 +364,57 @@ class BreezLiquidSDKModule(
}
}
}
@ReactMethod
fun lnurlPay(
req: ReadableMap,
promise: Promise,
) {
executor.execute {
try {
val lnUrlPayRequest =
asLnUrlPayRequest(req) ?: run { throw LiquidSdkException.Generic(errMissingMandatoryField("req", "LnUrlPayRequest")) }
val res = getBindingLiquidSdk().lnurlPay(lnUrlPayRequest)
promise.resolve(readableMapOf(res))
} catch (e: Exception) {
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
}
}
}
@ReactMethod
fun lnurlWithdraw(
req: ReadableMap,
promise: Promise,
) {
executor.execute {
try {
val lnUrlWithdrawRequest =
asLnUrlWithdrawRequest(req)
?: run { throw LiquidSdkException.Generic(errMissingMandatoryField("req", "LnUrlWithdrawRequest")) }
val res = getBindingLiquidSdk().lnurlWithdraw(lnUrlWithdrawRequest)
promise.resolve(readableMapOf(res))
} catch (e: Exception) {
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
}
}
}
@ReactMethod
fun lnurlAuth(
reqData: ReadableMap,
promise: Promise,
) {
executor.execute {
try {
val lnUrlAuthRequestData =
asLnUrlAuthRequestData(reqData)
?: run { throw LiquidSdkException.Generic(errMissingMandatoryField("reqData", "LnUrlAuthRequestData")) }
val res = getBindingLiquidSdk().lnurlAuth(lnUrlAuthRequestData)
promise.resolve(readableMapOf(res))
} catch (e: Exception) {
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,13 @@ RCT_EXTERN_METHOD(
)
RCT_EXTERN_METHOD(
parseInvoice: (NSString*)invoice
parse: (NSString*)input
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)
RCT_EXTERN_METHOD(
parseInvoice: (NSString*)input
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)
@@ -105,4 +111,22 @@ RCT_EXTERN_METHOD(
reject: (RCTPromiseRejectBlock)reject
)
RCT_EXTERN_METHOD(
lnurlPay: (NSDictionary*)req
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)
RCT_EXTERN_METHOD(
lnurlWithdraw: (NSDictionary*)req
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)
RCT_EXTERN_METHOD(
lnurlAuth: (NSDictionary*)reqData
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)
@end

View File

@@ -74,7 +74,7 @@ class RNBreezLiquidSDK: RCTEventEmitter {
@objc(defaultConfig:resolve:reject:)
func defaultConfig(_ network: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
let networkTmp = try BreezLiquidSDKMapper.asNetwork(network: network)
let networkTmp = try BreezLiquidSDKMapper.asLiquidNetwork(liquidNetwork: network)
var res = BreezLiquidSDK.defaultConfig(network: networkTmp)
res.workingDir = RNBreezLiquidSDK.breezLiquidSdkDirectory.path
resolve(BreezLiquidSDKMapper.dictionaryOf(config: res))
@@ -83,10 +83,20 @@ class RNBreezLiquidSDK: RCTEventEmitter {
}
}
@objc(parseInvoice:resolve:reject:)
func parseInvoice(_ invoice: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
@objc(parse:resolve:reject:)
func parse(_ input: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
var res = try BreezLiquidSDK.parseInvoice(invoice: invoice)
var res = try BreezLiquidSDK.parse(input: input)
resolve(BreezLiquidSDKMapper.dictionaryOf(inputType: res))
} catch let err {
rejectErr(err: err, reject: reject)
}
}
@objc(parseInvoice:resolve:reject:)
func parseInvoice(_ input: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
var res = try BreezLiquidSDK.parseInvoice(input: input)
resolve(BreezLiquidSDKMapper.dictionaryOf(lnInvoice: res))
} catch let err {
rejectErr(err: err, reject: reject)
@@ -273,6 +283,39 @@ class RNBreezLiquidSDK: RCTEventEmitter {
}
}
@objc(lnurlPay:resolve:reject:)
func lnurlPay(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
let lnUrlPayRequest = try BreezLiquidSDKMapper.asLnUrlPayRequest(lnUrlPayRequest: req)
var res = try getBindingLiquidSdk().lnurlPay(req: lnUrlPayRequest)
resolve(BreezLiquidSDKMapper.dictionaryOf(lnUrlPayResult: res))
} catch let err {
rejectErr(err: err, reject: reject)
}
}
@objc(lnurlWithdraw:resolve:reject:)
func lnurlWithdraw(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
let lnUrlWithdrawRequest = try BreezLiquidSDKMapper.asLnUrlWithdrawRequest(lnUrlWithdrawRequest: req)
var res = try getBindingLiquidSdk().lnurlWithdraw(req: lnUrlWithdrawRequest)
resolve(BreezLiquidSDKMapper.dictionaryOf(lnUrlWithdrawResult: res))
} catch let err {
rejectErr(err: err, reject: reject)
}
}
@objc(lnurlAuth:resolve:reject:)
func lnurlAuth(_ reqData: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
let lnUrlAuthRequestData = try BreezLiquidSDKMapper.asLnUrlAuthRequestData(lnUrlAuthRequestData: reqData)
var res = try getBindingLiquidSdk().lnurlAuth(reqData: lnUrlAuthRequestData)
resolve(BreezLiquidSDKMapper.dictionaryOf(lnUrlCallbackStatus: res))
} catch let err {
rejectErr(err: err, reject: reject)
}
}
func rejectErr(err: Error, reject: @escaping RCTPromiseRejectBlock) {
var errorName = "Generic"
var message = "\(err)"

View File

@@ -19,16 +19,29 @@ const BreezLiquidSDK = NativeModules.RNBreezLiquidSDK
const BreezLiquidSDKEmitter = new NativeEventEmitter(BreezLiquidSDK)
export interface AesSuccessActionDataDecrypted {
description: string
plaintext: string
}
export interface BackupRequest {
backupPath?: string
}
export interface BitcoinAddressData {
address: string
network: Network
amountSat?: number
label?: string
message?: string
}
export interface Config {
boltzUrl: string
liquidElectrumUrl: string
bitcoinElectrumUrl: string
workingDir: string
network: Network
network: LiquidNetwork
paymentTimeoutSec: number
zeroConfMinFeeRate: number
zeroConfMaxAmountSat?: number
@@ -61,11 +74,73 @@ export interface LnInvoice {
minFinalCltvExpiryDelta: number
}
export interface LnUrlAuthRequestData {
k1: string
domain: string
url: string
action?: string
}
export interface LnUrlErrorData {
reason: string
}
export interface LnUrlPayErrorData {
paymentHash: string
reason: string
}
export interface LnUrlPayRequest {
data: LnUrlPayRequestData
amountMsat: number
comment?: string
paymentLabel?: string
}
export interface LnUrlPayRequestData {
callback: string
minSendable: number
maxSendable: number
metadataStr: string
commentAllowed: number
domain: string
allowsNostr: boolean
nostrPubkey?: string
lnAddress?: string
}
export interface LnUrlPaySuccessData {
successAction?: SuccessActionProcessed
payment: Payment
}
export interface LnUrlWithdrawRequest {
data: LnUrlWithdrawRequestData
amountMsat: number
description?: string
}
export interface LnUrlWithdrawRequestData {
callback: string
k1: string
defaultDescription: string
minWithdrawable: number
maxWithdrawable: number
}
export interface LnUrlWithdrawSuccessData {
invoice: LnInvoice
}
export interface LogEntry {
line: string
level: string
}
export interface MessageSuccessActionData {
message: string
}
export interface PayOnchainRequest {
address: string
prepareRes: PreparePayOnchainResponse
@@ -139,6 +214,66 @@ export interface SendPaymentResponse {
payment: Payment
}
export interface UrlSuccessActionData {
description: string
url: string
}
export enum AesSuccessActionDataResultVariant {
DECRYPTED = "decrypted",
ERROR_STATUS = "errorStatus"
}
export type AesSuccessActionDataResult = {
type: AesSuccessActionDataResultVariant.DECRYPTED,
data: AesSuccessActionDataDecrypted
} | {
type: AesSuccessActionDataResultVariant.ERROR_STATUS,
reason: string
}
export enum InputTypeVariant {
BITCOIN_ADDRESS = "bitcoinAddress",
BOLT11 = "bolt11",
NODE_ID = "nodeId",
URL = "url",
LN_URL_PAY = "lnUrlPay",
LN_URL_WITHDRAW = "lnUrlWithdraw",
LN_URL_AUTH = "lnUrlAuth",
LN_URL_ERROR = "lnUrlError"
}
export type InputType = {
type: InputTypeVariant.BITCOIN_ADDRESS,
address: BitcoinAddressData
} | {
type: InputTypeVariant.BOLT11,
invoice: LnInvoice
} | {
type: InputTypeVariant.NODE_ID,
nodeId: string
} | {
type: InputTypeVariant.URL,
url: string
} | {
type: InputTypeVariant.LN_URL_PAY,
data: LnUrlPayRequestData
} | {
type: InputTypeVariant.LN_URL_WITHDRAW,
data: LnUrlWithdrawRequestData
} | {
type: InputTypeVariant.LN_URL_AUTH,
data: LnUrlAuthRequestData
} | {
type: InputTypeVariant.LN_URL_ERROR,
data: LnUrlErrorData
}
export enum LiquidNetwork {
MAINNET = "mainnet",
TESTNET = "testnet"
}
export enum LiquidSdkEventVariant {
PAYMENT_FAILED = "paymentFailed",
PAYMENT_PENDING = "paymentPending",
@@ -171,9 +306,53 @@ export type LiquidSdkEvent = {
type: LiquidSdkEventVariant.SYNCED
}
export enum LnUrlCallbackStatusVariant {
OK = "ok",
ERROR_STATUS = "errorStatus"
}
export type LnUrlCallbackStatus = {
type: LnUrlCallbackStatusVariant.OK
} | {
type: LnUrlCallbackStatusVariant.ERROR_STATUS,
data: LnUrlErrorData
}
export enum LnUrlPayResultVariant {
ENDPOINT_SUCCESS = "endpointSuccess",
ENDPOINT_ERROR = "endpointError",
PAY_ERROR = "payError"
}
export type LnUrlPayResult = {
type: LnUrlPayResultVariant.ENDPOINT_SUCCESS,
data: LnUrlPaySuccessData
} | {
type: LnUrlPayResultVariant.ENDPOINT_ERROR,
data: LnUrlErrorData
} | {
type: LnUrlPayResultVariant.PAY_ERROR,
data: LnUrlPayErrorData
}
export enum LnUrlWithdrawResultVariant {
OK = "ok",
ERROR_STATUS = "errorStatus"
}
export type LnUrlWithdrawResult = {
type: LnUrlWithdrawResultVariant.OK,
data: LnUrlWithdrawSuccessData
} | {
type: LnUrlWithdrawResultVariant.ERROR_STATUS,
data: LnUrlErrorData
}
export enum Network {
MAINNET = "mainnet",
TESTNET = "testnet"
BITCOIN = "bitcoin",
TESTNET = "testnet",
SIGNET = "signet",
REGTEST = "regtest"
}
export enum PaymentState {
@@ -189,6 +368,23 @@ export enum PaymentType {
SEND = "send"
}
export enum SuccessActionProcessedVariant {
AES = "aes",
MESSAGE = "message",
URL = "url"
}
export type SuccessActionProcessed = {
type: SuccessActionProcessedVariant.AES,
result: AesSuccessActionDataResult
} | {
type: SuccessActionProcessedVariant.MESSAGE,
data: MessageSuccessActionData
} | {
type: SuccessActionProcessedVariant.URL,
data: UrlSuccessActionData
}
export type EventListener = (e: LiquidSdkEvent) => void
export type Logger = (logEntry: LogEntry) => void
@@ -215,13 +411,18 @@ export const setLogger = async (logger: Logger): Promise<EmitterSubscription> =>
return subscription
}
export const defaultConfig = async (network: Network): Promise<Config> => {
export const defaultConfig = async (network: LiquidNetwork): Promise<Config> => {
const response = await BreezLiquidSDK.defaultConfig(network)
return response
}
export const parseInvoice = async (invoice: string): Promise<LnInvoice> => {
const response = await BreezLiquidSDK.parseInvoice(invoice)
export const parse = async (input: string): Promise<InputType> => {
const response = await BreezLiquidSDK.parse(input)
return response
}
export const parseInvoice = async (input: string): Promise<LnInvoice> => {
const response = await BreezLiquidSDK.parseInvoice(input)
return response
}
@@ -285,3 +486,18 @@ export const restore = async (req: RestoreRequest): Promise<void> => {
export const disconnect = async (): Promise<void> => {
await BreezLiquidSDK.disconnect()
}
export const lnurlPay = async (req: LnUrlPayRequest): Promise<LnUrlPayResult> => {
const response = await BreezLiquidSDK.lnurlPay(req)
return response
}
export const lnurlWithdraw = async (req: LnUrlWithdrawRequest): Promise<LnUrlWithdrawResult> => {
const response = await BreezLiquidSDK.lnurlWithdraw(req)
return response
}
export const lnurlAuth = async (reqData: LnUrlAuthRequestData): Promise<LnUrlCallbackStatus> => {
const response = await BreezLiquidSDK.lnurlAuth(reqData)
return response
}