mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Merge branch 'main' into ok300-bump-sdk-dependency-version
# Conflicts: # snippets/dart_snippets/lib/send_spontaneous_payment.dart
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -105,8 +105,8 @@ jobs:
|
|||||||
# Set up the flutter environment and run checks
|
# Set up the flutter environment and run checks
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '3.13.9'
|
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
|
cache: true
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
43
snippets/csharp/ClosedChannel.cs
Normal file
43
snippets/csharp/ClosedChannel.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using Breez.Sdk;
|
||||||
|
|
||||||
|
public class ClosedChannelSnippets
|
||||||
|
{
|
||||||
|
public void PrepareRedeemOnchainFunds(BlockingBreezServices sdk, uint feeRate)
|
||||||
|
{
|
||||||
|
// ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
var destinationAddress = "bc1..";
|
||||||
|
var satPerVbyte = feeRate;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var prepareRedeemOnchainFundsResp = sdk.PrepareRedeemOnchainFunds(
|
||||||
|
new PrepareRedeemOnchainFundsRequest(
|
||||||
|
destinationAddress,
|
||||||
|
satPerVbyte
|
||||||
|
));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RedeemOnchainFunds(BlockingBreezServices sdk, uint satPerVbyte, string toAddress)
|
||||||
|
{
|
||||||
|
// ANCHOR: redeem-onchain-funds
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var redeemOnchainFundsResp = sdk.RedeemOnchainFunds(
|
||||||
|
new RedeemOnchainFundsRequest(
|
||||||
|
toAddress,
|
||||||
|
satPerVbyte
|
||||||
|
));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: redeem-onchain-funds
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
snippets/dart_snippets/lib/closed_channel.dart
Normal file
26
snippets/dart_snippets/lib/closed_channel.dart
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import 'package:breez_sdk/breez_sdk.dart';
|
||||||
|
import 'package:breez_sdk/bridge_generated.dart';
|
||||||
|
|
||||||
|
Future<PrepareRedeemOnchainFundsResponse> prepareRedeemOnchainFunds(
|
||||||
|
{required int satPerVbyte}) async {
|
||||||
|
// ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
PrepareRedeemOnchainFundsRequest req = PrepareRedeemOnchainFundsRequest(
|
||||||
|
toAddress: "bc1..",
|
||||||
|
satPerVbyte: satPerVbyte,
|
||||||
|
);
|
||||||
|
final resp = await BreezSDK().prepareRedeemOnchainFunds(req: req);
|
||||||
|
// ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<RedeemOnchainFundsResponse> redeemOnchainFunds(
|
||||||
|
{required int satPerVbyte, required String toAddress}) async {
|
||||||
|
// ANCHOR: redeem-onchain-funds
|
||||||
|
RedeemOnchainFundsRequest req = RedeemOnchainFundsRequest(
|
||||||
|
toAddress: "bc1..",
|
||||||
|
satPerVbyte: satPerVbyte,
|
||||||
|
);
|
||||||
|
final resp = await BreezSDK().redeemOnchainFunds(req: req);
|
||||||
|
// ANCHOR_END: redeem-onchain-funds
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
27
snippets/go/closed_channel.go
Normal file
27
snippets/go/closed_channel.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PrepareRedeemOnchainFunds(feeRate uint32) {
|
||||||
|
// ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
satPerVbyte := feeRate
|
||||||
|
destinationAddress := "bc1.."
|
||||||
|
req := breez_sdk.PrepareRedeemOnchainFundsRequest{SatPerVbyte: satPerVbyte, ToAddress: destinationAddress}
|
||||||
|
if prepareRedeemOnchainFundsResponse, err := sdk.PrepareRedeemOnchainFunds(req); err == nil {
|
||||||
|
log.Printf("PrepareRedeemOnchainFundsRequest is %#v", prepareRedeemOnchainFundsResponse)
|
||||||
|
}
|
||||||
|
// ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
}
|
||||||
|
|
||||||
|
func RedeemOnchainFunds(satPerVbyte uint32, toAddress string) {
|
||||||
|
// ANCHOR: redeem-onchain-funds
|
||||||
|
req := breez_sdk.RedeemOnchainFundsRequest{SatPerVbyte: satPerVbyte, ToAddress: toAddress}
|
||||||
|
if redeemOnchainFundsResponse, err := sdk.RedeemOnchainFunds(req); err == nil {
|
||||||
|
log.Printf("RedeemOnchainFunds error %#v", redeemOnchainFundsResponse)
|
||||||
|
}
|
||||||
|
// ANCHOR_END: redeem-onchain-funds
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.example.kotlinmpplib
|
||||||
|
|
||||||
|
import breez_sdk.*
|
||||||
|
class ClosedChannel {
|
||||||
|
fun prepareRedeemOnchainFunds(sdk: BlockingBreezServices, feeRate: UInt) {
|
||||||
|
// ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
val satPerVbyte = feeRate
|
||||||
|
var destinationAddress = "bc1.."
|
||||||
|
try {
|
||||||
|
val req = PrepareRedeemOnchainFundsRequest(destinationAddress, satPerVbyte)
|
||||||
|
val prepareRedeemOnchainFundsResp = sdk.prepareRedeemOnchainFunds(req)
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
// handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
}
|
||||||
|
|
||||||
|
fun redeemOnchainFunds(sdk: BlockingBreezServices, satPerVbyte: UInt, toAddress: String) {
|
||||||
|
// ANCHOR: redeem-onchain-funds
|
||||||
|
try {
|
||||||
|
val req = RedeemOnchainFundsRequest(toAddress, satPerVbyte)
|
||||||
|
val redeemOnchainFundsResp = sdk.redeemOnchainFunds(req)
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
// handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: redeem-onchain-funds
|
||||||
|
}
|
||||||
|
}
|
||||||
26
snippets/python/src/closed_channel.py
Normal file
26
snippets/python/src/closed_channel.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import breez_sdk
|
||||||
|
|
||||||
|
def prepare_redeem_onchain_funds(sdk_services, fee_rate):
|
||||||
|
|
||||||
|
try:
|
||||||
|
# ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
destination_address = "bc1.."
|
||||||
|
sat_per_vbyte = fee_rate
|
||||||
|
req = breez_sdk.PrepareRedeemOnchainFundsRequest(destination_address, sat_per_vbyte)
|
||||||
|
result = sdk_services.prepare_redeem_onchain_funds(req)
|
||||||
|
# ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
return result
|
||||||
|
except Exception as error:
|
||||||
|
print(error)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def redeem_onchain_funds(sdk_services, to_address, fee_rate):
|
||||||
|
try:
|
||||||
|
# ANCHOR: redeem-onchain-funds
|
||||||
|
req = breez_sdk.RedeemOnchainFundsRequest(to_address, fee_rate)
|
||||||
|
result = sdk_services.redeem_onchain_funds(req)
|
||||||
|
# ANCHOR_END: redeem-onchain-funds
|
||||||
|
return result
|
||||||
|
except Exception as error:
|
||||||
|
print(error)
|
||||||
|
raise
|
||||||
@@ -3,13 +3,14 @@ import breez_sdk
|
|||||||
|
|
||||||
|
|
||||||
def send_spontaneous_payment(sdk_services):
|
def send_spontaneous_payment(sdk_services):
|
||||||
# ANCHOR: send-spontaneous-payment
|
|
||||||
node_id = "..."
|
|
||||||
amount_msat = 300000
|
|
||||||
try:
|
try:
|
||||||
req = breez_sdk.SendSpontaneousPaymentRequest(node_id, amount_msat)
|
|
||||||
result = sdk_services.send_spontaneous_payment(req)
|
|
||||||
# ANCHOR: send-spontaneous-payment
|
# ANCHOR: send-spontaneous-payment
|
||||||
|
node_id = "..."
|
||||||
|
amount_msat = 3000000
|
||||||
|
|
||||||
|
req = breez_sdk.SendSpontaneousPaymentRequest(node_id,amount_msat)
|
||||||
|
result = sdk_services.send_spontaneous_payment(req)
|
||||||
|
# ANCHOR_END: send-spontaneous-payment
|
||||||
return result
|
return result
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
print(error)
|
print(error)
|
||||||
|
|||||||
19
snippets/react-native/closed_channel.ts
Normal file
19
snippets/react-native/closed_channel.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
prepareRedeemOnchainFunds,
|
||||||
|
redeemOnchainFunds
|
||||||
|
} from '@breeztech/react-native-breez-sdk'
|
||||||
|
|
||||||
|
const examplePrepareRedeemOnchainFunds = async (feeRate: number) => {
|
||||||
|
// ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
const toAddress = 'bc1..'
|
||||||
|
const satPerVbyte = feeRate
|
||||||
|
|
||||||
|
const prepareRedeemOnchainFundsResp = await prepareRedeemOnchainFunds({ toAddress, satPerVbyte })
|
||||||
|
// ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
}
|
||||||
|
|
||||||
|
const exampleRedeemOnchainFunds = async (satPerVbyte: number, toAddress: string) => {
|
||||||
|
// ANCHOR: redeem-onchain-funds
|
||||||
|
const redeemOnchainFundsResp = await redeemOnchainFunds({ toAddress, satPerVbyte })
|
||||||
|
// ANCHOR_END: redeem-onchain-funds
|
||||||
|
}
|
||||||
904
snippets/rust/Cargo.lock
generated
904
snippets/rust/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
32
snippets/rust/src/closed_channel.rs
Normal file
32
snippets/rust/src/closed_channel.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use breez_sdk_core::*;
|
||||||
|
|
||||||
|
async fn prepare_redeem_onchain_funds(sdk: Arc<BreezServices>, fee_rate: u32) -> Result<()> {
|
||||||
|
// ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
let sat_per_vbyte = fee_rate;
|
||||||
|
let destination_address = String::from("bc1..");
|
||||||
|
sdk.prepare_redeem_onchain_funds(PrepareRedeemOnchainFundsRequest {
|
||||||
|
sat_per_vbyte,
|
||||||
|
to_address: destination_address,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
// ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn redeem_onchain_funds(
|
||||||
|
sdk: Arc<BreezServices>,
|
||||||
|
sat_per_vbyte: u32,
|
||||||
|
to_address: String,
|
||||||
|
) -> Result<()> {
|
||||||
|
// ANCHOR: redeem-onchain-funds
|
||||||
|
sdk.redeem_onchain_funds(RedeemOnchainFundsRequest {
|
||||||
|
sat_per_vbyte,
|
||||||
|
to_address,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
// ANCHOR_END: redeem-onchain-funds
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
mod buy_btc;
|
mod buy_btc;
|
||||||
|
mod closed_channel;
|
||||||
mod connecting_lsp;
|
mod connecting_lsp;
|
||||||
mod fiat_currencies;
|
mod fiat_currencies;
|
||||||
mod getting_started;
|
mod getting_started;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import PackageDescription
|
|||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "BreezSDKDocs",
|
name: "BreezSDKDocs",
|
||||||
platforms: [.macOS(.v12)],
|
platforms: [.macOS(.v13)],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"),
|
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"),
|
||||||
.package(url: "https://github.com/breez/breez-sdk-swift", from:"0.2.15")
|
.package(url: "https://github.com/breez/breez-sdk-swift", from:"0.2.15")
|
||||||
@@ -16,8 +16,9 @@ let package = Package(
|
|||||||
.executableTarget(
|
.executableTarget(
|
||||||
name: "BreezSDKDocs",
|
name: "BreezSDKDocs",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
|
||||||
.product(name: "BreezSDK", package: "breez-sdk-swift"),
|
.product(name: "BreezSDK", package: "breez-sdk-swift"),
|
||||||
|
// use a local version of breez-sdk
|
||||||
|
// .product(name: "BreezSDK", package: "bindings-swift"),
|
||||||
],
|
],
|
||||||
path: "Sources"),
|
path: "Sources"),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func buy(sdk: BlockingBreezServices) -> BuyBitcoinResponse? {
|
func buy(sdk: BlockingBreezServices) -> BuyBitcoinResponse? {
|
||||||
// ANCHOR: buy-btc
|
// ANCHOR: buy-btc
|
||||||
|
|||||||
27
snippets/swift/BreezSDKExamples/Sources/ClosedChannel.swift
Normal file
27
snippets/swift/BreezSDKExamples/Sources/ClosedChannel.swift
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// ClosedChannel.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by ruben on 12/12/2023.
|
||||||
|
//
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
import BreezSDK
|
||||||
|
|
||||||
|
func prepareRedeemOnchainFunds(sdk: BlockingBreezServices, feeRate: UInt32) -> PrepareRedeemOnchainFundsResponse? {
|
||||||
|
// ANCHOR: prepare-redeem-onchain-funds
|
||||||
|
let satPerVbyte = feeRate
|
||||||
|
let req = PrepareRedeemOnchainFundsRequest(toAddress: "bc1..", satPerVbyte: satPerVbyte)
|
||||||
|
let prepareRedeemOnchainFundsResponse = try? sdk.prepareRedeemOnchainFunds(req: req)
|
||||||
|
// ANCHOR_END: prepare-redeem-onchain-funds
|
||||||
|
return prepareRedeemOnchainFundsResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
func redeemOnchainFunds(sdk: BlockingBreezServices, toAddress _: String, feeRate: UInt32) -> RedeemOnchainFundsResponse? {
|
||||||
|
// ANCHOR: redeem-onchain-funds
|
||||||
|
let satPerVbyte = feeRate
|
||||||
|
let req = RedeemOnchainFundsRequest(toAddress: "bc1..", satPerVbyte: satPerVbyte)
|
||||||
|
let redeemOnchainFundsResponse = try? sdk.redeemOnchainFunds(req: req)
|
||||||
|
// ANCHOR_END: redeem-onchain-funds
|
||||||
|
return redeemOnchainFundsResponse
|
||||||
|
}
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func getLspInfo(sdk: BlockingBreezServices) -> LspInformation?{
|
func getLspInfo(sdk: BlockingBreezServices) -> LspInformation? {
|
||||||
// ANCHOR: get-lsp-info
|
// ANCHOR: get-lsp-info
|
||||||
let lspId = try? sdk.lspId()
|
let lspId = try? sdk.lspId()
|
||||||
let lspInfo = try? sdk.lspInfo()
|
let lspInfo = try? sdk.lspInfo()
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func listSupportedFiatCurrencies(sdk: BlockingBreezServices) -> [FiatCurrency]? {
|
func listSupportedFiatCurrencies(sdk: BlockingBreezServices) -> [FiatCurrency]? {
|
||||||
// ANCHOR: list-fiat-currencies
|
// ANCHOR: list-fiat-currencies
|
||||||
@@ -15,7 +15,7 @@ func listSupportedFiatCurrencies(sdk: BlockingBreezServices) -> [FiatCurrency]?
|
|||||||
return supportedFiatCurrencies
|
return supportedFiatCurrencies
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCurrentRates(sdk:BlockingBreezServices) -> [Rate]? {
|
func getCurrentRates(sdk: BlockingBreezServices) -> [Rate]? {
|
||||||
// ANCHOR: fetch-fiat-rates
|
// ANCHOR: fetch-fiat-rates
|
||||||
let fiatRates = try? sdk.fetchFiatRates()
|
let fiatRates = try? sdk.fetchFiatRates()
|
||||||
// ANCHOR_END: fetch-fiat-rates
|
// ANCHOR_END: fetch-fiat-rates
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import BreezSDK
|
|||||||
// ANCHOR: init-sdk
|
// ANCHOR: init-sdk
|
||||||
// SDK events listener
|
// SDK events listener
|
||||||
class SDKListener: EventListener {
|
class SDKListener: EventListener {
|
||||||
func onEvent(e: BreezEvent) {
|
func onEvent(e: BreezEvent) {
|
||||||
print("received event ", e)
|
print("received event ", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func gettingStarted() throws -> BlockingBreezServices? {
|
func gettingStarted() throws -> BlockingBreezServices? {
|
||||||
@@ -22,13 +22,12 @@ func gettingStarted() throws -> BlockingBreezServices? {
|
|||||||
let inviteCode = "<invite code>"
|
let inviteCode = "<invite code>"
|
||||||
let apiKey = "<api key>"
|
let apiKey = "<api key>"
|
||||||
var config = defaultConfig(envType: EnvironmentType.production, apiKey: apiKey,
|
var config = defaultConfig(envType: EnvironmentType.production, apiKey: apiKey,
|
||||||
nodeConfig: NodeConfig.greenlight(
|
nodeConfig: NodeConfig.greenlight(
|
||||||
config: GreenlightNodeConfig(partnerCredentials: nil, inviteCode: inviteCode)))
|
config: GreenlightNodeConfig(partnerCredentials: nil, inviteCode: inviteCode)))
|
||||||
|
|
||||||
// Customize the config object according to your needs
|
// Customize the config object according to your needs
|
||||||
config.workingDir = "path to an existing directory"
|
config.workingDir = "path to an existing directory"
|
||||||
|
|
||||||
|
|
||||||
// Connect to the Breez SDK make it ready for use
|
// Connect to the Breez SDK make it ready for use
|
||||||
guard seed != nil else {
|
guard seed != nil else {
|
||||||
return nil
|
return nil
|
||||||
@@ -37,6 +36,7 @@ func gettingStarted() throws -> BlockingBreezServices? {
|
|||||||
|
|
||||||
return sdk
|
return sdk
|
||||||
}
|
}
|
||||||
|
|
||||||
// ANCHOR_END: init-sdk
|
// ANCHOR_END: init-sdk
|
||||||
func gettingStartedNodeInfo(sdk: BlockingBreezServices) {
|
func gettingStartedNodeInfo(sdk: BlockingBreezServices) {
|
||||||
// ANCHOR: fetch-balance
|
// ANCHOR: fetch-balance
|
||||||
@@ -48,5 +48,3 @@ func gettingStartedNodeInfo(sdk: BlockingBreezServices) {
|
|||||||
}
|
}
|
||||||
// ANCHOR_END: fetch-balance
|
// ANCHOR_END: fetch-balance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by ruben on 13/11/2023.
|
// Created by ruben on 13/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func ListPayments(sdk: BlockingBreezServices) -> [Payment]? {
|
func ListPayments(sdk: BlockingBreezServices) -> [Payment]? {
|
||||||
// ANCHOR: list-payments
|
// ANCHOR: list-payments
|
||||||
@@ -20,8 +20,9 @@ func ListPaymentsFiltered(sdk: BlockingBreezServices) -> [Payment]? {
|
|||||||
let payments = try? sdk.listPayments(
|
let payments = try? sdk.listPayments(
|
||||||
req: ListPaymentsRequest(
|
req: ListPaymentsRequest(
|
||||||
filters: [.sent],
|
filters: [.sent],
|
||||||
fromTimestamp: 1696880000,
|
fromTimestamp: 1_696_880_000,
|
||||||
includeFailures: true))
|
includeFailures: true
|
||||||
|
))
|
||||||
// ANCHOR_END: list-payments-filtered
|
// ANCHOR_END: list-payments-filtered
|
||||||
return payments
|
return payments
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func auth(sdk: BlockingBreezServices) {
|
func auth(sdk: BlockingBreezServices) {
|
||||||
// ANCHOR: lnurl-withdraw
|
// ANCHOR: lnurl-withdraw
|
||||||
@@ -14,14 +14,13 @@ func auth(sdk: BlockingBreezServices) {
|
|||||||
// keyauth://domain.com/auth?key=val
|
// keyauth://domain.com/auth?key=val
|
||||||
let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"
|
let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"
|
||||||
|
|
||||||
|
|
||||||
if let inputType = try? parseInput(s: lnurlAuthUrl) {
|
if let inputType = try? parseInput(s: lnurlAuthUrl) {
|
||||||
if case .lnUrlAuth(let `data`) = inputType {
|
if case let .lnUrlAuth(data) = inputType {
|
||||||
let result = try? sdk.lnurlAuth(reqData: data)
|
let result = try? sdk.lnurlAuth(reqData: data)
|
||||||
switch result {
|
switch result {
|
||||||
case .ok:
|
case .ok:
|
||||||
print("Successfully authenticated")
|
print("Successfully authenticated")
|
||||||
case .errorStatus(let error):
|
case let .errorStatus(error):
|
||||||
print("Failed to authenticate: \(error)")
|
print("Failed to authenticate: \(error)")
|
||||||
case .none:
|
case .none:
|
||||||
print("Failed to authenticate")
|
print("Failed to authenticate")
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func pay(sdk: BlockingBreezServices) -> LnUrlPayResult? {
|
func pay(sdk: BlockingBreezServices) -> LnUrlPayResult? {
|
||||||
// ANCHOR: lnurl-pay
|
// ANCHOR: lnurl-pay
|
||||||
@@ -16,7 +16,7 @@ func pay(sdk: BlockingBreezServices) -> LnUrlPayResult? {
|
|||||||
var response: LnUrlPayResult?
|
var response: LnUrlPayResult?
|
||||||
let lnurlPayUrl = "lightning@address.com"
|
let lnurlPayUrl = "lightning@address.com"
|
||||||
if let inputType = try? parseInput(s: lnurlPayUrl) {
|
if let inputType = try? parseInput(s: lnurlPayUrl) {
|
||||||
if case.lnUrlPay(let `data`) = inputType {
|
if case let .lnUrlPay(data) = inputType {
|
||||||
let amountMSat = data.minSendable
|
let amountMSat = data.minSendable
|
||||||
response = try? sdk.payLnurl(req: LnUrlPayRequest(data: data, amountMsat: amountMSat, comment: "comment"))
|
response = try? sdk.payLnurl(req: LnUrlPayRequest(data: data, amountMsat: amountMSat, comment: "comment"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func withdraw(sdk: BlockingBreezServices) -> LnUrlWithdrawResult? {
|
func withdraw(sdk: BlockingBreezServices) -> LnUrlWithdrawResult? {
|
||||||
// ANCHOR: lnurl-withdraw
|
// ANCHOR: lnurl-withdraw
|
||||||
@@ -15,8 +15,8 @@ func withdraw(sdk: BlockingBreezServices) -> LnUrlWithdrawResult? {
|
|||||||
var response: LnUrlWithdrawResult?
|
var response: LnUrlWithdrawResult?
|
||||||
let lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"
|
let lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"
|
||||||
|
|
||||||
if let inputType = try? parseInput(s: lnurlWithdrawUrl){
|
if let inputType = try? parseInput(s: lnurlWithdrawUrl) {
|
||||||
if case.lnUrlWithdraw(let `data`) = inputType {
|
if case let .lnUrlWithdraw(data) = inputType {
|
||||||
let amountMsat = data.maxWithdrawable
|
let amountMsat = data.maxWithdrawable
|
||||||
let description = "Test withdraw"
|
let description = "Test withdraw"
|
||||||
response = try? sdk.withdrawLnurl(
|
response = try? sdk.withdrawLnurl(
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func productionNodeConfig() -> NodeConfig {
|
|||||||
let greenlightCredentials = GreenlightCredentials(deviceKey: deviceKey, deviceCert: deviceCert)
|
let greenlightCredentials = GreenlightCredentials(deviceKey: deviceKey, deviceCert: deviceCert)
|
||||||
|
|
||||||
let nodeConfig = NodeConfig.greenlight(
|
let nodeConfig = NodeConfig.greenlight(
|
||||||
config: GreenlightNodeConfig(partnerCredentials: greenlightCredentials, inviteCode: nil))
|
config: GreenlightNodeConfig(partnerCredentials: greenlightCredentials, inviteCode: nil))
|
||||||
// ANCHOR_END: moving-to-production
|
// ANCHOR_END: moving-to-production
|
||||||
return nodeConfig
|
return nodeConfig
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func generateReceiveOnchainAddress(sdk: BlockingBreezServices) -> String? {
|
func generateReceiveOnchainAddress(sdk: BlockingBreezServices) -> String? {
|
||||||
// ANCHOR: generate-receive-onchain-address
|
// ANCHOR: generate-receive-onchain-address
|
||||||
@@ -28,13 +28,14 @@ func getSwapInProgress(sdk: BlockingBreezServices) -> SwapInfo? {
|
|||||||
return swapInfo
|
return swapInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func listRefundables(sdk:BlockingBreezServices) -> [SwapInfo]? {
|
func listRefundables(sdk: BlockingBreezServices) -> [SwapInfo]? {
|
||||||
// ANCHOR: list-refundables
|
// ANCHOR: list-refundables
|
||||||
let refundables = try? sdk.listRefundables()
|
let refundables = try? sdk.listRefundables()
|
||||||
// ANCHOR_END: list-refundables
|
// ANCHOR_END: list-refundables
|
||||||
return refundables
|
return refundables
|
||||||
}
|
}
|
||||||
func executeRefund(sdk: BlockingBreezServices, refundables: SwapInfo,satPerVbyte: UInt32) -> RefundResponse? {
|
|
||||||
|
func executeRefund(sdk: BlockingBreezServices, refundables: SwapInfo, satPerVbyte: UInt32) -> RefundResponse? {
|
||||||
// ANCHOR: execute-refund
|
// ANCHOR: execute-refund
|
||||||
let destinationAddress = "..."
|
let destinationAddress = "..."
|
||||||
let response = try? sdk.refund(req: RefundRequest(swapAddress: refundables.bitcoinAddress, toAddress: destinationAddress, satPerVbyte: satPerVbyte))
|
let response = try? sdk.refund(req: RefundRequest(swapAddress: refundables.bitcoinAddress, toAddress: destinationAddress, satPerVbyte: satPerVbyte))
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func GetCurrentFees(sdk: BlockingBreezServices) -> ReverseSwapPairInfo? {
|
func GetCurrentFees(sdk: BlockingBreezServices) -> ReverseSwapPairInfo? {
|
||||||
// ANCHOR: estimate-current-reverse-swap-total-fees
|
// ANCHOR: estimate-current-reverse-swap-total-fees
|
||||||
let sendAmountSat:UInt64 = 50_000
|
let sendAmountSat: UInt64 = 50_000
|
||||||
let currentFees = try? sdk.fetchReverseSwapFees(req: ReverseSwapFeesRequest(sendAmountSat: sendAmountSat))
|
let currentFees = try? sdk.fetchReverseSwapFees(req: ReverseSwapFeesRequest(sendAmountSat: sendAmountSat))
|
||||||
print("Total estimated fees for reverse swap: \(String(describing: currentFees?.totalEstimatedFees))")
|
print("Total estimated fees for reverse swap: \(String(describing: currentFees?.totalEstimatedFees))")
|
||||||
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
||||||
|
|||||||
@@ -15,6 +15,4 @@ func sendPayment(sdk: BlockingBreezServices) -> SendPaymentResponse? {
|
|||||||
let response = try? sdk.sendPayment(req: req)
|
let response = try? sdk.sendPayment(req: req)
|
||||||
// ANCHOR_END: send-payment
|
// ANCHOR_END: send-payment
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,16 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func sendSpontaneousPayment(sdk: BlockingBreezServices) -> SendPaymentResponse? {
|
func sendSpontaneousPayment(sdk: BlockingBreezServices) -> SendPaymentResponse? {
|
||||||
// ANCHOR: send-spontaneous-payment
|
// ANCHOR: send-spontaneous-payment
|
||||||
let response = try? sdk.sendSpontaneousPayment(
|
let response = try? sdk.sendSpontaneousPayment(
|
||||||
req: SendSpontaneousPaymentRequest(
|
req: SendSpontaneousPaymentRequest(
|
||||||
nodeId: "...",
|
nodeId: "...",
|
||||||
amountMsat: 3_000_000))
|
amountMsat: 3_000_000
|
||||||
|
))
|
||||||
// ANCHOR_END: send-spontaneous-payment
|
// ANCHOR_END: send-spontaneous-payment
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// Created by dangeross on 27/11/2023.
|
// Created by dangeross on 27/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func getServiceStatus(sdk: BlockingBreezServices) {
|
func getServiceStatus(sdk: BlockingBreezServices) {
|
||||||
// ANCHOR: health-check-status
|
// ANCHOR: health-check-status
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
// Created by ruben on 14/11/2023.
|
// Created by ruben on 14/11/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import BreezSDK
|
import BreezSDK
|
||||||
|
import Foundation
|
||||||
|
|
||||||
func retrieveBackupFiles() -> StaticBackupResponse? {
|
func retrieveBackupFiles() -> StaticBackupResponse? {
|
||||||
// ANCHOR: static-channel-backup
|
// ANCHOR: static-channel-backup
|
||||||
let backupData = try? staticBackup(req:StaticBackupRequest(workingDir: "<working directory>"))
|
let backupData = try? staticBackup(req: StaticBackupRequest(workingDir: "<working directory>"))
|
||||||
// ANCHOR_END: static-channel-backup
|
// ANCHOR_END: static-channel-backup
|
||||||
return backupData
|
return backupData
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
// https://docs.swift.org/swift-book
|
// https://docs.swift.org/swift-book
|
||||||
|
|
||||||
print("Hello, tester!")
|
print("Hello, tester!")
|
||||||
if let sdk = try gettingStarted(){
|
if let sdk = try gettingStarted() {
|
||||||
if let fiatRates = getCurrentRates(sdk: sdk) {
|
if let fiatRates = getCurrentRates(sdk: sdk) {
|
||||||
for rate in fiatRates {
|
for rate in fiatRates {
|
||||||
print("rate \(rate)\n")
|
print("rate \(rate)\n")
|
||||||
print("------------------------")
|
print("------------------------")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
- [iOS](guide/ios_notification_service_extension.md)
|
- [iOS](guide/ios_notification_service_extension.md)
|
||||||
- [Android](guide/android_notification_foreground_service.md)
|
- [Android](guide/android_notification_foreground_service.md)
|
||||||
- [Connecting to an LSP](guide/connecting_lsp.md)
|
- [Connecting to an LSP](guide/connecting_lsp.md)
|
||||||
- [Receiving an on-chain transaction](guide/receive_onchain.md)
|
- [Receiving an On-Chain Transaction](guide/receive_onchain.md)
|
||||||
- [Sending an on-chain transaction](guide/send_onchain.md)
|
- [Sending an On-Chain Transaction](guide/send_onchain.md)
|
||||||
|
- [Closed channels](guide/closed_channels.md)
|
||||||
|
|
||||||
- [Using LNURL & Lightning addresses](guide/lnurl.md)
|
- [Using LNURL & Lightning addresses](guide/lnurl.md)
|
||||||
- [Sending payments using LNURL-Pay/Lightning address](guide/lnurl_pay.md)
|
- [Sending payments using LNURL-Pay/Lightning address](guide/lnurl_pay.md)
|
||||||
|
|||||||
143
src/guide/closed_channels.md
Normal file
143
src/guide/closed_channels.md
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
# Closed channels
|
||||||
|
|
||||||
|
On channel close the remaining funds will be sent to an onchain address. In order to redeem those funds you may do the following.
|
||||||
|
|
||||||
|
## Prepare Redeem Onchain Funds
|
||||||
|
|
||||||
|
First you may want to call prepare the transaction in order to get the transaction weight as well as the calculated fees before eventually broadcasting it.
|
||||||
|
|
||||||
|
<custom-tabs category="lang">
|
||||||
|
<div slot="title">Rust</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```rust,ignore
|
||||||
|
{{#include ../../snippets/rust/src/closed_channel.rs:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Swift</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```swift,ignore
|
||||||
|
{{#include ../../snippets/swift/BreezSDKExamples/Sources/ClosedChannel.swift:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Kotlin</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```kotlin,ignore
|
||||||
|
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ClosedChannel.kt:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">React Native</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
{{#include ../../snippets/react-native/closed_channel.ts:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Dart</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```dart,ignore
|
||||||
|
{{#include ../../snippets/dart_snippets/lib/closed_channel.dart:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Python</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```python,ignore
|
||||||
|
{{#include ../../snippets/python/src/closed_channel.py:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Go</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```go,ignore
|
||||||
|
{{#include ../../snippets/go/closed_channel.go:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">C#</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```cs,ignore
|
||||||
|
{{#include ../../snippets/csharp/ClosedChannel.cs:prepare-redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
</custom-tabs>
|
||||||
|
|
||||||
|
## Redeem Onchain Funds
|
||||||
|
|
||||||
|
In order to broadcast the redeem transaction do the following.
|
||||||
|
|
||||||
|
<custom-tabs category="lang">
|
||||||
|
<div slot="title">Rust</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```rust,ignore
|
||||||
|
{{#include ../../snippets/rust/src/closed_channel.rs:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Swift</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```swift,ignore
|
||||||
|
{{#include ../../snippets/swift/BreezSDKExamples/Sources/ClosedChannel.swift:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Kotlin</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```kotlin,ignore
|
||||||
|
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ClosedChannel.kt:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">React Native</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
{{#include ../../snippets/react-native/closed_channel.ts:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Dart</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```dart,ignore
|
||||||
|
{{#include ../../snippets/dart_snippets/lib/closed_channel.dart:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Python</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```python,ignore
|
||||||
|
{{#include ../../snippets/python/src/closed_channel.py:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Go</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```go,ignore
|
||||||
|
{{#include ../../snippets/go/closed_channel.go:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">C#</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```cs,ignore
|
||||||
|
{{#include ../../snippets/csharp/ClosedChannel.cs:redeem-onchain-funds}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
</custom-tabs>
|
||||||
@@ -373,5 +373,4 @@ To calculate the fees for a channel being opened by the LSP:
|
|||||||
</section>
|
</section>
|
||||||
</custom-tabs>
|
</custom-tabs>
|
||||||
|
|
||||||
|
|
||||||
[^1]: For more details on these fees, see [Channel Opening Fees](connecting_lsp.md#channel-opening-fees)
|
[^1]: For more details on these fees, see [Channel Opening Fees](connecting_lsp.md#channel-opening-fees)
|
||||||
|
|||||||
Reference in New Issue
Block a user