mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 05:44: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
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.13.9'
|
||||
channel: 'stable'
|
||||
cache: true
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
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):
|
||||
try:
|
||||
# ANCHOR: send-spontaneous-payment
|
||||
node_id = "..."
|
||||
amount_msat = 300000
|
||||
try:
|
||||
req = breez_sdk.SendSpontaneousPaymentRequest(node_id, amount_msat)
|
||||
amount_msat = 3000000
|
||||
|
||||
req = breez_sdk.SendSpontaneousPaymentRequest(node_id,amount_msat)
|
||||
result = sdk_services.send_spontaneous_payment(req)
|
||||
# ANCHOR: send-spontaneous-payment
|
||||
# ANCHOR_END: send-spontaneous-payment
|
||||
return result
|
||||
except Exception as 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 closed_channel;
|
||||
mod connecting_lsp;
|
||||
mod fiat_currencies;
|
||||
mod getting_started;
|
||||
|
||||
@@ -5,7 +5,7 @@ import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "BreezSDKDocs",
|
||||
platforms: [.macOS(.v12)],
|
||||
platforms: [.macOS(.v13)],
|
||||
dependencies: [
|
||||
.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")
|
||||
@@ -16,8 +16,9 @@ let package = Package(
|
||||
.executableTarget(
|
||||
name: "BreezSDKDocs",
|
||||
dependencies: [
|
||||
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
||||
.product(name: "BreezSDK", package: "breez-sdk-swift"),
|
||||
// use a local version of breez-sdk
|
||||
// .product(name: "BreezSDK", package: "bindings-swift"),
|
||||
],
|
||||
path: "Sources"),
|
||||
]
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func buy(sdk: BlockingBreezServices) -> BuyBitcoinResponse? {
|
||||
// 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.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func getLspInfo(sdk: BlockingBreezServices) -> LspInformation?{
|
||||
func getLspInfo(sdk: BlockingBreezServices) -> LspInformation? {
|
||||
// ANCHOR: get-lsp-info
|
||||
let lspId = try? sdk.lspId()
|
||||
let lspInfo = try? sdk.lspInfo()
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func listSupportedFiatCurrencies(sdk: BlockingBreezServices) -> [FiatCurrency]? {
|
||||
// ANCHOR: list-fiat-currencies
|
||||
@@ -15,7 +15,7 @@ func listSupportedFiatCurrencies(sdk: BlockingBreezServices) -> [FiatCurrency]?
|
||||
return supportedFiatCurrencies
|
||||
}
|
||||
|
||||
func getCurrentRates(sdk:BlockingBreezServices) -> [Rate]? {
|
||||
func getCurrentRates(sdk: BlockingBreezServices) -> [Rate]? {
|
||||
// ANCHOR: fetch-fiat-rates
|
||||
let fiatRates = try? sdk.fetchFiatRates()
|
||||
// ANCHOR_END: fetch-fiat-rates
|
||||
|
||||
@@ -28,7 +28,6 @@ func gettingStarted() throws -> BlockingBreezServices? {
|
||||
// Customize the config object according to your needs
|
||||
config.workingDir = "path to an existing directory"
|
||||
|
||||
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
guard seed != nil else {
|
||||
return nil
|
||||
@@ -37,6 +36,7 @@ func gettingStarted() throws -> BlockingBreezServices? {
|
||||
|
||||
return sdk
|
||||
}
|
||||
|
||||
// ANCHOR_END: init-sdk
|
||||
func gettingStartedNodeInfo(sdk: BlockingBreezServices) {
|
||||
// ANCHOR: fetch-balance
|
||||
@@ -48,5 +48,3 @@ func gettingStartedNodeInfo(sdk: BlockingBreezServices) {
|
||||
}
|
||||
// ANCHOR_END: fetch-balance
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by ruben on 13/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func ListPayments(sdk: BlockingBreezServices) -> [Payment]? {
|
||||
// ANCHOR: list-payments
|
||||
@@ -20,8 +20,9 @@ func ListPaymentsFiltered(sdk: BlockingBreezServices) -> [Payment]? {
|
||||
let payments = try? sdk.listPayments(
|
||||
req: ListPaymentsRequest(
|
||||
filters: [.sent],
|
||||
fromTimestamp: 1696880000,
|
||||
includeFailures: true))
|
||||
fromTimestamp: 1_696_880_000,
|
||||
includeFailures: true
|
||||
))
|
||||
// ANCHOR_END: list-payments-filtered
|
||||
return payments
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func auth(sdk: BlockingBreezServices) {
|
||||
// ANCHOR: lnurl-withdraw
|
||||
@@ -14,14 +14,13 @@ func auth(sdk: BlockingBreezServices) {
|
||||
// keyauth://domain.com/auth?key=val
|
||||
let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"
|
||||
|
||||
|
||||
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)
|
||||
switch result {
|
||||
case .ok:
|
||||
print("Successfully authenticated")
|
||||
case .errorStatus(let error):
|
||||
case let .errorStatus(error):
|
||||
print("Failed to authenticate: \(error)")
|
||||
case .none:
|
||||
print("Failed to authenticate")
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func pay(sdk: BlockingBreezServices) -> LnUrlPayResult? {
|
||||
// ANCHOR: lnurl-pay
|
||||
@@ -16,7 +16,7 @@ func pay(sdk: BlockingBreezServices) -> LnUrlPayResult? {
|
||||
var response: LnUrlPayResult?
|
||||
let lnurlPayUrl = "lightning@address.com"
|
||||
if let inputType = try? parseInput(s: lnurlPayUrl) {
|
||||
if case.lnUrlPay(let `data`) = inputType {
|
||||
if case let .lnUrlPay(data) = inputType {
|
||||
let amountMSat = data.minSendable
|
||||
response = try? sdk.payLnurl(req: LnUrlPayRequest(data: data, amountMsat: amountMSat, comment: "comment"))
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func withdraw(sdk: BlockingBreezServices) -> LnUrlWithdrawResult? {
|
||||
// ANCHOR: lnurl-withdraw
|
||||
@@ -15,8 +15,8 @@ func withdraw(sdk: BlockingBreezServices) -> LnUrlWithdrawResult? {
|
||||
var response: LnUrlWithdrawResult?
|
||||
let lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"
|
||||
|
||||
if let inputType = try? parseInput(s: lnurlWithdrawUrl){
|
||||
if case.lnUrlWithdraw(let `data`) = inputType {
|
||||
if let inputType = try? parseInput(s: lnurlWithdrawUrl) {
|
||||
if case let .lnUrlWithdraw(data) = inputType {
|
||||
let amountMsat = data.maxWithdrawable
|
||||
let description = "Test withdraw"
|
||||
response = try? sdk.withdrawLnurl(
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func generateReceiveOnchainAddress(sdk: BlockingBreezServices) -> String? {
|
||||
// ANCHOR: generate-receive-onchain-address
|
||||
@@ -28,13 +28,14 @@ func getSwapInProgress(sdk: BlockingBreezServices) -> SwapInfo? {
|
||||
return swapInfo
|
||||
}
|
||||
|
||||
func listRefundables(sdk:BlockingBreezServices) -> [SwapInfo]? {
|
||||
func listRefundables(sdk: BlockingBreezServices) -> [SwapInfo]? {
|
||||
// ANCHOR: list-refundables
|
||||
let refundables = try? sdk.listRefundables()
|
||||
// ANCHOR_END: list-refundables
|
||||
return refundables
|
||||
}
|
||||
func executeRefund(sdk: BlockingBreezServices, refundables: SwapInfo,satPerVbyte: UInt32) -> RefundResponse? {
|
||||
|
||||
func executeRefund(sdk: BlockingBreezServices, refundables: SwapInfo, satPerVbyte: UInt32) -> RefundResponse? {
|
||||
// ANCHOR: execute-refund
|
||||
let destinationAddress = "..."
|
||||
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.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func GetCurrentFees(sdk: BlockingBreezServices) -> ReverseSwapPairInfo? {
|
||||
// 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))
|
||||
print("Total estimated fees for reverse swap: \(String(describing: currentFees?.totalEstimatedFees))")
|
||||
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
||||
|
||||
@@ -15,6 +15,4 @@ func sendPayment(sdk: BlockingBreezServices) -> SendPaymentResponse? {
|
||||
let response = try? sdk.sendPayment(req: req)
|
||||
// ANCHOR_END: send-payment
|
||||
return response
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
|
||||
import Foundation
|
||||
|
||||
func sendSpontaneousPayment(sdk: BlockingBreezServices) -> SendPaymentResponse? {
|
||||
// ANCHOR: send-spontaneous-payment
|
||||
let response = try? sdk.sendSpontaneousPayment(
|
||||
req: SendSpontaneousPaymentRequest(
|
||||
nodeId: "...",
|
||||
amountMsat: 3_000_000))
|
||||
amountMsat: 3_000_000
|
||||
))
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Created by dangeross on 27/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func getServiceStatus(sdk: BlockingBreezServices) {
|
||||
// ANCHOR: health-check-status
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
// Created by ruben on 14/11/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import BreezSDK
|
||||
import Foundation
|
||||
|
||||
func retrieveBackupFiles() -> StaticBackupResponse? {
|
||||
// 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
|
||||
return backupData
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// https://docs.swift.org/swift-book
|
||||
|
||||
print("Hello, tester!")
|
||||
if let sdk = try gettingStarted(){
|
||||
if let sdk = try gettingStarted() {
|
||||
if let fiatRates = getCurrentRates(sdk: sdk) {
|
||||
for rate in fiatRates {
|
||||
print("rate \(rate)\n")
|
||||
@@ -10,4 +10,3 @@ if let sdk = try gettingStarted(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
- [iOS](guide/ios_notification_service_extension.md)
|
||||
- [Android](guide/android_notification_foreground_service.md)
|
||||
- [Connecting to an LSP](guide/connecting_lsp.md)
|
||||
- [Receiving an on-chain transaction](guide/receive_onchain.md)
|
||||
- [Sending an on-chain transaction](guide/send_onchain.md)
|
||||
- [Receiving an On-Chain Transaction](guide/receive_onchain.md)
|
||||
- [Sending an On-Chain Transaction](guide/send_onchain.md)
|
||||
- [Closed channels](guide/closed_channels.md)
|
||||
|
||||
- [Using LNURL & Lightning addresses](guide/lnurl.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>
|
||||
</custom-tabs>
|
||||
|
||||
|
||||
[^1]: For more details on these fees, see [Channel Opening Fees](connecting_lsp.md#channel-opening-fees)
|
||||
|
||||
Reference in New Issue
Block a user