From b100b51e6bf32796987072affc6ea86e4e46b5cb Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Mon, 14 Oct 2024 13:00:29 +0200 Subject: [PATCH] Add get_payment docs --- .github/workflows/main.yml | 8 +- examples/python/cli/pyproject.toml | 2 +- snippets/csharp/ListPayments.cs | 17 ++ snippets/dart_snippets/lib/list_payments.dart | 9 + snippets/dart_snippets/pubspec.lock | 8 +- snippets/dart_snippets/pubspec.yaml | 4 +- snippets/go/go.mod | 2 +- snippets/go/list_payments.go | 12 + .../kotlin_mpp_lib/shared/build.gradle.kts | 2 +- .../com/example/kotlinmpplib/ListPayments.kt | 11 + snippets/python/src/list_payments.py | 12 +- snippets/react-native/list_payments.ts | 12 + snippets/react-native/package.json | 2 +- snippets/react-native/yarn.lock | 8 +- snippets/rust/Cargo.lock | 210 +++++++++++++++++- snippets/rust/Cargo.toml | 2 +- snippets/rust/src/list_payments.rs | 12 + .../swift/BreezSDKExamples/Package.resolved | 4 +- snippets/swift/BreezSDKExamples/Package.swift | 2 +- .../Sources/ListPayments.swift | 10 + src/guide/install.md | 2 +- src/guide/list_payments.md | 70 ++++++ 22 files changed, 391 insertions(+), 30 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 971b760..069d4c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,10 +11,10 @@ on: workflow_dispatch: inputs: sdk-ref: - description: 'sdk commit/tag/branch reference. Defaults to 0.3.4' + description: 'sdk commit/tag/branch reference. Defaults to 0.4.0-rc3' required: false type: string - default: 0.3.4 + default: 0.4.0-rc3 concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -26,9 +26,9 @@ jobs: runs-on: ubuntu-latest outputs: # Used only for Rust snippets - sdk-ref: ${{ inputs.sdk-ref || '0.3.4' }} + sdk-ref: ${{ inputs.sdk-ref || '0.4.0-rc3' }} # Used for RN and Flutter snippets - package-version: '0.3.4' + package-version: '0.4.0-rc3' steps: - run: echo "set pre-setup output variables" diff --git a/examples/python/cli/pyproject.toml b/examples/python/cli/pyproject.toml index 9ad0db6..5ff3c01 100644 --- a/examples/python/cli/pyproject.toml +++ b/examples/python/cli/pyproject.toml @@ -7,7 +7,7 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.8.1" -breez-sdk-liquid = "^0.3.4" +breez-sdk-liquid = "^0.4.0-rc3" argparse = "^1.4.0" qrcode = "^7.4.2" colorama = "^0.4.6" diff --git a/snippets/csharp/ListPayments.cs b/snippets/csharp/ListPayments.cs index f17570d..1400c77 100644 --- a/snippets/csharp/ListPayments.cs +++ b/snippets/csharp/ListPayments.cs @@ -2,6 +2,23 @@ public class ListPaymentsSnippets { + public void GetPayment(BindingLiquidSdk sdk) + { + // ANCHOR: get-payment + try + { + var paymentHash = ""; + var payment = sdk.GetPayment( + new GetPaymentRequest.Lightning(paymentHash) + ); + } + catch (Exception) + { + // Handle error + } + // ANCHOR_END: get-payment + } + public void ListPayments(BindingLiquidSdk sdk) { // ANCHOR: list-payments diff --git a/snippets/dart_snippets/lib/list_payments.dart b/snippets/dart_snippets/lib/list_payments.dart index fcfc276..d7678dd 100644 --- a/snippets/dart_snippets/lib/list_payments.dart +++ b/snippets/dart_snippets/lib/list_payments.dart @@ -1,6 +1,15 @@ import 'package:dart_snippets/sdk_instance.dart'; import 'package:flutter_breez_liquid/flutter_breez_liquid.dart'; +Future getPayment() async { + // ANCHOR: get-payment + String paymentHash = ""; + GetPaymentRequest req = GetPaymentRequest.lightning(paymentHash: paymentHash); + Payment? payment = await breezSDKLiquid.instance!.getPayment(req: req); + // ANCHOR_END: get-payment + return payment; +} + Future> listPayments() async { // ANCHOR: list-payments ListPaymentsRequest req = ListPaymentsRequest(); diff --git a/snippets/dart_snippets/pubspec.lock b/snippets/dart_snippets/pubspec.lock index cf19c66..f274599 100644 --- a/snippets/dart_snippets/pubspec.lock +++ b/snippets/dart_snippets/pubspec.lock @@ -46,10 +46,10 @@ packages: description: path: "." ref: HEAD - resolved-ref: fe172bab450a18f166c533e28868a3d68180ca41 + resolved-ref: 399a455a3618de58c97dc25380a5166239835b52 url: "https://github.com/breez/breez-sdk-liquid-dart" source: git - version: "0.3.4" + version: "0.4.0-rc3" build_cli_annotations: dependency: transitive description: @@ -140,10 +140,10 @@ packages: description: path: "." ref: HEAD - resolved-ref: bf303dff81a6915249712761b768d58337e3e833 + resolved-ref: 7659a0ca7405247c2dbbcd94ac6aec62ddf60570 url: "https://github.com/breez/breez-sdk-liquid-flutter" source: git - version: "0.3.4" + version: "0.4.0-rc3" flutter_rust_bridge: dependency: transitive description: diff --git a/snippets/dart_snippets/pubspec.yaml b/snippets/dart_snippets/pubspec.yaml index 0fd0f7b..e5731be 100644 --- a/snippets/dart_snippets/pubspec.yaml +++ b/snippets/dart_snippets/pubspec.yaml @@ -10,11 +10,11 @@ dependencies: breez_liquid: git: url: https://github.com/breez/breez-sdk-liquid-dart - tag: 0.3.4 + tag: 0.4.0-rc3 flutter_breez_liquid: git: url: https://github.com/breez/breez-sdk-liquid-flutter - tag: 0.3.4 + tag: 0.4.0-rc3 rxdart: ^0.28.0 dependency_overrides: diff --git a/snippets/go/go.mod b/snippets/go/go.mod index 3afd230..e68c512 100644 --- a/snippets/go/go.mod +++ b/snippets/go/go.mod @@ -2,6 +2,6 @@ module main go 1.19 -require github.com/breez/breez-sdk-liquid-go v0.3.4 +require github.com/breez/breez-sdk-liquid-go v0.4.0-rc3 //replace github.com/breez/breez-sdk-liquid-go => ./packages/breez-sdk-liquid-go diff --git a/snippets/go/list_payments.go b/snippets/go/list_payments.go index 8f45716..4fa5b75 100644 --- a/snippets/go/list_payments.go +++ b/snippets/go/list_payments.go @@ -6,6 +6,18 @@ import ( "github.com/breez/breez-sdk-liquid-go/breez_sdk_liquid" ) +func GetPayment(sdk *breez_sdk_liquid.BindingLiquidSdk) { + // ANCHOR: get-payment + paymentHash := "" + req := breez_sdk.GetPaymentRequestLightning{ + PaymentHash: paymentHash, + } + if payment, err := sdk.GetPayment(req); err == nil { + log.Printf("%#v", payment) + } + // ANCHOR_END: get-payment +} + func ListPayments(sdk *breez_sdk_liquid.BindingLiquidSdk) { // ANCHOR: list-payments if payments, err := sdk.ListPayments(breez_sdk_liquid.ListPaymentsRequest{}); err == nil { diff --git a/snippets/kotlin_mpp_lib/shared/build.gradle.kts b/snippets/kotlin_mpp_lib/shared/build.gradle.kts index 381421f..34688c4 100644 --- a/snippets/kotlin_mpp_lib/shared/build.gradle.kts +++ b/snippets/kotlin_mpp_lib/shared/build.gradle.kts @@ -29,7 +29,7 @@ kotlin { } val commonMain by getting { dependencies { - implementation("technology.breez.liquid:breez-sdk-liquid-kmp:0.3.4") + implementation("technology.breez.liquid:breez-sdk-liquid-kmp:0.4.0-rc3") } } } diff --git a/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ListPayments.kt b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ListPayments.kt index 30c048a..b3a3406 100644 --- a/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ListPayments.kt +++ b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ListPayments.kt @@ -2,6 +2,17 @@ package com.example.kotlinmpplib import breez_sdk_liquid.* class ListPayments { + fun getPayment(sdk: BindingLiquidSdk) { + // ANCHOR: get-payment + try { + val paymentHash = ""; + val payment = sdk.getPayment(GetPaymentRequest.Lightning(paymentHash)) + } catch (e: Exception) { + // handle error + } + // ANCHOR_END: get-payment + } + fun listPayments(sdk: BindingLiquidSdk) { // ANCHOR: list-payments try { diff --git a/snippets/python/src/list_payments.py b/snippets/python/src/list_payments.py index a653165..7bc3d69 100644 --- a/snippets/python/src/list_payments.py +++ b/snippets/python/src/list_payments.py @@ -1,7 +1,17 @@ -from breez_sdk_liquid import BindingLiquidSdk, ListPaymentsRequest, PaymentType +from breez_sdk_liquid import BindingLiquidSdk, GetPaymentRequest, ListPaymentsRequest, PaymentType import logging +def get_payment(sdk: BindingLiquidSdk): + try: + # ANCHOR: get-payment + payment_hash = "" + sdk.get_payment(GetPaymentRequest.LIGHTNING(payment_hash)) + # ANCHOR_END: get-payment + except Exception as error: + logging.error(error) + raise + def list_payments(sdk: BindingLiquidSdk): try: # ANCHOR: list-payments diff --git a/snippets/react-native/list_payments.ts b/snippets/react-native/list_payments.ts index a558dcd..13f6148 100644 --- a/snippets/react-native/list_payments.ts +++ b/snippets/react-native/list_payments.ts @@ -1,8 +1,20 @@ import { + getPayment, + GetPaymentRequestVariant, listPayments, PaymentType } from '@breeztech/react-native-breez-sdk-liquid' +const exampleGetPayment = async () => { + // ANCHOR: get-payment + const paymentHash = '' + const payment = await getPayment({ + type: GetPaymentRequestVariant.LIGHTNING, + paymentHash + }) + // ANCHOR_END: get-payment +} + const exampleListPayments = async () => { // ANCHOR: list-payments const payments = await listPayments({}) diff --git a/snippets/react-native/package.json b/snippets/react-native/package.json index ce9750f..21def0f 100644 --- a/snippets/react-native/package.json +++ b/snippets/react-native/package.json @@ -10,7 +10,7 @@ "compile": "tsc" }, "dependencies": { - "@breeztech/react-native-breez-sdk-liquid": "^0.3.4", + "@breeztech/react-native-breez-sdk-liquid": "^0.4.0-rc3", "react": "18.1.0", "react-native": "0.70.6" }, diff --git a/snippets/react-native/yarn.lock b/snippets/react-native/yarn.lock index 30cce37..0b930f4 100644 --- a/snippets/react-native/yarn.lock +++ b/snippets/react-native/yarn.lock @@ -703,10 +703,10 @@ "@babel/helper-validator-identifier" "^7.24.7" to-fast-properties "^2.0.0" -"@breeztech/react-native-breez-sdk-liquid@^0.3.4": - version "0.3.4" - resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk-liquid/-/react-native-breez-sdk-liquid-0.3.4.tgz#2519e19e4268850d15b72ea29cfb6e145261b321" - integrity sha512-c0L3n9suD1Y2poIfOyjSlWzCfNxy42TsZcAkvfG5uOEoAIZccTwPGHwHla+x/vZFugQ7QTBC+AGrJtTQKUZ+aQ== +"@breeztech/react-native-breez-sdk-liquid@^0.4.0-rc3": + version "0.4.0-rc3" + resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk-liquid/-/react-native-breez-sdk-liquid-0.4.0-rc3.tgz#9a99abcc792e54302e54ebdddc4d72a9173ebeaa" + integrity sha512-3uMMz6BfYmx4KDs+YU+OwAYIJQTfJbtRzEHpa3PE7j4QBtfpffTp2MqN/HxkKqhw/98u/kfDdbklO5PmF+BrFg== "@esbuild/android-arm64@0.18.20": version "0.18.20" diff --git a/snippets/rust/Cargo.lock b/snippets/rust/Cargo.lock index 971db6b..55ff65d 100644 --- a/snippets/rust/Cargo.lock +++ b/snippets/rust/Cargo.lock @@ -194,6 +194,45 @@ dependencies = [ "backtrace", ] +[[package]] +name = "asn1-rs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -520,8 +559,8 @@ dependencies = [ [[package]] name = "breez-sdk-liquid" -version = "0.3.4" -source = "git+https://github.com/breez/breez-sdk-liquid?tag=0.3.4#4d1690bfc47ae203b0c5facf14ccae218f74cf2e" +version = "0.4.0-rc3" +source = "git+https://github.com/breez/breez-sdk-liquid?tag=0.4.0-rc3#0a66f4c5a8f3fd0c8b5cb6e3ec0f9650e6be8ce0" dependencies = [ "anyhow", "async-trait", @@ -554,6 +593,7 @@ dependencies = [ "tokio-stream", "tokio-tungstenite", "url", + "x509-parser", "zbase32", ] @@ -785,6 +825,29 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "digest" version = "0.10.7" @@ -796,6 +859,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "either" version = "1.13.0" @@ -950,9 +1024,9 @@ dependencies = [ [[package]] name = "flutter_rust_bridge" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13c1e57b460f7adbd6cbf8b4cd0a1d14238ed64f5cc2a6c2ccb7a605ac01354" +checksum = "6ff967a5893be60d849e4362910762acdc275febe44333153a11dcec1bca2cd2" dependencies = [ "allo-isolate", "android_logger", @@ -979,9 +1053,9 @@ dependencies = [ [[package]] name = "flutter_rust_bridge_macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c85e62d6d34f5c1590af004ccd3dc45b1c726dba6721b632b164c19894fab4" +checksum = "d48b4d3fae9d29377b19134a38386d8792bde70b9448cde49e96391bcfc8fed1" dependencies = [ "hex", "md-5", @@ -1810,6 +1884,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniscript" version = "11.2.0" @@ -1874,6 +1954,41 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1902,6 +2017,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "oid-registry" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" +dependencies = [ + "asn1-rs", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -2076,6 +2200,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -2459,6 +2589,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + [[package]] name = "rustix" version = "0.38.35" @@ -2957,6 +3096,17 @@ dependencies = [ "futures-core", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -3046,6 +3196,37 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -3807,6 +3988,23 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "x509-parser" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" +dependencies = [ + "asn1-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror", + "time", +] + [[package]] name = "zbase32" version = "0.1.2" diff --git a/snippets/rust/Cargo.toml b/snippets/rust/Cargo.toml index 8399d5f..aafa27b 100644 --- a/snippets/rust/Cargo.toml +++ b/snippets/rust/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] anyhow = "1" bip39 = { version = "2", features = ["rand"] } -breez-sdk-liquid = { git = "https://github.com/breez/breez-sdk-liquid", tag = "0.3.4" } +breez-sdk-liquid = { git = "https://github.com/breez/breez-sdk-liquid", tag = "0.4.0-rc3" } log = "0.4" tokio = "1.29" diff --git a/snippets/rust/src/list_payments.rs b/snippets/rust/src/list_payments.rs index 957ce25..aa48e2e 100644 --- a/snippets/rust/src/list_payments.rs +++ b/snippets/rust/src/list_payments.rs @@ -3,6 +3,17 @@ use std::sync::Arc; use anyhow::Result; use breez_sdk_liquid::prelude::*; +async fn get_payment(sdk: Arc) -> Result> { + // ANCHOR: get-payment + let payment_hash = "".to_string(); + let payment = sdk.get_payment(&GetPaymentRequest::Lightning { + payment_hash + }).await?; + // ANCHOR_END: get-payment + + Ok(payment) +} + async fn list_payments(sdk: Arc) -> Result> { // ANCHOR: list-payments let payments = sdk.list_payments(&ListPaymentsRequest::default()).await?; @@ -20,6 +31,7 @@ async fn list_payments_filtered(sdk: Arc) -> Result> { to_timestamp: Some(1696959200), offset: Some(0), limit: Some(50), + details: None, }) .await?; // ANCHOR_END: list-payments-filtered diff --git a/snippets/swift/BreezSDKExamples/Package.resolved b/snippets/swift/BreezSDKExamples/Package.resolved index 35fb324..017b579 100644 --- a/snippets/swift/BreezSDKExamples/Package.resolved +++ b/snippets/swift/BreezSDKExamples/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/breez/breez-sdk-liquid-swift", "state" : { - "revision" : "d1b44db8bd99516d42006f07d7fa4a078acb2623", - "version" : "0.3.4" + "revision" : "d66001f453fea3f0715690e943c65464bd3d1230", + "version" : "0.4.0-rc3" } }, { diff --git a/snippets/swift/BreezSDKExamples/Package.swift b/snippets/swift/BreezSDKExamples/Package.swift index 2e1b369..f60abfc 100644 --- a/snippets/swift/BreezSDKExamples/Package.swift +++ b/snippets/swift/BreezSDKExamples/Package.swift @@ -8,7 +8,7 @@ let package = Package( platforms: [.macOS("15.0")], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"), - .package(url: "https://github.com/breez/breez-sdk-liquid-swift", from:"0.3.4") + .package(url: "https://github.com/breez/breez-sdk-liquid-swift", from:"0.4.0-rc3") // To use a local version of breez-sdk-liquid, comment-out the above and un-comment: // .package(name: "bindings-swift", path: "/local-path/breez-sdk-liquid/lib/bindings/langs/swift") ], diff --git a/snippets/swift/BreezSDKExamples/Sources/ListPayments.swift b/snippets/swift/BreezSDKExamples/Sources/ListPayments.swift index 7a10a79..1726552 100644 --- a/snippets/swift/BreezSDKExamples/Sources/ListPayments.swift +++ b/snippets/swift/BreezSDKExamples/Sources/ListPayments.swift @@ -1,6 +1,16 @@ import BreezSDKLiquid import Foundation +func getPayment(sdk: BindingLiquidSdk) -> Payment? { + // ANCHOR: get-payment + let paymentHash = "" + let payment = try? sdk.getPayment( + req: GetPaymentRequest.lightning(paymentHash: paymentHash) + ) + // ANCHOR_END: get-payment + return payment +} + func listPayments(sdk: BindingLiquidSdk) -> [Payment]? { // ANCHOR: list-payments let payments = try? sdk.listPayments(req: ListPaymentsRequest()) diff --git a/src/guide/install.md b/src/guide/install.md index b1f7569..544e9e8 100644 --- a/src/guide/install.md +++ b/src/guide/install.md @@ -91,7 +91,7 @@ Check https://github.com/breez/breez-sdk-liquid/releases for the latest version. ```toml [dependencies] -breez-sdk-liquid = { git = "https://github.com/breez/breez-sdk-liquid", tag = "0.3.4" } +breez-sdk-liquid = { git = "https://github.com/breez/breez-sdk-liquid", tag = "0.4.0-rc3" } [patch.crates-io] secp256k1-zkp = {git = "https://github.com/sanket1729/rust-secp256k1-zkp.git", rev = "60e631c24588a0c9e271badd61959294848c665d"} diff --git a/src/guide/list_payments.md b/src/guide/list_payments.md index 426e4fa..0cedfbf 100644 --- a/src/guide/list_payments.md +++ b/src/guide/list_payments.md @@ -135,3 +135,73 @@ You can optionally filter payments by timestamp and type. ``` + +## Get Payment + +You can also retrieve a single Lightning payment using the invoice payment hash. + + +
Rust
+
+ +```rust,ignore +{{#include ../../snippets/rust/src/list_payments.rs:get-payment}} +``` +
+ +
Swift
+
+ +```swift,ignore +{{#include ../../snippets/swift/BreezSDKExamples/Sources/ListPayments.swift:get-payment}} +``` +
+ +
Kotlin
+
+ +```kotlin,ignore +{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ListPayments.kt:get-payment}} +``` +
+ +
React Native
+
+ +```typescript +{{#include ../../snippets/react-native/list_payments.ts:get-payment}} +``` +
+ +
Dart
+
+ +```dart,ignore +{{#include ../../snippets/dart_snippets/lib/list_payments.dart:get-payment}} +``` +
+ +
Python
+
+ +```python,ignore +{{#include ../../snippets/python/src/list_payments.py:get-payment}} +``` +
+ +
Go
+
+ +```go,ignore +{{#include ../../snippets/go/list_payments.go:get-payment}} +``` +
+ +
C#
+
+ +```cs,ignore +{{#include ../../snippets/csharp/ListPayments.cs:get-payment}} +``` +
+