mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 06:14:21 +01:00
Merge pull request #72 from breez/ok300-snippets-rust
Extract code snippets and reference them from doc files
This commit is contained in:
107
.github/workflows/main.yml
vendored
Normal file
107
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
name: CI
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
# Triggers the workflow on push events but only for the "main" branch
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Set up Rust environment and run checks
|
||||
- name: Install rust
|
||||
run: |
|
||||
rustup set auto-self-update disable
|
||||
rustup toolchain install stable --profile minimal
|
||||
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v2
|
||||
with:
|
||||
version: "23.4"
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: clippy
|
||||
run: |
|
||||
cd snippets/rust
|
||||
# Explicitly allow clippy::dead_code lint because the functions aren't called in the docs snippets
|
||||
# Explicitly allow clippy::unused_variables because snippets might have to demonstrate how to get certain variables without using them afterward
|
||||
cargo clippy -- --allow dead_code --allow unused_variables --deny warnings
|
||||
|
||||
# Set up the flutter environment and run checks
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.13.9'
|
||||
channel: 'stable'
|
||||
|
||||
- name: pub-get
|
||||
run: |
|
||||
cd snippets/dart_snippets
|
||||
flutter pub get
|
||||
|
||||
- name: dart-analyze
|
||||
run: |
|
||||
cd snippets/dart_snippets
|
||||
dart analyze --fatal-infos
|
||||
|
||||
check-csharp:
|
||||
name: Check C# snippets
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
|
||||
- name: Build the csharp project
|
||||
working-directory: snippets/csharp
|
||||
run: dotnet build
|
||||
|
||||
build:
|
||||
name: Build mdbook
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install rust
|
||||
run: |
|
||||
rustup set auto-self-update disable
|
||||
rustup toolchain install stable --profile minimal
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: |
|
||||
. -> target
|
||||
snippets-processor -> snippets-processor/target
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cargo install mdbook --vers "^0.4" --locked
|
||||
cargo install --path ./snippets-processor
|
||||
|
||||
- name: Build mdbook
|
||||
run: mdbook build
|
||||
|
||||
- name: Archive book
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: book
|
||||
path: book
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,7 @@
|
||||
book
|
||||
.DS_Store
|
||||
.idea
|
||||
|
||||
# Sub-projects with code snippets
|
||||
snippets/react-native/node_modules
|
||||
snippets/rust/target
|
||||
@@ -13,6 +13,7 @@ To locally serve the docs run:
|
||||
|
||||
```bash
|
||||
cargo install mdbook
|
||||
cargo install --path ./snippets-processor
|
||||
mdbook build
|
||||
mdbook serve --open
|
||||
```
|
||||
|
||||
@@ -13,3 +13,6 @@ edit-url-template = "https://github.com/breez/breez-sdk-docs/edit/main/{path}"
|
||||
|
||||
[output.html.print]
|
||||
enable = false
|
||||
|
||||
[preprocessor.snippets]
|
||||
after = ["links"]
|
||||
1
snippets-processor/.gitignore
vendored
Normal file
1
snippets-processor/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
target
|
||||
1993
snippets-processor/Cargo.lock
generated
Normal file
1993
snippets-processor/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
snippets-processor/Cargo.toml
Normal file
11
snippets-processor/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "mdbook-snippets"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = "4.4.7"
|
||||
mdbook = "0.4.35"
|
||||
serde_json = "1.0.108"
|
||||
123
snippets-processor/src/main.rs
Normal file
123
snippets-processor/src/main.rs
Normal file
@@ -0,0 +1,123 @@
|
||||
use clap::{crate_version, Arg, ArgMatches, Command};
|
||||
use mdbook::book::Book;
|
||||
use mdbook::errors::{Error, Result};
|
||||
use mdbook::preprocess::{CmdPreprocessor, Preprocessor, PreprocessorContext};
|
||||
use mdbook::BookItem;
|
||||
use std::io;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// set up app
|
||||
let matches = make_app().get_matches();
|
||||
let pre = SnippetsProcessor;
|
||||
|
||||
// determine what behaviour has been requested
|
||||
if let Some(sub_args) = matches.subcommand_matches("supports") {
|
||||
// handle cmdline supports
|
||||
handle_supports(&pre, sub_args)
|
||||
} else {
|
||||
// handle preprocessing
|
||||
handle_preprocessing(&pre)
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse CLI options.
|
||||
pub fn make_app() -> Command {
|
||||
Command::new("mdbook-snippets")
|
||||
.version(crate_version!())
|
||||
.about("A preprocessor that removes leading whitespace from code snippets.")
|
||||
.subcommand(
|
||||
Command::new("supports")
|
||||
.arg(Arg::new("renderer").required(true))
|
||||
.about("Check whether a renderer is supported by this preprocessor"),
|
||||
)
|
||||
}
|
||||
|
||||
/// Tell mdBook if we support what it asks for.
|
||||
fn handle_supports(pre: &dyn Preprocessor, sub_args: &ArgMatches) -> Result<()> {
|
||||
let renderer = sub_args
|
||||
.get_one::<String>("renderer")
|
||||
.expect("Required argument");
|
||||
let supported = pre.supports_renderer(renderer);
|
||||
if supported {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::msg(format!(
|
||||
"The snippets preprocessor does not support the '{renderer}' renderer",
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Preprocess `book` using `pre` and print it out.
|
||||
fn handle_preprocessing(pre: &dyn Preprocessor) -> Result<()> {
|
||||
let (ctx, book) = CmdPreprocessor::parse_input(io::stdin())?;
|
||||
check_mdbook_version(&ctx.mdbook_version);
|
||||
|
||||
let processed_book = pre.run(&ctx, book)?;
|
||||
serde_json::to_writer(io::stdout(), &processed_book)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Produce a warning on mdBook version mismatch.
|
||||
fn check_mdbook_version(version: &str) {
|
||||
if version != mdbook::MDBOOK_VERSION {
|
||||
eprintln!(
|
||||
"This mdbook-snippets was built against mdbook v{}, \
|
||||
but we are being called from mdbook v{version}. \
|
||||
If you have any issue, this might be a reason.",
|
||||
mdbook::MDBOOK_VERSION,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct SnippetsProcessor;
|
||||
impl Preprocessor for SnippetsProcessor {
|
||||
fn name(&self) -> &str {
|
||||
"snippets"
|
||||
}
|
||||
|
||||
fn run(&self, _ctx: &PreprocessorContext, mut book: Book) -> Result<Book> {
|
||||
book.for_each_mut(|item| {
|
||||
if let BookItem::Chapter(chapter) = item {
|
||||
let mut resulting_lines: Vec<&str> = vec![];
|
||||
let mut in_block = false;
|
||||
let mut block_lines: Vec<&str> = vec![];
|
||||
let mut min_indentation: usize = 0;
|
||||
for line in chapter.content.lines() {
|
||||
if line.starts_with("```") {
|
||||
if in_block {
|
||||
// This is end of block
|
||||
// Replace previous lines
|
||||
for block_line in block_lines.iter() {
|
||||
let indent = std::cmp::min(min_indentation, block_line.len());
|
||||
resulting_lines.push(&block_line[indent..])
|
||||
}
|
||||
in_block = false;
|
||||
} else {
|
||||
// Start of block
|
||||
in_block = true;
|
||||
block_lines = vec![];
|
||||
min_indentation = usize::MAX;
|
||||
}
|
||||
|
||||
resulting_lines.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
if in_block {
|
||||
block_lines.push(line);
|
||||
let trimmed = line.trim_start_matches(' ');
|
||||
if !trimmed.is_empty() {
|
||||
min_indentation =
|
||||
std::cmp::min(min_indentation, line.len() - trimmed.len())
|
||||
}
|
||||
} else {
|
||||
resulting_lines.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
chapter.content = resulting_lines.join("\n");
|
||||
}
|
||||
});
|
||||
Ok(book)
|
||||
}
|
||||
}
|
||||
477
snippets/csharp/.gitignore
vendored
Normal file
477
snippets/csharp/.gitignore
vendored
Normal file
@@ -0,0 +1,477 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# Tye
|
||||
.tye/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
##
|
||||
## Visual studio for Mac
|
||||
##
|
||||
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
|
||||
# Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
19
snippets/csharp/BuyBtc.cs
Normal file
19
snippets/csharp/BuyBtc.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class BuyBtcSnippets
|
||||
{
|
||||
public void BuyBtc(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: buy-btc
|
||||
try
|
||||
{
|
||||
var buyBitcoinResponse = sdk.BuyBitcoin(
|
||||
new BuyBitcoinRequest(BuyBitcoinProvider.MOONPAY));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: buy-btc
|
||||
}
|
||||
}
|
||||
33
snippets/csharp/ConnectingLsp.cs
Normal file
33
snippets/csharp/ConnectingLsp.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class ConnectingLspSnippets
|
||||
{
|
||||
public void GetLspInfo(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: get-lsp-info
|
||||
try
|
||||
{
|
||||
var lspId = sdk.LspId();
|
||||
var lspInfo = sdk.LspInfo();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: get-lsp-info
|
||||
}
|
||||
|
||||
public void ConnectLsp(BlockingBreezServices sdk, string? lspId)
|
||||
{
|
||||
// ANCHOR: connect-lsp
|
||||
try
|
||||
{
|
||||
sdk.ConnectLsp(lspId!);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: connect-lsp
|
||||
}
|
||||
}
|
||||
39
snippets/csharp/FiatCurrencies.cs
Normal file
39
snippets/csharp/FiatCurrencies.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class FiatCurrenciesSnippets
|
||||
{
|
||||
public void ListFiatCurrencies(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: list-fiat-currencies
|
||||
try
|
||||
{
|
||||
var fiatCurrencies = sdk.ListFiatCurrencies();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: list-fiat-currencies
|
||||
}
|
||||
|
||||
public void FetchFiatRates(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: fetch-fiat-rates
|
||||
try
|
||||
{
|
||||
var fiatRates = sdk.FetchFiatRates();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: fetch-fiat-rates
|
||||
}
|
||||
|
||||
public void GetFiatCurrenciesAndRates(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: get-fiat-currencies-and-rates
|
||||
// TODO
|
||||
// ANCHOR_END: get-fiat-currencies-and-rates
|
||||
}
|
||||
}
|
||||
62
snippets/csharp/GettingStarted.cs
Normal file
62
snippets/csharp/GettingStarted.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class GettingStartedSnippets
|
||||
{
|
||||
// ANCHOR: init-sdk
|
||||
public void GettingStarted()
|
||||
{
|
||||
// Create the default config
|
||||
var seed = BreezSdkMethods.MnemonicToSeed("<mnemonic words>");
|
||||
var inviteCode = "<invite code>";
|
||||
var apiKey = "<api key>";
|
||||
var nodeConfig = new NodeConfig.Greenlight(
|
||||
new GreenlightNodeConfig(null, inviteCode)
|
||||
);
|
||||
var config = BreezSdkMethods.DefaultConfig(
|
||||
EnvironmentType.PRODUCTION,
|
||||
apiKey,
|
||||
nodeConfig
|
||||
) with
|
||||
{
|
||||
// Customize the config object according to your needs
|
||||
workingDir = "path to an existing directory"
|
||||
};
|
||||
|
||||
BlockingBreezServices sdk;
|
||||
try
|
||||
{
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
sdk = BreezSdkMethods.Connect(config, seed, new SdkListener());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
}
|
||||
|
||||
// SDK event listener
|
||||
class SdkListener : EventListener
|
||||
{
|
||||
public void OnEvent(BreezEvent e)
|
||||
{
|
||||
Console.WriteLine($"Received Breez event type {e.GetType().Name}");
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: init-sdk
|
||||
|
||||
public void FetchNodeInfo(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: fetch-balance
|
||||
try
|
||||
{
|
||||
var nodeInfo = sdk.NodeInfo();
|
||||
var lnBalance = nodeInfo?.channelsBalanceMsat;
|
||||
var onchainBalance = nodeInfo?.onchainBalanceMsat;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: fetch-balance
|
||||
}
|
||||
}
|
||||
37
snippets/csharp/ListPayments.cs
Normal file
37
snippets/csharp/ListPayments.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class ListPaymentsSnippets
|
||||
{
|
||||
public void ListPayments(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: list-payments
|
||||
try
|
||||
{
|
||||
var payments = sdk.ListPayments(
|
||||
new ListPaymentsRequest(PaymentTypeFilter.ALL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: list-payments
|
||||
}
|
||||
|
||||
public void ListPaymentsFiltered(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: list-payments-filtered
|
||||
try
|
||||
{
|
||||
var payments = sdk.ListPayments(
|
||||
new ListPaymentsRequest(
|
||||
PaymentTypeFilter.SENT,
|
||||
fromTimestamp: 1696880000,
|
||||
includeFailures: true));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: list-payments-filtered
|
||||
}
|
||||
}
|
||||
34
snippets/csharp/LnurlAuth.cs
Normal file
34
snippets/csharp/LnurlAuth.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class LnurlAuthSnippets
|
||||
{
|
||||
public void LnurlAuth(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: lnurl-auth
|
||||
// Endpoint can also be of the form:
|
||||
// keyauth://domain.com/auth?key=val
|
||||
var lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu";
|
||||
|
||||
try
|
||||
{
|
||||
var input = BreezSdkMethods.ParseInput(lnurlAuthUrl);
|
||||
if (input is InputType.LnUrlAuth lnurla)
|
||||
{
|
||||
var result = sdk.LnurlAuth(lnurla.data);
|
||||
if (result is LnUrlCallbackStatus.Ok)
|
||||
{
|
||||
Console.WriteLine("Successfully authenticated");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Failed to authenticate");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: lnurl-auth
|
||||
}
|
||||
}
|
||||
29
snippets/csharp/LnurlPay.cs
Normal file
29
snippets/csharp/LnurlPay.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class LnurlPaySnippets
|
||||
{
|
||||
public void LnurlPay(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: lnurl-pay
|
||||
// Endpoint can also be of the form:
|
||||
// lnurlp://domain.com/lnurl-pay?key=val
|
||||
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
|
||||
var lnurlPayUrl = "lightning@address.com";
|
||||
|
||||
try
|
||||
{
|
||||
var input = BreezSdkMethods.ParseInput(lnurlPayUrl);
|
||||
if (input is InputType.LnUrlPay lnurlp)
|
||||
{
|
||||
var amountMsat = lnurlp.data.minSendable;
|
||||
var result = sdk.PayLnurl(
|
||||
new LnUrlPayRequest(lnurlp.data, amountMsat, "comment"));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: lnurl-pay
|
||||
}
|
||||
}
|
||||
31
snippets/csharp/LnurlWithdraw.cs
Normal file
31
snippets/csharp/LnurlWithdraw.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class LnurlWithdrawSnippets
|
||||
{
|
||||
public void LnurlWithdraw(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: lnurl-withdraw
|
||||
// Endpoint can also be of the form:
|
||||
// lnurlw://domain.com/lnurl-withdraw?key=val
|
||||
var lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
|
||||
|
||||
try
|
||||
{
|
||||
var input = BreezSdkMethods.ParseInput(lnurlWithdrawUrl);
|
||||
if (input is InputType.LnUrlWithdraw lnurlw)
|
||||
{
|
||||
var amountMsat = lnurlw.data.minWithdrawable;
|
||||
var result = sdk.WithdrawLnurl(
|
||||
new LnUrlWithdrawRequest(
|
||||
lnurlw.data,
|
||||
amountMsat,
|
||||
"comment"));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: lnurl-withdraw
|
||||
}
|
||||
}
|
||||
84
snippets/csharp/ReceiveOnchain.cs
Normal file
84
snippets/csharp/ReceiveOnchain.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class ReceiveOnchainSnippets
|
||||
{
|
||||
public void ReceiveOnchain(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: generate-receive-onchain-address
|
||||
try
|
||||
{
|
||||
var swapInfo = sdk.ReceiveOnchain(new ReceiveOnchainRequest());
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
var address = swapInfo.bitcoinAddress;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: generate-receive-onchain-address
|
||||
}
|
||||
|
||||
public void GetInProgressSwap(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: in-progress-swap
|
||||
try
|
||||
{
|
||||
var swapInfo = sdk.InProgressSwap();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: in-progress-swap
|
||||
}
|
||||
|
||||
public void ListRefundables(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: list-refundables
|
||||
try
|
||||
{
|
||||
var refundables = sdk.ListRefundables();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: list-refundables
|
||||
}
|
||||
|
||||
public void ExecuteRefund(BlockingBreezServices sdk, uint refundTxFeeRate, SwapInfo refundable)
|
||||
{
|
||||
// ANCHOR: execute-refund
|
||||
var destinationAddress = "...";
|
||||
var satPerVbyte = refundTxFeeRate;
|
||||
try
|
||||
{
|
||||
var result = sdk.Refund(
|
||||
new RefundRequest(
|
||||
refundable.bitcoinAddress,
|
||||
destinationAddress,
|
||||
satPerVbyte));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: execute-refund
|
||||
}
|
||||
|
||||
public void GetChannelOpeningFees(BlockingBreezServices sdk, ulong amountMsat)
|
||||
{
|
||||
// ANCHOR: get-channel-opening-fees
|
||||
try
|
||||
{
|
||||
var channelFees = sdk.OpenChannelFee(
|
||||
new OpenChannelFeeRequest(amountMsat));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: get-channel-opening-fees
|
||||
}
|
||||
}
|
||||
19
snippets/csharp/ReceivePayment.cs
Normal file
19
snippets/csharp/ReceivePayment.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class ReceivePaymentSnippets
|
||||
{
|
||||
public void ReceivePayment(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: receive-payment
|
||||
try
|
||||
{
|
||||
var invoice = sdk.ReceivePayment(
|
||||
new ReceivePaymentRequest(3_000_000, "Invoice for 3000 sats"));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: receive-payment
|
||||
}
|
||||
}
|
||||
72
snippets/csharp/SendOnchain.cs
Normal file
72
snippets/csharp/SendOnchain.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class SendOnchainSnippets
|
||||
{
|
||||
public void GetCurrentFees(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: estimate-current-reverse-swap-total-fees
|
||||
try
|
||||
{
|
||||
var currentFees = sdk.FetchReverseSwapFees(
|
||||
new ReverseSwapFeesRequest(50000));
|
||||
Console.WriteLine(
|
||||
$"Total estimated fees for reverse " +
|
||||
$"swap: {currentFees.totalEstimatedFees}");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
||||
}
|
||||
|
||||
public void ListCurrentFees(BlockingBreezServices sdk, ReverseSwapPairInfo currentFees)
|
||||
{
|
||||
// ANCHOR: get-current-reverse-swap-min-max
|
||||
Console.WriteLine($"Minimum amount, in sats: {currentFees.min}");
|
||||
Console.WriteLine($"Maximum amount, in sats: {currentFees.max}");
|
||||
// ANCHOR_END: get-current-reverse-swap-min-max
|
||||
}
|
||||
|
||||
public void StartReverseSwap(BlockingBreezServices sdk, ReverseSwapPairInfo currentFees, uint feeRate)
|
||||
{
|
||||
// ANCHOR: start-reverse-swap
|
||||
var destinationAddress = "bc1..";
|
||||
var amountSat = currentFees.min;
|
||||
var satPerVbyte = feeRate;
|
||||
try
|
||||
{
|
||||
var reverseSwapInfo = sdk.SendOnchain(
|
||||
new SendOnchainRequest(
|
||||
amountSat,
|
||||
destinationAddress,
|
||||
currentFees.feesHash,
|
||||
satPerVbyte));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: start-reverse-swap
|
||||
}
|
||||
|
||||
public void CheckReverseSwapStatus(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: check-reverse-swaps-status
|
||||
try
|
||||
{
|
||||
var swaps = sdk.InProgressReverseSwaps();
|
||||
foreach (var swap in swaps)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"Reverse swap {swap.id} in progress, " +
|
||||
$"status is {swap.status}`");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: check-reverse-swaps-status
|
||||
}
|
||||
}
|
||||
26
snippets/csharp/SendPayment.cs
Normal file
26
snippets/csharp/SendPayment.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class SendPaymentSnippets
|
||||
{
|
||||
public void SendPayment(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: send-payment
|
||||
var bolt11 = "...";
|
||||
ulong amountMsat = 3_000_000;
|
||||
|
||||
try
|
||||
{
|
||||
// The `amountMsat` param is optional and should only passed if the
|
||||
// bolt11 doesn't specify an amount.
|
||||
// The amountMsat is required in case an amount is not specified in
|
||||
// the bolt11 invoice.
|
||||
var response = sdk.SendPayment(
|
||||
new SendPaymentRequest(bolt11, amountMsat));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: send-payment
|
||||
}
|
||||
}
|
||||
21
snippets/csharp/SendSpontaneousPayment.cs
Normal file
21
snippets/csharp/SendSpontaneousPayment.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class SendSpontaneousPaymentSnippets
|
||||
{
|
||||
public void SendSpontaneousPayment(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: send-spontaneous-payment
|
||||
var nodeId = "...";
|
||||
ulong amountMsat = 3_000_000;
|
||||
try
|
||||
{
|
||||
var response = sdk.SendSpontaneousPayment(
|
||||
new SendSpontaneousPaymentRequest(nodeId, amountMsat));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
}
|
||||
}
|
||||
13
snippets/csharp/Snippets.csproj
Normal file
13
snippets/csharp/Snippets.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Breez.Sdk" Version="0.2.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
19
snippets/csharp/StaticChannelBackup.cs
Normal file
19
snippets/csharp/StaticChannelBackup.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Breez.Sdk;
|
||||
|
||||
public class StaticChannelBackupSnippets
|
||||
{
|
||||
public void StaticChannelBackup(BlockingBreezServices sdk)
|
||||
{
|
||||
// ANCHOR: static-channel-backup
|
||||
try
|
||||
{
|
||||
var backupData = BreezSdkMethods.StaticBackup(
|
||||
new StaticBackupRequest("<working directory>"));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
// ANCHOR_END: static-channel-backup
|
||||
}
|
||||
}
|
||||
3
snippets/dart_snippets/.gitignore
vendored
Normal file
3
snippets/dart_snippets/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# https://dart.dev/guides/libraries/private-files
|
||||
# Created by `dart pub`
|
||||
.dart_tool/
|
||||
3
snippets/dart_snippets/CHANGELOG.md
Normal file
3
snippets/dart_snippets/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 1.0.0
|
||||
|
||||
- Initial version.
|
||||
2
snippets/dart_snippets/README.md
Normal file
2
snippets/dart_snippets/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
A sample command-line application with an entrypoint in `bin/`, library code
|
||||
in `lib/`, and example unit test in `test/`.
|
||||
30
snippets/dart_snippets/analysis_options.yaml
Normal file
30
snippets/dart_snippets/analysis_options.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
# This file configures the static analysis results for your project (errors,
|
||||
# warnings, and lints).
|
||||
#
|
||||
# This enables the 'recommended' set of lints from `package:lints`.
|
||||
# This set helps identify many issues that may lead to problems when running
|
||||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||
# style and format.
|
||||
#
|
||||
# If you want a smaller set of lints you can change this to specify
|
||||
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||
# (the recommended set includes the core lints).
|
||||
# The core lints are also what is used by pub.dev for scoring packages.
|
||||
|
||||
include: package:lints/recommended.yaml
|
||||
|
||||
# Uncomment the following section to specify additional rules.
|
||||
|
||||
# linter:
|
||||
# rules:
|
||||
# - camel_case_types
|
||||
|
||||
# analyzer:
|
||||
# exclude:
|
||||
# - path/to/excluded/files/**
|
||||
|
||||
# For more information about the core and recommended set of lints, see
|
||||
# https://dart.dev/go/core-lints
|
||||
|
||||
# For additional information about configuring this file, see
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
5
snippets/dart_snippets/bin/dart_snippets.dart
Normal file
5
snippets/dart_snippets/bin/dart_snippets.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
|
||||
void main(List<String> arguments) {
|
||||
BreezSDK().initialize();
|
||||
}
|
||||
10
snippets/dart_snippets/lib/buy_btc.dart
Normal file
10
snippets/dart_snippets/lib/buy_btc.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<BuyBitcoinResponse> buyBitcoin() async {
|
||||
// ANCHOR: buy-btc
|
||||
BuyBitcoinRequest req = const BuyBitcoinRequest(provider: BuyBitcoinProvider.Moonpay);
|
||||
BuyBitcoinResponse resp = await BreezSDK().buyBitcoin(req: req);
|
||||
// ANCHOR_END: buy-btc
|
||||
return resp;
|
||||
}
|
||||
17
snippets/dart_snippets/lib/connecting_lsp.dart
Normal file
17
snippets/dart_snippets/lib/connecting_lsp.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<void> getLspInfo() async {
|
||||
// ANCHOR: get-lsp-info
|
||||
String? lspId = await BreezSDK().lspId();
|
||||
LspInformation? lspInfo = await BreezSDK().lspInfo();
|
||||
print(lspId);
|
||||
print(lspInfo);
|
||||
// ANCHOR_END: get-lsp-info
|
||||
}
|
||||
|
||||
Future<void> connectLsp(String lspId) async {
|
||||
// ANCHOR: connect-lsp
|
||||
return await BreezSDK().connectLSP(lspId);
|
||||
// ANCHOR_END: connect-lsp
|
||||
}
|
||||
40
snippets/dart_snippets/lib/fiat_currencies.dart
Normal file
40
snippets/dart_snippets/lib/fiat_currencies.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<List<FiatCurrency>> listFiatCurrencies() async {
|
||||
// ANCHOR: list-fiat-currencies
|
||||
List<FiatCurrency> fiatCurrencyList = await BreezSDK().listFiatCurrencies();
|
||||
// ANCHOR_END: list-fiat-currencies
|
||||
return fiatCurrencyList;
|
||||
}
|
||||
|
||||
Future<Map<String, Rate>> fetchFiatRates(String lspId) async {
|
||||
// ANCHOR: fetch-fiat-rates
|
||||
Map<String, Rate> fiatRatesMap = await BreezSDK().fetchFiatRates();
|
||||
// print your desired rate
|
||||
print(fiatRatesMap["USD"]?.value);
|
||||
// ANCHOR_END: fetch-fiat-rates
|
||||
return fiatRatesMap;
|
||||
}
|
||||
|
||||
Future<Map<FiatCurrency, Rate>> fiatCurrenciesAndRate() async {
|
||||
// ANCHOR: get-fiat-currencies-and-rates
|
||||
List<FiatCurrency> fiatCurrencies = await BreezSDK().listFiatCurrencies();
|
||||
Map<String, Rate> fiatRates = await BreezSDK().fetchFiatRates();
|
||||
|
||||
var sorted = fiatCurrencies.toList();
|
||||
sorted.sort((f1, f2) {
|
||||
return f1.id.compareTo(f2.id);
|
||||
});
|
||||
|
||||
Map<FiatCurrency, Rate> result = {};
|
||||
for (var currency in sorted) {
|
||||
var rate = fiatRates[currency.id];
|
||||
if (rate != null) {
|
||||
result[currency] = rate;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
// ANCHOR_END: get-fiat-currencies-and-rates
|
||||
}
|
||||
46
snippets/dart_snippets/lib/getting_started.dart
Normal file
46
snippets/dart_snippets/lib/getting_started.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<void> initializeSDK() async {
|
||||
// ANCHOR: init-sdk
|
||||
|
||||
// Initialize SDK logs listener
|
||||
BreezSDK().initialize();
|
||||
|
||||
// Create the default config
|
||||
Uint8List seed = await BreezSDK().mnemonicToSeed("<mnemonic words>");
|
||||
String inviteCode = "<invite code>";
|
||||
String apiKey = "<api key>";
|
||||
NodeConfig nodeConfig = NodeConfig.greenlight(
|
||||
config: GreenlightNodeConfig(
|
||||
partnerCredentials: null,
|
||||
inviteCode: inviteCode,
|
||||
),
|
||||
);
|
||||
Config config = await BreezSDK().defaultConfig(
|
||||
envType: EnvironmentType.Production,
|
||||
apiKey: apiKey,
|
||||
nodeConfig: nodeConfig,
|
||||
);
|
||||
|
||||
// Customize the config object according to your needs
|
||||
config = config.copyWith(workingDir: "path to an existing directory");
|
||||
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
return await BreezSDK().connect(config: config, seed: seed);
|
||||
// ANCHOR_END: init-sdk
|
||||
}
|
||||
|
||||
Future<void> fetchBalance(String lspId) async {
|
||||
// ANCHOR: fetch-balance
|
||||
NodeState? nodeInfo = await BreezSDK().nodeInfo();
|
||||
if (nodeInfo != null) {
|
||||
int lnBalance = nodeInfo.channelsBalanceMsat;
|
||||
int onchainBalance = nodeInfo.onchainBalanceMsat;
|
||||
print(lnBalance);
|
||||
print(onchainBalance);
|
||||
}
|
||||
// ANCHOR_END: fetch-balance
|
||||
}
|
||||
36
snippets/dart_snippets/lib/list_payments.dart
Normal file
36
snippets/dart_snippets/lib/list_payments.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<List<Payment>> listPayments() async {
|
||||
// ANCHOR: list-payments
|
||||
ListPaymentsRequest req = ListPaymentsRequest(filter: PaymentTypeFilter.All);
|
||||
List<Payment> paymentsList = await BreezSDK().listPayments(req: req);
|
||||
print(paymentsList);
|
||||
// ANCHOR_END: list-payments
|
||||
return paymentsList;
|
||||
}
|
||||
|
||||
Future<List<Payment>> listPaymentsFiltered({
|
||||
int? fromTimestamp,
|
||||
int? toTimestamp,
|
||||
bool? includeFailures,
|
||||
int? offset,
|
||||
int? limit,
|
||||
}) async {
|
||||
// ANCHOR: list-payments-filtered
|
||||
/// Get the desired epoch timestamp in seconds
|
||||
int fromTimestamp = DateTime.now().subtract(const Duration(minutes: 30)).millisecondsSinceEpoch ~/ 1000;
|
||||
|
||||
ListPaymentsRequest req = ListPaymentsRequest(
|
||||
filter: PaymentTypeFilter.Sent,
|
||||
fromTimestamp: fromTimestamp,
|
||||
toTimestamp: toTimestamp,
|
||||
includeFailures: includeFailures,
|
||||
offset: offset,
|
||||
limit: limit,
|
||||
);
|
||||
List<Payment> paymentsList = await BreezSDK().listPayments(req: req);
|
||||
print(paymentsList);
|
||||
// ANCHOR_END: list-payments-filtered
|
||||
return paymentsList;
|
||||
}
|
||||
21
snippets/dart_snippets/lib/lnurl_auth.dart
Normal file
21
snippets/dart_snippets/lib/lnurl_auth.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<void> lnurlAuth() async {
|
||||
// ANCHOR: lnurl-auth
|
||||
/// Endpoint can also be of the form:
|
||||
/// keyauth://domain.com/auth?key=val
|
||||
String lnurlAuthUrl =
|
||||
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu";
|
||||
|
||||
InputType inputType = await BreezSDK().parseInput(input: lnurlAuthUrl);
|
||||
if (inputType is InputType_LnUrlAuth) {
|
||||
LnUrlCallbackStatus result = await BreezSDK().lnurlAuth(reqData: inputType.data);
|
||||
if (result is LnUrlCallbackStatus_Ok) {
|
||||
print("Successfully authenticated");
|
||||
} else {
|
||||
print("Failed to authenticate");
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: lnurl-auth
|
||||
}
|
||||
23
snippets/dart_snippets/lib/lnurl_pay.dart
Normal file
23
snippets/dart_snippets/lib/lnurl_pay.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<void> lnurlPay() async {
|
||||
// ANCHOR: lnurl-pay
|
||||
/// Endpoint can also be of the form:
|
||||
/// lnurlp://domain.com/lnurl-pay?key=val
|
||||
/// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
|
||||
String lnurlPayUrl = "lightning@address.com";
|
||||
|
||||
InputType inputType = await BreezSDK().parseInput(input: lnurlPayUrl);
|
||||
if (inputType is InputType_LnUrlPay) {
|
||||
int amountMsat = inputType.data.minSendable;
|
||||
LnUrlPayRequest req = LnUrlPayRequest(
|
||||
data: inputType.data,
|
||||
amountMsat: amountMsat,
|
||||
comment: "<comment>",
|
||||
);
|
||||
LnUrlPayResult result = await BreezSDK().lnurlPay(req: req);
|
||||
print(result.data);
|
||||
}
|
||||
// ANCHOR_END: lnurl-pay
|
||||
}
|
||||
23
snippets/dart_snippets/lib/lnurl_withdraw.dart
Normal file
23
snippets/dart_snippets/lib/lnurl_withdraw.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<void> lnurlWithdraw() async {
|
||||
// ANCHOR: lnurl-withdraw
|
||||
/// Endpoint can also be of the form:
|
||||
/// lnurlw://domain.com/lnurl-withdraw?key=val
|
||||
String lnurlWithdrawUrl =
|
||||
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
|
||||
|
||||
InputType inputType = await BreezSDK().parseInput(input: lnurlWithdrawUrl);
|
||||
if (inputType is InputType_LnUrlWithdraw) {
|
||||
int amountMsat = inputType.data.minWithdrawable;
|
||||
LnUrlWithdrawRequest req = LnUrlWithdrawRequest(
|
||||
data: inputType.data,
|
||||
amountMsat: amountMsat,
|
||||
description: "<description>",
|
||||
);
|
||||
LnUrlWithdrawResult result = await BreezSDK().lnurlWithdraw(req: req);
|
||||
print(result.data);
|
||||
}
|
||||
// ANCHOR_END: lnurl-withdraw
|
||||
}
|
||||
61
snippets/dart_snippets/lib/receive_onchain.dart
Normal file
61
snippets/dart_snippets/lib/receive_onchain.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<SwapInfo> generateReceiveOnchainAddress() async {
|
||||
// ANCHOR: generate-receive-onchain-address
|
||||
ReceiveOnchainRequest req = const ReceiveOnchainRequest();
|
||||
SwapInfo swapInfo = await BreezSDK().receiveOnchain(req: req);
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
final address = swapInfo.bitcoinAddress;
|
||||
print(address);
|
||||
return swapInfo;
|
||||
// ANCHOR_END: generate-receive-onchain-address
|
||||
}
|
||||
|
||||
Future<SwapInfo?> getInProgressSwap() async {
|
||||
// ANCHOR: in-progress-swap
|
||||
SwapInfo? swapInfo = await BreezSDK().inProgressSwap();
|
||||
print(swapInfo);
|
||||
// ANCHOR_END: in-progress-swap
|
||||
return swapInfo;
|
||||
}
|
||||
|
||||
Future<List<SwapInfo>> listRefundables() async {
|
||||
// ANCHOR: list-refundables
|
||||
List<SwapInfo> refundables = await BreezSDK().listRefundables();
|
||||
for (var refundable in refundables) {
|
||||
print(refundable.bitcoinAddress);
|
||||
}
|
||||
// ANCHOR_END: list-refundables
|
||||
return refundables;
|
||||
}
|
||||
|
||||
Future<RefundResponse> executeRefund({
|
||||
required String swapAddress,
|
||||
required String toAddress,
|
||||
required int satPerVbyte,
|
||||
}) async {
|
||||
// ANCHOR: execute-refund
|
||||
RefundRequest req = RefundRequest(
|
||||
swapAddress: swapAddress,
|
||||
toAddress: toAddress,
|
||||
satPerVbyte: satPerVbyte,
|
||||
);
|
||||
RefundResponse resp = await BreezSDK().refund(req: req);
|
||||
print(resp.refundTxId);
|
||||
// ANCHOR_END: execute-refund
|
||||
return resp;
|
||||
}
|
||||
|
||||
Future<OpenChannelFeeResponse> getChannelOpeningFees({
|
||||
required int amountMsat,
|
||||
int? expiry,
|
||||
}) async {
|
||||
// ANCHOR: get-channel-opening-fees
|
||||
OpenChannelFeeRequest req = OpenChannelFeeRequest(amountMsat: amountMsat, expiry: expiry);
|
||||
OpenChannelFeeResponse resp = await BreezSDK().openChannelFee(req: req);
|
||||
print(resp.feeMsat);
|
||||
// ANCHOR_END: get-channel-opening-fees
|
||||
return resp;
|
||||
}
|
||||
14
snippets/dart_snippets/lib/receive_payment.dart
Normal file
14
snippets/dart_snippets/lib/receive_payment.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<ReceivePaymentResponse> receivePayment() async {
|
||||
// ANCHOR: receive-payment
|
||||
ReceivePaymentRequest req = const ReceivePaymentRequest(
|
||||
amountMsat: 3000000,
|
||||
description: "Invoice for 3000 sats",
|
||||
);
|
||||
ReceivePaymentResponse resp = await BreezSDK().receivePayment(req: req);
|
||||
print(resp.lnInvoice);
|
||||
// ANCHOR_END: receive-payment
|
||||
return resp;
|
||||
}
|
||||
46
snippets/dart_snippets/lib/send_onchain.dart
Normal file
46
snippets/dart_snippets/lib/send_onchain.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<ReverseSwapPairInfo> estimateCurrentFees() async {
|
||||
// ANCHOR: estimate-current-reverse-swap-total-fees
|
||||
ReverseSwapFeesRequest req = const ReverseSwapFeesRequest(sendAmountSat: 50000);
|
||||
ReverseSwapPairInfo currentFees = await BreezSDK().fetchReverseSwapFees(req: req);
|
||||
print("Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}");
|
||||
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
||||
return currentFees;
|
||||
}
|
||||
|
||||
void listCurrentFees({required ReverseSwapPairInfo currentFees}) {
|
||||
// ANCHOR: get-current-reverse-swap-min-max
|
||||
print("Minimum amount, in sats: ${currentFees.min}");
|
||||
print("Maximum amount, in sats: ${currentFees.max}");
|
||||
// ANCHOR_END: get-current-reverse-swap-min-max
|
||||
}
|
||||
|
||||
Future<SendOnchainResponse> startReverseSwap({
|
||||
required int amountSat,
|
||||
required String onchainRecipientAddress,
|
||||
required String pairHash,
|
||||
required int satPerVbyte,
|
||||
}) async {
|
||||
// ANCHOR: start-reverse-swap
|
||||
SendOnchainRequest req = SendOnchainRequest(
|
||||
amountSat: amountSat,
|
||||
onchainRecipientAddress: onchainRecipientAddress,
|
||||
pairHash: pairHash,
|
||||
satPerVbyte: satPerVbyte,
|
||||
);
|
||||
SendOnchainResponse resp = await BreezSDK().sendOnchain(req: req);
|
||||
// ANCHOR_END: start-reverse-swap
|
||||
return resp;
|
||||
}
|
||||
|
||||
Future<List<ReverseSwapInfo>> checkReverseSwapStatus() async {
|
||||
// ANCHOR: check-reverse-swaps-status
|
||||
List<ReverseSwapInfo> inProgRevSwapList = await BreezSDK().inProgressReverseSwaps();
|
||||
for (var inProgRevSwap in inProgRevSwapList) {
|
||||
print("Reverse swap ${inProgRevSwap.id} in progress, status is ${inProgRevSwap.status.name}");
|
||||
}
|
||||
// ANCHOR_END: check-reverse-swaps-status
|
||||
return inProgRevSwapList;
|
||||
}
|
||||
12
snippets/dart_snippets/lib/send_payment.dart
Normal file
12
snippets/dart_snippets/lib/send_payment.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<SendPaymentResponse> sendPayment({required String bolt11}) async {
|
||||
// ANCHOR: send-payment
|
||||
// The `amountMsat` param is optional and should only passed if the bolt11 doesn't specify an amount.
|
||||
// The amountMsat is required in case an amount is not specified in the bolt11 invoice'.
|
||||
SendPaymentRequest req = SendPaymentRequest(bolt11: bolt11, amountMsat: 3000000);
|
||||
SendPaymentResponse resp = await BreezSDK().sendPayment(req: req);
|
||||
// ANCHOR_END: send-payment
|
||||
return resp;
|
||||
}
|
||||
15
snippets/dart_snippets/lib/send_spontaneous_payment.dart
Normal file
15
snippets/dart_snippets/lib/send_spontaneous_payment.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<SendPaymentResponse> sendSpontaneousPayment({
|
||||
required String nodeId,
|
||||
}) async {
|
||||
// ANCHOR: send-spontaneous-payment
|
||||
SendSpontaneousPaymentRequest req = SendSpontaneousPaymentRequest(
|
||||
amountMsat: 3000000,
|
||||
nodeId: nodeId,
|
||||
);
|
||||
SendPaymentResponse resp = await BreezSDK().sendSpontaneousPayment(req: req);
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
return resp;
|
||||
}
|
||||
10
snippets/dart_snippets/lib/static_channel_backup.dart
Normal file
10
snippets/dart_snippets/lib/static_channel_backup.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
Future<StaticBackupResponse> retrieveBackupFiles({required String workingDir}) async {
|
||||
// ANCHOR: static-channel-backup
|
||||
StaticBackupRequest req = StaticBackupRequest(workingDir: workingDir);
|
||||
StaticBackupResponse resp = await BreezSDK().staticBackup(req: req);
|
||||
// ANCHOR_END: static-channel-backup
|
||||
return resp;
|
||||
}
|
||||
593
snippets/dart_snippets/pubspec.lock
Normal file
593
snippets/dart_snippets/pubspec.lock
Normal file
@@ -0,0 +1,593 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "64.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.2.0"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
sha256: "7e0d52067d05f2e0324268097ba723b71cb41ac8a6a2b24d1edf9c536b987b03"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.4.6"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
breez_sdk:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: "9629def110a9dd03413850a05e9709d3c9794b0d"
|
||||
url: "https://github.com/breez/breez-sdk-flutter"
|
||||
source: git
|
||||
version: "0.2.7"
|
||||
build:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build
|
||||
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
build_cli_annotations:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_cli_annotations
|
||||
sha256: b59d2769769efd6c9ff6d4c4cede0be115a566afc591705c2040b707534b1172
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
build_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_config
|
||||
sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: checked_yaml
|
||||
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.2"
|
||||
colorize:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: colorize
|
||||
sha256: "584746cd6ba1cba0633b6720f494fe6f9601c4170f0666c1579d2aa2a61071ba"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
coverage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: coverage
|
||||
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.7.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
sha256: abd7625e16f51f554ea244d090292945ec4d4be7bfbaf2ec8cccea568919d334
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.3"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
flutter:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_rust_bridge:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_rust_bridge
|
||||
sha256: "8dcfeff9dcf0db9c76578c8805a337c0e5e21b4d96887eb1007b6fe141e15ea9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.75.2"
|
||||
freezed:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: freezed
|
||||
sha256: "21bf2825311de65501d22e563e3d7605dff57fb5e6da982db785ae5372ff018a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.5"
|
||||
freezed_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: freezed_annotation
|
||||
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: frontend_server_client
|
||||
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: glob
|
||||
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.13.6"
|
||||
http_multi_server:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_multi_server
|
||||
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.2"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: io
|
||||
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.7"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.8.1"
|
||||
lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: lints
|
||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
node_preamble:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: node_preamble
|
||||
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.3"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.4.0"
|
||||
pointycastle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pointycastle
|
||||
sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.7.3"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pool
|
||||
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
pubspec_parse:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pubspec_parse
|
||||
sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
puppeteer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: puppeteer
|
||||
sha256: dd49117259867d0ce0de33ddd95628fb70cff94581a6432c08272447b8dd1d27
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.24.0"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rxdart
|
||||
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.27.7"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf
|
||||
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
shelf_packages_handler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_packages_handler
|
||||
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
shelf_static:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_static
|
||||
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
shelf_web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_web_socket
|
||||
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_gen:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_gen
|
||||
sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
source_map_stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_map_stack_trace
|
||||
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
source_maps:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_maps
|
||||
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.10.12"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
test:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: test
|
||||
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.24.9"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.1"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.9"
|
||||
tuple:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: tuple
|
||||
sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: uuid
|
||||
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.7"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "13.0.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.4-beta"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
webkit_inspection_protocol:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webkit_inspection_protocol
|
||||
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.1.0-185.0.dev <4.0.0"
|
||||
flutter: ">=3.7.12"
|
||||
16
snippets/dart_snippets/pubspec.yaml
Normal file
16
snippets/dart_snippets/pubspec.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
name: dart_snippets
|
||||
description: A sample command-line application.
|
||||
version: 1.0.0
|
||||
publish_to: 'none'
|
||||
|
||||
environment:
|
||||
sdk: '>=3.0.0 <4.0.0'
|
||||
|
||||
dependencies:
|
||||
breez_sdk:
|
||||
git:
|
||||
url: https://github.com/breez/breez-sdk-flutter
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^2.0.0
|
||||
test: ^1.21.0
|
||||
26
snippets/go/.gitignore
vendored
Normal file
26
snippets/go/.gitignore
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
|
||||
# Ignore Go binaries
|
||||
**/*
|
||||
!**/*.go
|
||||
!**/
|
||||
18
snippets/go/buy_btc.go
Normal file
18
snippets/go/buy_btc.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func BuyBitcoin() {
|
||||
// ANCHOR: buy-btc
|
||||
buyBitcoinRequest := breez_sdk.BuyBitcoinRequest{
|
||||
Provider: breez_sdk.BuyBitcoinProviderMoonpay,
|
||||
}
|
||||
if buyBitcoinResponse, err := sdk.BuyBitcoin(buyBitcoinRequest); err == nil {
|
||||
log.Printf("%#v", buyBitcoinResponse)
|
||||
}
|
||||
// ANCHOR_END: buy-btc
|
||||
}
|
||||
27
snippets/go/connecting_lsp.go
Normal file
27
snippets/go/connecting_lsp.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
func GetLspInfo() {
|
||||
// ANCHOR: get-lsp-info
|
||||
if lspId, err := sdk.LspId(); lspId != nil && err == nil {
|
||||
log.Printf("%#v", *lspId)
|
||||
}
|
||||
|
||||
if lspInfo, err := sdk.LspInfo(); err == nil {
|
||||
log.Printf("%#v", lspInfo)
|
||||
}
|
||||
// ANCHOR_END: get-lsp-info
|
||||
}
|
||||
|
||||
func ConnectLsp() {
|
||||
// ANCHOR: connect-lsp
|
||||
lspId := "your selected lsp id"
|
||||
|
||||
if err := sdk.ConnectLsp(lspId); err != nil {
|
||||
log.Printf("%#v", err)
|
||||
}
|
||||
// ANCHOR_END: connect-lsp
|
||||
}
|
||||
27
snippets/go/fiat_currencies.go
Normal file
27
snippets/go/fiat_currencies.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
func ListFiatCurrencies() {
|
||||
// ANCHOR: list-fiat-currencies
|
||||
if fiatCurrencies, err := sdk.ListFiatCurrencies(); err == nil {
|
||||
log.Printf("%#v", fiatCurrencies)
|
||||
}
|
||||
// ANCHOR_END: list-fiat-currencies
|
||||
}
|
||||
|
||||
func FetchFiatRates() {
|
||||
// ANCHOR: fetch-fiat-rates
|
||||
if fiatRates, err := sdk.FetchFiatRates(); err == nil {
|
||||
log.Printf("%#v", fiatRates)
|
||||
}
|
||||
// ANCHOR_END: fetch-fiat-rates
|
||||
}
|
||||
|
||||
func GetFiatCurrenciesAndRates() {
|
||||
// ANCHOR: get-fiat-currencies-and-rates
|
||||
// TODO
|
||||
// ANCHOR_END: get-fiat-currencies-and-rates
|
||||
}
|
||||
53
snippets/go/getting_started.go
Normal file
53
snippets/go/getting_started.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
// ANCHOR: init-sdk-requirements
|
||||
// SDK events listener
|
||||
type BreezListener struct{}
|
||||
|
||||
func (BreezListener) OnEvent(e breez_sdk.BreezEvent) {
|
||||
log.Printf("received event %#v", e)
|
||||
}
|
||||
|
||||
// ANCHOR_END: init-sdk-requirements
|
||||
|
||||
func GettingStarted() {
|
||||
// ANCHOR: init-sdk
|
||||
// Create the default config
|
||||
seed, err := breez_sdk.MnemonicToSeed("<mnemonic words>")
|
||||
if err != nil {
|
||||
log.Fatalf("MnemonicToSeed failed: %#v", err)
|
||||
}
|
||||
|
||||
inviteCode := "<invite code>"
|
||||
apiKey := "<api key>"
|
||||
nodeConfig := breez_sdk.NodeConfigGreenlight{
|
||||
Config: breez_sdk.GreenlightNodeConfig{
|
||||
PartnerCredentials: nil,
|
||||
InviteCode: &inviteCode,
|
||||
},
|
||||
}
|
||||
|
||||
config := breez_sdk.DefaultConfig(breez_sdk.EnvironmentTypeProduction, apiKey, nodeConfig)
|
||||
// Customize the config object according to your needs
|
||||
config.WorkingDir = "path to an existing directory"
|
||||
|
||||
sdk, err := breez_sdk.Connect(config, seed, BreezListener{})
|
||||
if err != nil {
|
||||
log.Fatalf("Connect failed: %#v", err)
|
||||
}
|
||||
// ANCHOR_END: init-sdk
|
||||
// ANCHOR: fetch-balance
|
||||
if nodeInfo, err := sdk.NodeInfo(); err != nil {
|
||||
lnBalance := nodeInfo.ChannelsBalanceMsat
|
||||
onchainBalance := nodeInfo.OnchainBalanceMsat
|
||||
|
||||
log.Printf("%#v %#v", lnBalance, onchainBalance)
|
||||
}
|
||||
// ANCHOR_END: fetch-balance
|
||||
}
|
||||
5
snippets/go/go.mod
Normal file
5
snippets/go/go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module main
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/breez/breez-sdk-go v0.2.7
|
||||
30
snippets/go/list_payments.go
Normal file
30
snippets/go/list_payments.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func ListPayments() {
|
||||
// ANCHOR: list-payments
|
||||
if payments, err := sdk.ListPayments(breez_sdk.ListPaymentsRequest{Filter: breez_sdk.PaymentTypeFilterAll}); err == nil {
|
||||
log.Printf("%#v", payments)
|
||||
}
|
||||
// ANCHOR_END: list-payments
|
||||
}
|
||||
|
||||
func ListPaymentsFiltered() {
|
||||
// ANCHOR: list-payments-filtered
|
||||
fromTimestamp := int64(1696880000)
|
||||
includeFailures := true
|
||||
listPaymentsRequest := breez_sdk.ListPaymentsRequest{
|
||||
Filter: breez_sdk.PaymentTypeFilterSent,
|
||||
FromTimestamp: &fromTimestamp,
|
||||
IncludeFailures: &includeFailures,
|
||||
}
|
||||
if payments, err := sdk.ListPayments(listPaymentsRequest); err == nil {
|
||||
log.Printf("%#v", payments)
|
||||
}
|
||||
// ANCHOR_END: list-payments-filtered
|
||||
}
|
||||
28
snippets/go/lnurl_auth.go
Normal file
28
snippets/go/lnurl_auth.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func LnurlAuth() {
|
||||
// ANCHOR: lnurl-auth
|
||||
// keyauth://domain.com/auth?key=val
|
||||
lnurlAuthUrl := "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"
|
||||
|
||||
if input, err := breez_sdk.ParseInput(lnurlAuthUrl); err != nil {
|
||||
switch inputType := input.(type) {
|
||||
case breez_sdk.InputTypeLnUrlAuth:
|
||||
if result, err := sdk.LnurlAuth(inputType.Data); err != nil {
|
||||
switch result.(type) {
|
||||
case breez_sdk.LnUrlCallbackStatusOk:
|
||||
log.Printf("Successfully authenticated")
|
||||
default:
|
||||
log.Printf("Failed to authenticate")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: lnurl-auth
|
||||
}
|
||||
37
snippets/go/lnurl_pay.go
Normal file
37
snippets/go/lnurl_pay.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func LnurlPay() {
|
||||
// ANCHOR: lnurl-pay
|
||||
// Endpoint can also be of the form:
|
||||
// lnurlp://domain.com/lnurl-pay?key=val
|
||||
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
|
||||
lnurlPayUrl := "lightning@address.com"
|
||||
|
||||
if input, err := breez_sdk.ParseInput(lnurlPayUrl); err != nil {
|
||||
switch inputType := input.(type) {
|
||||
case breez_sdk.InputTypeLnUrlPay:
|
||||
amountMsat := inputType.Data.MinSendable
|
||||
comment := "comment"
|
||||
lnUrlPayRequest := breez_sdk.LnUrlPayRequest{
|
||||
Data: inputType.Data,
|
||||
AmountMsat: amountMsat,
|
||||
Comment: &comment,
|
||||
}
|
||||
if result, err := sdk.PayLnurl(lnUrlPayRequest); err != nil {
|
||||
switch result.(type) {
|
||||
case breez_sdk.LnUrlPayResultEndpointSuccess:
|
||||
log.Printf("Successfully paid")
|
||||
default:
|
||||
log.Printf("Failed to pay")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: lnurl-pay
|
||||
}
|
||||
35
snippets/go/lnurl_withdraw.go
Normal file
35
snippets/go/lnurl_withdraw.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func LnurlWithdraw() {
|
||||
// ANCHOR: lnurl-withdraw
|
||||
// Endpoint can also be of the form:
|
||||
// lnurlw://domain.com/lnurl-withdraw?key=val
|
||||
lnurlWithdrawUrl := "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"
|
||||
|
||||
if input, err := breez_sdk.ParseInput(lnurlWithdrawUrl); err != nil {
|
||||
switch inputType := input.(type) {
|
||||
case breez_sdk.InputTypeLnUrlWithdraw:
|
||||
amountMsat := inputType.Data.MinWithdrawable
|
||||
description := "comment"
|
||||
if result, err := sdk.WithdrawLnurl(breez_sdk.LnUrlWithdrawRequest{
|
||||
Data: inputType.Data,
|
||||
AmountMsat: amountMsat,
|
||||
Description: &description,
|
||||
}); err != nil {
|
||||
switch result.(type) {
|
||||
case breez_sdk.LnUrlCallbackStatusOk:
|
||||
log.Printf("Successfully withdrawn")
|
||||
default:
|
||||
log.Printf("Failed to withdraw")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: lnurl-withdraw
|
||||
}
|
||||
9
snippets/go/main.go
Normal file
9
snippets/go/main.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
var sdk breez_sdk.BlockingBreezServices
|
||||
|
||||
func main() {}
|
||||
58
snippets/go/receive_onchain.go
Normal file
58
snippets/go/receive_onchain.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func GenerateReceiveOnchainAddress() {
|
||||
// ANCHOR: generate-receive-onchain-address
|
||||
if swapInfo, err := sdk.ReceiveOnchain(breez_sdk.ReceiveOnchainRequest{}); err != nil {
|
||||
// Send your funds to the below bitcoin address
|
||||
address := swapInfo.BitcoinAddress
|
||||
log.Printf("%v", address)
|
||||
}
|
||||
// ANCHOR_END: generate-receive-onchain-address
|
||||
}
|
||||
|
||||
func GetInProgressSwap() {
|
||||
// ANCHOR: in-progress-swap
|
||||
if swapInfo, err := sdk.InProgressSwap(); err == nil {
|
||||
log.Printf("%#v", swapInfo)
|
||||
}
|
||||
// ANCHOR_END: in-progress-swap
|
||||
}
|
||||
|
||||
func ListRefundables() {
|
||||
// ANCHOR: list-refundables
|
||||
if refundables, err := sdk.ListRefundables(); err == nil {
|
||||
log.Printf("%#v", refundables)
|
||||
}
|
||||
// ANCHOR_END: list-refundables
|
||||
}
|
||||
|
||||
func ExecuteRefund() {
|
||||
// ANCHOR: execute-refund
|
||||
if refundables, err := sdk.ListRefundables(); err == nil {
|
||||
destinationAddress := "..."
|
||||
satPerVbyte := uint32(5)
|
||||
refundRequest := breez_sdk.RefundRequest{
|
||||
SwapAddress: refundables[0].BitcoinAddress,
|
||||
ToAddress: destinationAddress,
|
||||
SatPerVbyte: satPerVbyte,
|
||||
}
|
||||
if result, err := sdk.Refund(refundRequest); err == nil {
|
||||
log.Printf("%v", result)
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: execute-refund
|
||||
}
|
||||
|
||||
func GetChannelOpeningFees(amountMsat uint64) {
|
||||
// ANCHOR: get-channel-opening-fees
|
||||
if channelFees, err := sdk.OpenChannelFee(breez_sdk.OpenChannelFeeRequest{AmountMsat: amountMsat}); err == nil {
|
||||
log.Printf("%#v", channelFees)
|
||||
}
|
||||
// ANCHOR_END: get-channel-opening-fees
|
||||
}
|
||||
19
snippets/go/receive_payment.go
Normal file
19
snippets/go/receive_payment.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func ReceivePayment() {
|
||||
// ANCHOR: receive-payment
|
||||
receivePaymentRequest := breez_sdk.ReceivePaymentRequest{
|
||||
AmountMsat: uint64(3_000_000),
|
||||
Description: "Invoice for 3000 sats",
|
||||
}
|
||||
if receivePaymentResponse, err := sdk.ReceivePayment(receivePaymentRequest); err == nil {
|
||||
log.Printf("%#v", receivePaymentResponse)
|
||||
}
|
||||
// ANCHOR_END: receive-payment
|
||||
}
|
||||
55
snippets/go/send_onchain.go
Normal file
55
snippets/go/send_onchain.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func GetCurrentFees() {
|
||||
// ANCHOR: estimate-current-reverse-swap-total-fees
|
||||
sendAmountSat := uint64(50_000)
|
||||
reverseSwapFeesRequest := breez_sdk.ReverseSwapFeesRequest{
|
||||
SendAmountSat: &sendAmountSat,
|
||||
}
|
||||
if currentFees, err := sdk.FetchReverseSwapFees(reverseSwapFeesRequest); err == nil {
|
||||
log.Printf("Total estimated fees for reverse swap: %v", currentFees.TotalEstimatedFees)
|
||||
}
|
||||
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
||||
}
|
||||
|
||||
func ListCurrentFees(currentFees breez_sdk.ReverseSwapPairInfo) {
|
||||
// ANCHOR: get-current-reverse-swap-min-max
|
||||
log.Printf("Minimum amount, in sats: %v", currentFees.Min)
|
||||
log.Printf("Maximum amount, in sats: %v", currentFees.Max)
|
||||
// ANCHOR_END: get-current-reverse-swap-min-max
|
||||
}
|
||||
|
||||
func StartReverseSwap() {
|
||||
// ANCHOR: start-reverse-swap
|
||||
destinationAddress := "bc1.."
|
||||
sendAmountSat := uint64(50_000)
|
||||
satPerVbyte := uint32(5)
|
||||
if currentFees, err := sdk.FetchReverseSwapFees(breez_sdk.ReverseSwapFeesRequest{SendAmountSat: &sendAmountSat}); err == nil {
|
||||
sendOnchainRequest := breez_sdk.SendOnchainRequest{
|
||||
AmountSat: sendAmountSat,
|
||||
OnchainRecipientAddress: destinationAddress,
|
||||
PairHash: currentFees.FeesHash,
|
||||
SatPerVbyte: satPerVbyte,
|
||||
}
|
||||
if reverseSwapInfo, err := sdk.SendOnchain(sendOnchainRequest); err == nil {
|
||||
log.Printf("%#v", reverseSwapInfo)
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: start-reverse-swap
|
||||
}
|
||||
|
||||
func CheckReverseSwapStatus() {
|
||||
// ANCHOR: check-reverse-swaps-status
|
||||
if swaps, err := sdk.InProgressReverseSwaps(); err == nil {
|
||||
for _, swap := range swaps {
|
||||
log.Printf("Reverse swap %v in progress, status is %v", swap.Id, swap.Status)
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: check-reverse-swaps-status
|
||||
}
|
||||
23
snippets/go/send_payment.go
Normal file
23
snippets/go/send_payment.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func SendPayment() {
|
||||
// ANCHOR: send-payment
|
||||
bolt11 := "bolt11 invoice"
|
||||
// The `amountMsat` param is optional and should only passed if the bolt11 doesn't specify an amount.
|
||||
// The amountMsat is required in case an amount is not specified in the bolt11 invoice'.
|
||||
amountMsat := uint64(3_000_000)
|
||||
sendPaymentRequest := breez_sdk.SendPaymentRequest{
|
||||
Bolt11: bolt11,
|
||||
AmountMsat: &amountMsat,
|
||||
}
|
||||
if response, err := sdk.SendPayment(sendPaymentRequest); err == nil {
|
||||
log.Printf("%#v", response)
|
||||
}
|
||||
// ANCHOR_END: send-payment
|
||||
}
|
||||
19
snippets/go/send_spontaneous_payment.go
Normal file
19
snippets/go/send_spontaneous_payment.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func SendSpontaneousPayment() {
|
||||
// ANCHOR: send-spontaneous-payment
|
||||
sendSpontaneousPaymentRequest := breez_sdk.SendSpontaneousPaymentRequest{
|
||||
NodeId: "...",
|
||||
AmountMsat: uint64(3_000_000),
|
||||
}
|
||||
if response, err := sdk.SendSpontaneousPayment(sendSpontaneousPaymentRequest); err == nil {
|
||||
log.Printf("%#v", response)
|
||||
}
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
}
|
||||
16
snippets/go/static_channel_backup.go
Normal file
16
snippets/go/static_channel_backup.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
)
|
||||
|
||||
func RetrieveBackupFiles() {
|
||||
// ANCHOR: static-channel-backup
|
||||
workingDir := "<working directory>"
|
||||
if staticBackupResponse, err := breez_sdk.StaticBackup(breez_sdk.StaticBackupRequest{WorkingDir: workingDir}); err == nil {
|
||||
log.Printf("%#v", staticBackupResponse)
|
||||
}
|
||||
// ANCHOR_END: static-channel-backup
|
||||
}
|
||||
8
snippets/react-native/.prettierrc
Normal file
8
snippets/react-native/.prettierrc
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"endOfLine": "lf",
|
||||
"printWidth": 80,
|
||||
"semi": false,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 4,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
12
snippets/react-native/buy_btc.ts
Normal file
12
snippets/react-native/buy_btc.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {
|
||||
buyBitcoin,
|
||||
BuyBitcoinProvider
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleBuyBtc = async () => {
|
||||
// ANCHOR: buy-btc
|
||||
const buyBitcoinResponse = await buyBitcoin({
|
||||
provider: BuyBitcoinProvider.MOONPAY
|
||||
})
|
||||
// ANCHOR_END: buy-btc
|
||||
}
|
||||
15
snippets/react-native/connecting_lsp.ts
Normal file
15
snippets/react-native/connecting_lsp.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { connectLsp, lspId, lspInfo } from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleAutoConnect = async () => {
|
||||
// ANCHOR: get-lsp-info
|
||||
const id = await lspId()
|
||||
const info = await lspInfo()
|
||||
// ANCHOR_END: get-lsp-info
|
||||
}
|
||||
|
||||
const exampleManualConnect = async () => {
|
||||
// ANCHOR: connect-lsp
|
||||
const id = "your selected lsp id"
|
||||
await connectLsp(id)
|
||||
// ANCHOR_END: connect-lsp
|
||||
}
|
||||
22
snippets/react-native/fiat_currencies.ts
Normal file
22
snippets/react-native/fiat_currencies.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
listFiatCurrencies,
|
||||
fetchFiatRates
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleListCurrencies = async () => {
|
||||
// ANCHOR: list-fiat-currencies
|
||||
const fiatCurrencies = await listFiatCurrencies()
|
||||
// ANCHOR_END: list-fiat-currencies
|
||||
}
|
||||
|
||||
const exampleFetchRates = async () => {
|
||||
// ANCHOR: fetch-fiat-rates
|
||||
const fiatRates = await fetchFiatRates()
|
||||
// ANCHOR_END: fetch-fiat-rates
|
||||
}
|
||||
|
||||
const exampleListCurrenciesAndRates = async () => {
|
||||
// ANCHOR: get-fiat-currencies-and-rates
|
||||
// TODO
|
||||
// ANCHOR_END: get-fiat-currencies-and-rates
|
||||
}
|
||||
47
snippets/react-native/getting_started.ts
Normal file
47
snippets/react-native/getting_started.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
BreezEvent,
|
||||
connect,
|
||||
defaultConfig,
|
||||
EnvironmentType,
|
||||
mnemonicToSeed,
|
||||
NodeConfig,
|
||||
NodeConfigVariant,
|
||||
nodeInfo
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleGettingStarted = async () => {
|
||||
// ANCHOR: init-sdk
|
||||
// SDK events listener
|
||||
const onBreezEvent = (e: BreezEvent) => {
|
||||
console.log(`Received event ${e.type}`)
|
||||
}
|
||||
|
||||
// Create the default config
|
||||
const seed = await mnemonicToSeed("<mnemonics words>")
|
||||
const inviteCode = "<invite code>"
|
||||
const apiKey = "<api key>"
|
||||
const nodeConfig: NodeConfig = {
|
||||
type: NodeConfigVariant.GREENLIGHT,
|
||||
config: {
|
||||
inviteCode
|
||||
}
|
||||
}
|
||||
|
||||
const config = await defaultConfig(
|
||||
EnvironmentType.PRODUCTION,
|
||||
apiKey,
|
||||
nodeConfig
|
||||
)
|
||||
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
await connect(config, seed, onBreezEvent)
|
||||
// ANCHOR_END: init-sdk
|
||||
}
|
||||
|
||||
const exampleFetchNodeInfo = async () => {
|
||||
// ANCHOR: fetch-balance
|
||||
const nodeState = await nodeInfo()
|
||||
const balanceLn = nodeState.channelsBalanceMsat
|
||||
const balanceOnchain = nodeState.onchainBalanceMsat
|
||||
// ANCHOR_END: fetch-balance
|
||||
}
|
||||
20
snippets/react-native/list_payments.ts
Normal file
20
snippets/react-native/list_payments.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {
|
||||
listPayments,
|
||||
PaymentTypeFilter
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleListPayments = async () => {
|
||||
// ANCHOR: list-payments
|
||||
const payments = listPayments({ filter: PaymentTypeFilter.ALL })
|
||||
// ANCHOR_END: list-payments
|
||||
}
|
||||
|
||||
const exampleListPaymentsFiltered = async () => {
|
||||
// ANCHOR: list-payments-filtered
|
||||
const payments = listPayments({
|
||||
filter: PaymentTypeFilter.SENT,
|
||||
fromTimestamp: 1696880000,
|
||||
includeFailures: true
|
||||
})
|
||||
// ANCHOR_END: list-payments-filtered
|
||||
}
|
||||
25
snippets/react-native/lnurl_auth.ts
Normal file
25
snippets/react-native/lnurl_auth.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
InputTypeVariant,
|
||||
lnurlAuth,
|
||||
LnUrlCallbackStatusVariant,
|
||||
parseInput
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleLnurlAuth = async () => {
|
||||
// ANCHOR: lnurl-auth
|
||||
// Endpoint can also be of the form:
|
||||
// keyauth://domain.com/auth?key=val
|
||||
const lnurlAuthUrl =
|
||||
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"
|
||||
|
||||
const input = await parseInput(lnurlAuthUrl)
|
||||
if (input.type === InputTypeVariant.LN_URL_AUTH) {
|
||||
const result = await lnurlAuth(input.data)
|
||||
if (result.type === LnUrlCallbackStatusVariant.OK) {
|
||||
console.log("Successfully authenticated")
|
||||
} else {
|
||||
console.log("Failed to authenticate")
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: lnurl-auth
|
||||
}
|
||||
24
snippets/react-native/lnurl_pay.ts
Normal file
24
snippets/react-native/lnurl_pay.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
InputTypeVariant,
|
||||
parseInput,
|
||||
payLnurl
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleLnurlPay = async () => {
|
||||
// ANCHOR: lnurl-pay
|
||||
// Endpoint can also be of the
|
||||
// lnurlp://domain.com/lnurl-pay?key=val
|
||||
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
|
||||
const lnurlPayUrl = "lightning@address.com"
|
||||
|
||||
const input = await parseInput(lnurlPayUrl)
|
||||
if (input.type === InputTypeVariant.LN_URL_PAY) {
|
||||
const amountMsat = input.data.minSendable
|
||||
const lnUrlPayResult = await payLnurl({
|
||||
data: input.data,
|
||||
amountMsat,
|
||||
comment: "comment"
|
||||
})
|
||||
}
|
||||
// ANCHOR_END: lnurl-pay
|
||||
}
|
||||
24
snippets/react-native/lnurl_withdraw.ts
Normal file
24
snippets/react-native/lnurl_withdraw.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
InputTypeVariant,
|
||||
parseInput,
|
||||
withdrawLnurl
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleLnurlWithdraw = async () => {
|
||||
// ANCHOR: lnurl-withdraw
|
||||
// Endpoint can also be of the form:
|
||||
// lnurlw://domain.com/lnurl-withdraw?key=val
|
||||
const lnurlWithdrawUrl =
|
||||
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"
|
||||
|
||||
const input = await parseInput(lnurlWithdrawUrl)
|
||||
if (input.type === InputTypeVariant.LN_URL_WITHDRAW) {
|
||||
const amountMsat = input.data.minWithdrawable
|
||||
const lnUrlWithdrawResult = await withdrawLnurl({
|
||||
data: input.data,
|
||||
amountMsat,
|
||||
description: "comment"
|
||||
})
|
||||
}
|
||||
// ANCHOR_END: lnurl-withdraw
|
||||
}
|
||||
19
snippets/react-native/package.json
Normal file
19
snippets/react-native/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "snippets",
|
||||
"version": "0.0.1",
|
||||
"description": "React Native Snippets",
|
||||
"main": "index.ts",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
|
||||
},
|
||||
"dependencies": {
|
||||
"@breeztech/react-native-breez-sdk": "0.2.7",
|
||||
"react": "18.1.0",
|
||||
"react-native": "0.70.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsx": "^3.12.7"
|
||||
}
|
||||
}
|
||||
|
||||
52
snippets/react-native/receive_onchain.ts
Normal file
52
snippets/react-native/receive_onchain.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
inProgressSwap,
|
||||
listRefundables,
|
||||
openChannelFee,
|
||||
receiveOnchain,
|
||||
refund
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleReceiveOnchain = async () => {
|
||||
// ANCHOR: generate-receive-onchain-address
|
||||
const swapInfo = await receiveOnchain({})
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
const address = swapInfo.bitcoinAddress
|
||||
// ANCHOR_END: generate-receive-onchain-address
|
||||
}
|
||||
|
||||
const exampleInProgressSwap = async () => {
|
||||
// ANCHOR: in-progress-swap
|
||||
const swapInfo = await inProgressSwap()
|
||||
// ANCHOR_END: in-progress-swap
|
||||
}
|
||||
|
||||
const exampleListRefundables = async () => {
|
||||
// ANCHOR: list-refundables
|
||||
const refundables = await listRefundables()
|
||||
// ANCHOR_END: list-refundables
|
||||
}
|
||||
|
||||
const exampleRefund = async () => {
|
||||
// ANCHOR: execute-refund
|
||||
const refundables = await listRefundables()
|
||||
const toAddress = "..."
|
||||
const satPerVbyte = 5
|
||||
|
||||
const refundResponse = await refund({
|
||||
swapAddress: refundables[0].bitcoinAddress,
|
||||
toAddress,
|
||||
satPerVbyte
|
||||
})
|
||||
// ANCHOR_END: execute-refund
|
||||
}
|
||||
|
||||
const exampleOpenChannelFee = async () => {
|
||||
// ANCHOR: get-channel-opening-fees
|
||||
const amountMsat = 10000
|
||||
|
||||
const openChannelFeeResponse = await openChannelFee({
|
||||
amountMsat: amountMsat
|
||||
})
|
||||
// ANCHOR_END: get-channel-opening-fees
|
||||
}
|
||||
10
snippets/react-native/receive_payment.ts
Normal file
10
snippets/react-native/receive_payment.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { receivePayment } from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleReceiveLightningPayment = async () => {
|
||||
// ANCHOR: receive-payment
|
||||
const invoice = await receivePayment({
|
||||
amountMsat: 3000000,
|
||||
description: "Invoice for 3000 sats"
|
||||
})
|
||||
// ANCHOR: receive-payment
|
||||
}
|
||||
49
snippets/react-native/send_onchain.ts
Normal file
49
snippets/react-native/send_onchain.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
ReverseSwapPairInfo,
|
||||
fetchReverseSwapFees,
|
||||
inProgressReverseSwaps,
|
||||
sendOnchain
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleFetchReverseSwapFees = async () => {
|
||||
// ANCHOR: estimate-current-reverse-swap-total-fees
|
||||
const currentFees = await fetchReverseSwapFees({ sendAmountSat: 50000 })
|
||||
|
||||
console.log(
|
||||
`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`
|
||||
)
|
||||
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
||||
}
|
||||
|
||||
const exampleListCurrentFees = (currentFees: ReverseSwapPairInfo) => {
|
||||
// ANCHOR: get-current-reverse-swap-min-max
|
||||
console.log(`Minimum amount, in sats: ${currentFees.min}`)
|
||||
console.log(`Maximum amount, in sats: ${currentFees.max}`)
|
||||
// ANCHOR_END: get-current-reverse-swap-min-max
|
||||
}
|
||||
|
||||
const exampleSendOnchain = async (currentFees: ReverseSwapPairInfo) => {
|
||||
// ANCHOR: start-reverse-swap
|
||||
const onchainRecipientAddress = "bc1.."
|
||||
const amountSat = currentFees.min
|
||||
const satPerVbyte = 5
|
||||
|
||||
const reverseSwapInfo = await sendOnchain({
|
||||
amountSat,
|
||||
onchainRecipientAddress,
|
||||
pairHash: currentFees.feesHash,
|
||||
satPerVbyte
|
||||
})
|
||||
// ANCHOR_END: start-reverse-swap
|
||||
}
|
||||
|
||||
const exampleInProgressReverseSwaps = async () => {
|
||||
// ANCHOR: check-reverse-swaps-status
|
||||
const swaps = await inProgressReverseSwaps()
|
||||
for (const swap of swaps) {
|
||||
console.log(
|
||||
`Reverse swap ${swap.id} in progress, status is ${swap.status}`
|
||||
)
|
||||
}
|
||||
// ANCHOR_END: check-reverse-swaps-status
|
||||
}
|
||||
10
snippets/react-native/send_payment.ts
Normal file
10
snippets/react-native/send_payment.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { sendPayment } from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleSendLightningPayment = async () => {
|
||||
// ANCHOR: send-payment
|
||||
// The `amountMsat` param is optional and should only passed if the bolt11 doesn't specify an amount.
|
||||
// The amountMsat is required in case an amount is not specified in the bolt11 invoice'.
|
||||
const amountMsat = 3000000
|
||||
const response = await sendPayment({bolt11, amountMsat})
|
||||
// ANCHOR_END: send-payment
|
||||
}
|
||||
12
snippets/react-native/send_spontaneous_payment.ts
Normal file
12
snippets/react-native/send_spontaneous_payment.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { sendSpontaneousPayment } from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleSendSpontaneousPayment = async () => {
|
||||
// ANCHOR: send-spontaneous-payment
|
||||
const nodeId = "..."
|
||||
|
||||
const sendPaymentResponse = await sendSpontaneousPayment({
|
||||
nodeId,
|
||||
amountMsat: 3000000
|
||||
})
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
}
|
||||
7
snippets/react-native/static_channel_backup.ts
Normal file
7
snippets/react-native/static_channel_backup.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { staticBackup } from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleStaticBackup = async () => {
|
||||
// ANCHOR: static-channel-backup
|
||||
let backupData = await staticBackup({ workingDir: "<working directory>" })
|
||||
// ANCHOR_END: static-channel-backup
|
||||
}
|
||||
3842
snippets/react-native/yarn.lock
Normal file
3842
snippets/react-native/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
3622
snippets/rust/Cargo.lock
generated
Normal file
3622
snippets/rust/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
snippets/rust/Cargo.toml
Normal file
11
snippets/rust/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "sdk_docs_snippets"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
bip39 = { version = "2", features = ["rand"] }
|
||||
breez-sdk-core = { git = "https://github.com/breez/breez-sdk", rev = "3486c951e2422fe4ac3978795849f0b7649a9f1e" }
|
||||
log = "0.4"
|
||||
tokio = "1.29"
|
||||
16
snippets/rust/src/buy_btc.rs
Normal file
16
snippets/rust/src/buy_btc.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn buy(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: buy-btc
|
||||
let res = sdk.buy_bitcoin(
|
||||
BuyBitcoinRequest {
|
||||
provider: BuyBitcoinProvider::Moonpay,
|
||||
opening_fee_params: None})
|
||||
.await?;
|
||||
// ANCHOR_END: buy-btc
|
||||
|
||||
Ok(())
|
||||
}
|
||||
21
snippets/rust/src/connecting_lsp.rs
Normal file
21
snippets/rust/src/connecting_lsp.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn get_lsp_info(sdk: Arc<BreezServices>) -> Result<LspInformation> {
|
||||
// ANCHOR: get-lsp-info
|
||||
let lsp_id = sdk.lsp_id().await?;
|
||||
let lsp_info = sdk.lsp_info().await?;
|
||||
// ANCHOR_END: get-lsp-info
|
||||
|
||||
Ok(lsp_info)
|
||||
}
|
||||
|
||||
async fn connect_lsp(sdk: Arc<BreezServices>, lsp_id: String) -> Result<()> {
|
||||
// ANCHOR: connect-lsp
|
||||
sdk.connect_lsp(lsp_id).await?;
|
||||
// ANCHOR_END: connect-lsp
|
||||
|
||||
Ok(())
|
||||
}
|
||||
46
snippets/rust/src/fiat_currencies.rs
Normal file
46
snippets/rust/src/fiat_currencies.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn list_supported_fiat_currencies(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: list-fiat-currencies
|
||||
let supported_fiat_currencies = sdk.list_fiat_currencies().await?;
|
||||
// ANCHOR_END: list-fiat-currencies
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_current_rates(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: fetch-fiat-rates
|
||||
let fiat_rates = sdk.fetch_fiat_rates().await?;
|
||||
// ANCHOR_END: fetch-fiat-rates
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_fiat_currencies_and_rates(sdk: Arc<BreezServices>) -> Result<Vec<(FiatCurrency, Rate)>> {
|
||||
// ANCHOR: get-fiat-currencies-and-rates
|
||||
let supported_fiat_currencies = sdk.list_fiat_currencies().await?;
|
||||
let fiat_rates = sdk.fetch_fiat_rates().await?;
|
||||
|
||||
let mut rates_map : HashMap<String, Rate> = HashMap::new();
|
||||
for rate in fiat_rates {
|
||||
rates_map.insert(rate.coin.to_string().to_lowercase(), rate);
|
||||
}
|
||||
|
||||
let mut sorted = supported_fiat_currencies.clone();
|
||||
sorted.sort_by_key(|f| f.info.name.clone());
|
||||
|
||||
let mut result : Vec<(FiatCurrency, Rate)> = Vec::new();
|
||||
for currency in sorted {
|
||||
let rate = rates_map.get(¤cy.id.to_lowercase());
|
||||
if let Some(rate) = rate.cloned() {
|
||||
result.push((currency, rate));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
// ANCHOR_END: get-fiat-currencies-and-rates
|
||||
}
|
||||
50
snippets/rust/src/getting_started.rs
Normal file
50
snippets/rust/src/getting_started.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use anyhow::Result;
|
||||
use bip39::{Language, Mnemonic};
|
||||
use breez_sdk_core::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::AppEventListener;
|
||||
|
||||
async fn getting_started() -> Result<Arc<BreezServices>> {
|
||||
// ANCHOR: init-sdk
|
||||
let mnemonic = Mnemonic::generate_in(Language::English, 12)?;
|
||||
let seed = mnemonic.to_seed("");
|
||||
let invite_code = Some("<invite code>".into());
|
||||
let api_key = "<api key>".into();
|
||||
|
||||
// Create the default config
|
||||
let mut config = BreezServices::default_config(
|
||||
EnvironmentType::Production,
|
||||
api_key,
|
||||
breez_sdk_core::NodeConfig::Greenlight {
|
||||
config: GreenlightNodeConfig {
|
||||
partner_credentials: None,
|
||||
invite_code
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Customize the config object according to your needs
|
||||
config.working_dir = "path to an existing directory".into();
|
||||
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
let sdk = BreezServices::connect(
|
||||
config,
|
||||
seed.to_vec(),
|
||||
Box::new(AppEventListener {}),
|
||||
)
|
||||
.await?;
|
||||
// ANCHOR_END: init-sdk
|
||||
|
||||
Ok(sdk)
|
||||
}
|
||||
|
||||
async fn getting_started_node_info(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: fetch-balance
|
||||
let node_state = sdk.node_info()?;
|
||||
let balance_ln = node_state.channels_balance_msat;
|
||||
let balance_onchain = node_state.onchain_balance_msat;
|
||||
// ANCHOR_END: fetch-balance
|
||||
|
||||
Ok(())
|
||||
}
|
||||
38
snippets/rust/src/list_payments.rs
Normal file
38
snippets/rust/src/list_payments.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn list_payments(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> {
|
||||
// ANCHOR: list-payments
|
||||
let payments = sdk.list_payments(
|
||||
ListPaymentsRequest {
|
||||
filter: PaymentTypeFilter::All,
|
||||
from_timestamp: None,
|
||||
to_timestamp: None,
|
||||
include_failures: None,
|
||||
offset: None,
|
||||
limit: None
|
||||
}
|
||||
).await?;
|
||||
// ANCHOR_END: list-payments
|
||||
|
||||
Ok(payments)
|
||||
}
|
||||
|
||||
async fn list_payments_filtered(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> {
|
||||
// ANCHOR: list-payments-filtered
|
||||
let payments = sdk.list_payments(
|
||||
ListPaymentsRequest {
|
||||
filter: PaymentTypeFilter::Sent,
|
||||
from_timestamp: Some(1696880000),
|
||||
to_timestamp: None,
|
||||
include_failures: Some(true),
|
||||
offset: None,
|
||||
limit: None
|
||||
}
|
||||
).await?;
|
||||
// ANCHOR_END: list-payments-filtered
|
||||
|
||||
Ok(payments)
|
||||
}
|
||||
30
snippets/rust/src/lnurl_auth.rs
Normal file
30
snippets/rust/src/lnurl_auth.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
use breez_sdk_core::InputType::LnUrlAuth;
|
||||
use log::{error, info};
|
||||
|
||||
async fn auth(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: lnurl-auth
|
||||
// Endpoint can also be of the form:
|
||||
// keyauth://domain.com/auth?key=val
|
||||
let lnurl_auth_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu";
|
||||
|
||||
if let Ok(LnUrlAuth{data: ad}) = parse(lnurl_auth_url).await {
|
||||
match sdk.lnurl_auth(ad).await {
|
||||
Ok(LnUrlCallbackStatus::Ok) => {
|
||||
info!("Successfully authenticated")
|
||||
}
|
||||
Ok(LnUrlCallbackStatus::ErrorStatus { data }) => {
|
||||
error!("Failed to authenticate: {}", data.reason)
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to connect: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: lnurl-auth
|
||||
|
||||
Ok(())
|
||||
}
|
||||
27
snippets/rust/src/lnurl_pay.rs
Normal file
27
snippets/rust/src/lnurl_pay.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
use breez_sdk_core::InputType::LnUrlPay;
|
||||
|
||||
async fn pay(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: lnurl-pay
|
||||
// Endpoint can also be of the form:
|
||||
// lnurlp://domain.com/lnurl-pay?key=val
|
||||
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
|
||||
let lnurl_pay_url = "lightning@address.com";
|
||||
|
||||
if let Ok(LnUrlPay{data: pd}) = parse(lnurl_pay_url).await {
|
||||
let amount_msat = pd.min_sendable;
|
||||
let comment = "Test payment".to_string();
|
||||
|
||||
sdk.lnurl_pay(LnUrlPayRequest {
|
||||
data: pd,
|
||||
amount_msat,
|
||||
comment: Some(comment)
|
||||
}).await?;
|
||||
}
|
||||
// ANCHOR_END: lnurl-pay
|
||||
|
||||
Ok(())
|
||||
}
|
||||
26
snippets/rust/src/lnurl_withdraw.rs
Normal file
26
snippets/rust/src/lnurl_withdraw.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
use breez_sdk_core::InputType::LnUrlWithdraw;
|
||||
|
||||
async fn withdraw(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: lnurl-withdraw
|
||||
// Endpoint can also be of the form:
|
||||
// lnurlw://domain.com/lnurl-withdraw?key=val
|
||||
let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
|
||||
|
||||
if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await {
|
||||
let amount_msat = wd.min_withdrawable;
|
||||
let description = "Test withdraw".to_string();
|
||||
|
||||
sdk.lnurl_withdraw(LnUrlWithdrawRequest {
|
||||
data: wd,
|
||||
amount_msat,
|
||||
description: Some(description)
|
||||
}).await?;
|
||||
}
|
||||
// ANCHOR_END: lnurl-withdraw
|
||||
|
||||
Ok(())
|
||||
}
|
||||
30
snippets/rust/src/main.rs
Normal file
30
snippets/rust/src/main.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
mod getting_started;
|
||||
mod receive_payment;
|
||||
mod send_payment;
|
||||
mod send_spontaneous_payment;
|
||||
mod list_payments;
|
||||
mod connecting_lsp;
|
||||
mod receive_onchain;
|
||||
mod send_onchain;
|
||||
mod lnurl_pay;
|
||||
mod lnurl_withdraw;
|
||||
mod lnurl_auth;
|
||||
mod fiat_currencies;
|
||||
mod buy_btc;
|
||||
mod static_channel_backup;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
use log::info;
|
||||
|
||||
struct AppEventListener {}
|
||||
impl EventListener for AppEventListener {
|
||||
fn on_event(&self, e: BreezEvent) {
|
||||
info!("Received Breez event: {e:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
58
snippets/rust/src/receive_onchain.rs
Normal file
58
snippets/rust/src/receive_onchain.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn generate_receive_onchain_address(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: generate-receive-onchain-address
|
||||
let swap_info = sdk.receive_onchain(
|
||||
ReceiveOnchainRequest { opening_fee_params: None } )
|
||||
.await?;
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
let address = swap_info.bitcoin_address;
|
||||
// ANCHOR_END: generate-receive-onchain-address
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_in_progress_swap(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: in-progress-swap
|
||||
let swap_info = sdk.in_progress_swap().await?;
|
||||
// ANCHOR_END: in-progress-swap
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn list_refundables(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: list-refundables
|
||||
let refundables = sdk.list_refundables().await?;
|
||||
// ANCHOR_END: list-refundables
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn execute_refund(sdk: Arc<BreezServices>, refund_tx_fee_rate: u32, refundable: SwapInfo) -> Result<()> {
|
||||
// ANCHOR: execute-refund
|
||||
let destination_address = "...".into();
|
||||
let sat_per_vbyte = refund_tx_fee_rate;
|
||||
|
||||
sdk.refund(RefundRequest {
|
||||
to_address: destination_address,
|
||||
sat_per_vbyte,
|
||||
swap_address: refundable.bitcoin_address
|
||||
}).await?;
|
||||
// ANCHOR_END: execute-refund
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_channel_opening_fees(sdk: Arc<BreezServices>, amount_msat: u64) -> Result<()> {
|
||||
// ANCHOR: get-channel-opening-fees
|
||||
let channel_fees = sdk.open_channel_fee(
|
||||
OpenChannelFeeRequest { amount_msat, expiry: None })
|
||||
.await?;
|
||||
// ANCHOR_END: get-channel-opening-fees
|
||||
|
||||
Ok(())
|
||||
}
|
||||
22
snippets/rust/src/receive_payment.rs
Normal file
22
snippets/rust/src/receive_payment.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn receive_payment(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: receive-payment
|
||||
let res = sdk.receive_payment(
|
||||
ReceivePaymentRequest {
|
||||
amount_msat: 3_000_000,
|
||||
description: "Invoice for 3000 sats".into(),
|
||||
cltv: None,
|
||||
expiry: None,
|
||||
opening_fee_params: None,
|
||||
preimage: None,
|
||||
use_description_hash: None
|
||||
})
|
||||
.await?;
|
||||
// ANCHOR_END: receive-payment
|
||||
|
||||
Ok(())
|
||||
}
|
||||
55
snippets/rust/src/send_onchain.rs
Normal file
55
snippets/rust/src/send_onchain.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
use log::info;
|
||||
|
||||
async fn get_current_fees(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: estimate-current-reverse-swap-total-fees
|
||||
let current_fees = sdk.fetch_reverse_swap_fees(
|
||||
ReverseSwapFeesRequest {
|
||||
send_amount_sat: Some(50_000),
|
||||
})
|
||||
.await?;
|
||||
|
||||
info!("Total estimated fees for reverse swap: {:?}", current_fees.total_estimated_fees);
|
||||
// ANCHOR_END: estimate-current-reverse-swap-total-fees
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn list_current_fees(current_fees: ReverseSwapPairInfo) -> Result<()> {
|
||||
// ANCHOR: get-current-reverse-swap-min-max
|
||||
info!("Minimum amount, in sats: {}", current_fees.min);
|
||||
info!("Maximum amount, in sats: {}", current_fees.max);
|
||||
// ANCHOR_END: get-current-reverse-swap-min-max
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn start_reverse_swap(sdk: Arc<BreezServices>, current_fees: ReverseSwapPairInfo, fee_rate: u32) -> Result<()> {
|
||||
// ANCHOR: start-reverse-swap
|
||||
let destination_address = String::from("bc1..");
|
||||
let amount_sat = current_fees.min;
|
||||
let sat_per_vbyte = fee_rate;
|
||||
|
||||
sdk.send_onchain(SendOnchainRequest {
|
||||
pair_hash: current_fees.fees_hash,
|
||||
amount_sat,
|
||||
sat_per_vbyte,
|
||||
onchain_recipient_address: destination_address
|
||||
}).await?;
|
||||
// ANCHOR_END: start-reverse-swap
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn check_reverse_swap_status(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: check-reverse-swaps-status
|
||||
for rs in sdk.in_progress_reverse_swaps().await? {
|
||||
info!("Reverse swap {} in progress, status is {:?}", rs.id, rs.status);
|
||||
}
|
||||
// ANCHOR_END: check-reverse-swaps-status
|
||||
|
||||
Ok(())
|
||||
}
|
||||
19
snippets/rust/src/send_payment.rs
Normal file
19
snippets/rust/src/send_payment.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn send_payment(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: send-payment
|
||||
// The `amount_msat` param is optional and should only passed if the bolt11 doesn't specify an amount.
|
||||
// The amount_msat is required in case an amount is not specified in the bolt11 invoice'.
|
||||
let amount_msat: Option<u64> = None;
|
||||
let req = SendPaymentRequest {
|
||||
bolt11: "...".into(),
|
||||
amount_msat,
|
||||
};
|
||||
let response = sdk.send_payment(req).await?;
|
||||
// ANCHOR_END: send-payment
|
||||
|
||||
Ok(())
|
||||
}
|
||||
17
snippets/rust/src/send_spontaneous_payment.rs
Normal file
17
snippets/rust/src/send_spontaneous_payment.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn send_spontaneous_payment(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: send-spontaneous-payment
|
||||
let node_id = "...".into();
|
||||
|
||||
sdk.send_spontaneous_payment(SendSpontaneousPaymentRequest {
|
||||
amount_msat: 3_000_000,
|
||||
node_id
|
||||
}).await?;
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
|
||||
Ok(())
|
||||
}
|
||||
12
snippets/rust/src/static_channel_backup.rs
Normal file
12
snippets/rust/src/static_channel_backup.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
async fn retrieve_backup_files() -> Result<()> {
|
||||
// ANCHOR: static-channel-backup
|
||||
let backup_data = BreezServices::static_backup(StaticBackupRequest {
|
||||
working_dir: "<working directory>".into(),
|
||||
})?;
|
||||
// ANCHOR_END: static-channel-backup
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -12,11 +12,7 @@ Once the buy is completed, the provider will transfer the Bitcoin to the generat
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
let res = sdk.buy_bitcoin(
|
||||
BuyBitcoinRequest {
|
||||
provider: BuyBitcoinProvider::Moonpay,
|
||||
opening_fee_params: None})
|
||||
.await?;
|
||||
{{#include ../../snippets/rust/src/buy_btc.rs:buy-btc}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -33,7 +29,7 @@ do {
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin
|
||||
@@ -54,11 +50,7 @@ try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
try {
|
||||
let buyBitcoinResponse = await buyBitcoin({provider: BuyBitcoinProvider.MOONPAY})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
{{#include ../../snippets/react-native/buy_btc.ts:buy-btc}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -66,15 +58,7 @@ try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
try {
|
||||
BuyBitcoinResponse buyBitcoinResponse = buyBitcoin(
|
||||
reqData: BuyBitcoinRequest(
|
||||
provider: BuyBitcoinProvider.Moonpay,
|
||||
),
|
||||
);
|
||||
} catch {
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/dart_snippets/lib/buy_btc.dart:buy-btc}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -95,12 +79,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
buyBitcoinRequest := breez_sdk.BuyBitcoinRequest{
|
||||
Provider: breez_sdk.BuyBitcoinProviderMoonpay,
|
||||
}
|
||||
if buyBitcoinResponse, err := sdk.BuyBitcoin(buyBitcoinRequest); err == nil {
|
||||
log.Printf("%#v", buyBitcoinResponse)
|
||||
}
|
||||
{{#include ../../snippets/go/buy_btc.go:buy-btc}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -109,15 +88,7 @@ if buyBitcoinResponse, err := sdk.BuyBitcoin(buyBitcoinRequest); err == nil {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
try
|
||||
{
|
||||
var buyBitcoinResponse = sdk.BuyBitcoin(
|
||||
new BuyBitcoinRequest(BuyBitcoinProvider.MOONPAY));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/csharp/BuyBtc.cs:buy-btc}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
@@ -7,8 +7,7 @@ Based on the API key provided to the Breez SDK, a default LSP is selected for yo
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
let lsp_id = sdk.lsp_id().await?;
|
||||
let lsp_info = sdk.lsp_info().await?;
|
||||
{{#include ../../snippets/rust/src/connecting_lsp.rs:get-lsp-info}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -25,7 +24,7 @@ do {
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
@@ -46,12 +45,7 @@ try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
try {
|
||||
const lspId = await lspId()
|
||||
const lspInfo = await lspInfo()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
{{#include ../../snippets/react-native/connecting_lsp.ts:get-lsp-info}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -59,12 +53,7 @@ try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
try {
|
||||
List<LspInformation> lspList = await listLsps();
|
||||
// Select your desired LSP
|
||||
} catch (e) {
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/dart_snippets/lib/connecting_lsp.dart:get-lsp-info}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -85,12 +74,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
if lspId, err := sdk.LspId(); lspId != nil && err == nil {
|
||||
log.Printf("%#v", *lspId)
|
||||
}
|
||||
if lspInfo, err := sdk.LspInfo(); err == nil {
|
||||
log.Printf("%#v", lspInfo)
|
||||
}
|
||||
{{#include ../../snippets/go/connecting_lsp.go:get-lsp-info}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -98,15 +82,7 @@ if lspInfo, err := sdk.LspInfo(); err == nil {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
try
|
||||
{
|
||||
var lspId = sdk.LspId();
|
||||
var lspInfo = sdk.LspInfo();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/csharp/ConnectingLsp.cs:get-lsp-info}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
@@ -118,7 +94,7 @@ When you have selected an LSP you may then connect to it.
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
sdk.connect_lsp(lsp_id).await?;
|
||||
{{#include ../../snippets/rust/src/connecting_lsp.rs:connect-lsp}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -134,7 +110,7 @@ do {
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
@@ -150,11 +126,7 @@ try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
try {
|
||||
await connectLsp(lspId)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
{{#include ../../snippets/react-native/connecting_lsp.ts:connect-lsp}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -162,12 +134,7 @@ try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
try {
|
||||
String lspId = await lspId();
|
||||
await connectLSP(lspId);
|
||||
} catch (e) {
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/dart_snippets/lib/connecting_lsp.dart:connect-lsp}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -186,10 +153,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
lspId := "your selected lsp id"
|
||||
if err := sdk.ConnectLsp(lspId); err != nil {
|
||||
log.Printf("%#v", err)
|
||||
}
|
||||
{{#include ../../snippets/go/connecting_lsp.go:connect-lsp}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -197,14 +161,7 @@ if err := sdk.ConnectLsp(lspId); err != nil {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
try
|
||||
{
|
||||
sdk.ConnectLsp(lspId!);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/csharp/ConnectingLsp.cs:connect-lsp}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
|
||||
@@ -3,7 +3,15 @@
|
||||
In order to list the available fiat currencies:
|
||||
|
||||
<custom-tabs category="lang">
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Rust</div>
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
{{#include ../../snippets/rust/src/fiat_currencies.rs:list-fiat-currencies}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
@@ -19,11 +27,7 @@ try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
try {
|
||||
const fiatCurrencyList = await listFiatCurrencies()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
{{#include ../../snippets/react-native/fiat_currencies.ts:list-fiat-currencies}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -31,11 +35,7 @@ try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
try {
|
||||
List<FiatCurrency> fiatCurrencyList = await listFiatCurrencies();
|
||||
} catch(e) {
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/dart_snippets/lib/fiat_currencies.dart:list-fiat-currencies}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -55,9 +55,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
if fiatCurrencies, err := sdk.ListFiatCurrencies(); err == nil {
|
||||
log.Printf("%#v", fiatCurrencies)
|
||||
}
|
||||
{{#include ../../snippets/go/fiat_currencies.go:list-fiat-currencies}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -65,14 +63,7 @@ if fiatCurrencies, err := sdk.ListFiatCurrencies(); err == nil {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
try
|
||||
{
|
||||
var fiatCurrencies = sdk.ListFiatCurrencies();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/csharp/FiatCurrencies.cs:list-fiat-currencies}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
@@ -80,7 +71,15 @@ catch (Exception)
|
||||
To get the current BTC rate for the currencies:
|
||||
|
||||
<custom-tabs category="lang">
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Rust</div>
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
{{#include ../../snippets/rust/src/fiat_currencies.rs:fetch-fiat-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
@@ -96,11 +95,7 @@ try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
try {
|
||||
const fiatRatesMap = await fetchFiatRates()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
{{#include ../../snippets/react-native/fiat_currencies.ts:fetch-fiat-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -108,13 +103,7 @@ try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
try {
|
||||
Map<String, Rate> fiatRatesMap = await fetchFiatRates();
|
||||
// print your desired rate
|
||||
print(fiatRatesMap["USD"]?.value);
|
||||
} catch(e) {
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/dart_snippets/lib/fiat_currencies.dart:fetch-fiat-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -134,9 +123,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
if fiatRates, err := sdk.FetchFiatRates(); err == nil {
|
||||
log.Printf("%#v", fiatRates)
|
||||
}
|
||||
{{#include ../../snippets/go/fiat_currencies.go:fetch-fiat-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -144,14 +131,7 @@ if fiatRates, err := sdk.FetchFiatRates(); err == nil {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
try
|
||||
{
|
||||
var fiatRates = sdk.FetchFiatRates();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/csharp/FiatCurrencies.cs:fetch-fiat-rates}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
@@ -159,7 +139,15 @@ catch (Exception)
|
||||
At the example project you can see these methods combined:
|
||||
|
||||
<custom-tabs category="lang">
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Rust</div>
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
{{#include ../../snippets/rust/src/fiat_currencies.rs:get-fiat-currencies-and-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
@@ -193,7 +181,7 @@ fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
// TODO
|
||||
{{#include ../../snippets/react-native/fiat_currencies.ts:get-fiat-currencies-and-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -201,31 +189,7 @@ fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
Future<Map<FiatCurrency, Rate>> fiatCurrenciesAndRate() async {
|
||||
try {
|
||||
List<FiatCurrency> fiatCurrencies = await _breezLib.listFiatCurrencies();
|
||||
Map<String, Rate> fiatRates = await _breezLib.fetchFiatRates();
|
||||
|
||||
var sorted = fiatCurrencies.toList();
|
||||
sorted.sort((f1, f2) {
|
||||
return f1.id.compareTo(f2.id);
|
||||
});
|
||||
|
||||
Map<FiatCurrency, Rate> result = {};
|
||||
for (var currency in sorted) {
|
||||
var rate = fiatRates[currency.id];
|
||||
if (rate != null) {
|
||||
result[currency] = rate;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (e) {
|
||||
// Handle error
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
{{#include ../../snippets/dart_snippets/lib/fiat_currencies.dart:get-fiat-currencies-and-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -241,7 +205,7 @@ Future<Map<FiatCurrency, Rate>> fiatCurrenciesAndRate() async {
|
||||
<section>
|
||||
|
||||
```go
|
||||
// TODO
|
||||
{{#include ../../snippets/go/fiat_currencies.go:get-fiat-currencies-and-rates}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -249,7 +213,7 @@ Future<Map<FiatCurrency, Rate>> fiatCurrenciesAndRate() async {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
// TODO
|
||||
{{#include ../../snippets/csharp/FiatCurrencies.cs:get-fiat-currencies-and-rates}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
@@ -42,33 +42,7 @@ Now your SDK is ready to be used.
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
let mnemonic = Mnemonic::generate_in(Language::English, 12)?;
|
||||
let seed = mnemonic.to_seed("");
|
||||
let invite_code = Some("<invite code>".into());
|
||||
let api_key = "<api key>".into()
|
||||
|
||||
// Create the default config
|
||||
let mut config = BreezServices::default_config(
|
||||
EnvironmentType::Production,
|
||||
api_key,
|
||||
breez_sdk_core::NodeConfig::Greenlight {
|
||||
config: GreenlightNodeConfig {
|
||||
partner_credentials: None,
|
||||
invite_code
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Customize the config object according to your needs
|
||||
config.working_dir = "path to an existing directory".into();
|
||||
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
let sdk = BreezServices::connect(
|
||||
config,
|
||||
seed.to_vec(),
|
||||
Box::new(AppEventListener {}),
|
||||
)
|
||||
.await?;
|
||||
{{#include ../../snippets/rust/src/getting_started.rs:init-sdk}}
|
||||
```
|
||||
|
||||
</section>
|
||||
@@ -105,7 +79,7 @@ do {
|
||||
|
||||
</section>
|
||||
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
@@ -143,32 +117,7 @@ try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
// SDK events listener
|
||||
const onBreezEvent = (event: BreezEvent) => {
|
||||
console.log(`received event ${event.type}`)
|
||||
})
|
||||
|
||||
// Create the default config
|
||||
const seed = await mnemonicToSeed("<mnemonic words>")
|
||||
const inviteCode = "<invite code>"
|
||||
const apiKey = "<api key>"
|
||||
const nodeConfig : NodeConfig = {
|
||||
type: NodeConfigVariant.GREENLIGHT,
|
||||
config: {
|
||||
inviteCode: inviteCode
|
||||
}
|
||||
}
|
||||
let config = await defaultConfig(EnvironmentType.PRODUCTION, apiKey, nodeConfig)
|
||||
|
||||
// Customize the config object according to your needs
|
||||
config.workingDir = "path to an existing directory"
|
||||
|
||||
try {
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
const sdkServices = await connect(config, seed, onBreezEvent)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
{{#include ../../snippets/react-native/getting_started.ts:init-sdk}}
|
||||
```
|
||||
|
||||
</section>
|
||||
@@ -177,32 +126,7 @@ try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
// SDK events listener
|
||||
breezEventsStream().listen((event) {
|
||||
print("Received Breez event: $event");
|
||||
}
|
||||
|
||||
// SDK logs listener
|
||||
breezLogStream().listen((log) {
|
||||
print("Received Breez log entry: $log");
|
||||
}
|
||||
|
||||
// Create the default config
|
||||
Uint8List seed = await mnemonicToSeed(phrase: "<mnemonic words>");
|
||||
String inviteCode = "<invite code>";
|
||||
String apiKey = "<api key>"
|
||||
NodeConfg nodeConfig = NodeConfig.greenlight(config: GreenlightNodeConfig(partnerCredentials: null, inviteCode: inviteCode));
|
||||
Config config = await defaultConfig(configType: EnvironmentType.Production, apiKey: apiKey, nodeConfig: nodeConfig);
|
||||
|
||||
// Customize the config object according to your needs
|
||||
config.workingDir = "path to an existing directory";
|
||||
|
||||
try {
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
await connect(config: config, seed: seed);
|
||||
} catch (error) {
|
||||
// handle error
|
||||
}
|
||||
{{#include ../../snippets/dart_snippets/lib/getting_started.dart:init-sdk}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -237,41 +161,8 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
// SDK events listener
|
||||
type BreezListener struct{}
|
||||
|
||||
func (BreezListener) OnEvent(e breez_sdk.BreezEvent) {
|
||||
log.Printf("received event %#v", e)
|
||||
}
|
||||
|
||||
// Create the default config
|
||||
seed, err := breez_sdk.MnemonicToSeed("<mnemonic words>")
|
||||
if err != nil {
|
||||
log.Fatalf("MnemonicToSeed failed: %#v", err)
|
||||
}
|
||||
|
||||
inviteCode := "<invite code>"
|
||||
apiKey := "<api key>"
|
||||
nodeConfig := breez_sdk.NodeConfigGreenlight{
|
||||
Config: breez_sdk.GreenlightNodeConfig{
|
||||
PartnerCredentials: nil,
|
||||
InviteCode: &inviteCode,
|
||||
},
|
||||
}
|
||||
|
||||
config, err := breez_sdk.DefaultConfig(breez_sdk.EnvironmentTypeProduction, apiKey, nodeConfig)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("DefaultConfig failed: %#v", err)
|
||||
}
|
||||
|
||||
// Customize the config object according to your needs
|
||||
config.workingDir = "path to an existing directory"
|
||||
|
||||
sdk, err := breez_sdk.Connect(config, seed, BreezListener{})
|
||||
if err != nil {
|
||||
log.Fatalf("Connect failed: %#v", err)
|
||||
}
|
||||
{{#include ../../snippets/go/getting_started.go:init-sdk-requirements}}
|
||||
{{#include ../../snippets/go/getting_started.go:init-sdk}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -279,42 +170,7 @@ if err != nil {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
using Breez.Sdk;
|
||||
|
||||
// Create the default config
|
||||
var seed = BreezSdkMethods.MnemonicToSeed("<mnemonic words>");
|
||||
var inviteCode = "<invite code>";
|
||||
var apiKey = "<api key>";
|
||||
var nodeConfig = new NodeConfig.Greenlight(
|
||||
new GreenlightNodeConfig(null, inviteCode)
|
||||
);
|
||||
var config = BreezSdkMethods.DefaultConfig(
|
||||
EnvironmentType.PRODUCTION,
|
||||
apiKey,
|
||||
nodeConfig
|
||||
) with {
|
||||
// Customize the config object according to your needs
|
||||
workingDir = "path to an existing directory"
|
||||
};
|
||||
|
||||
BlockingBreezServices sdk;
|
||||
try
|
||||
{
|
||||
// Connect to the Breez SDK make it ready for use
|
||||
sdk = BreezSdkMethods.Connect(config, seed, new SdkListener());
|
||||
} catch (Exception)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// SDK event listener
|
||||
class SdkListener : EventListener
|
||||
{
|
||||
public void OnEvent(BreezEvent e)
|
||||
{
|
||||
Console.WriteLine($"Received Breez event type {e.GetType().Name}");
|
||||
}
|
||||
}
|
||||
{{#include ../../snippets/csharp/GettingStarted.cs:init-sdk}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
@@ -326,10 +182,7 @@ At any point we can fetch our balance from the Greenlight node:
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
if let Some(node_state) = sdk.node_info()? {
|
||||
let balance_ln = node_state.channels_balance_msat;
|
||||
let balance_onchain = node_state.onchain_balance_msat;
|
||||
}
|
||||
{{#include ../../snippets/rust/src/getting_started.rs:fetch-balance}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -347,7 +200,7 @@ do {
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Android</div>
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
@@ -365,13 +218,7 @@ try {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
try {
|
||||
const nodeInfo = await nodeInfo();
|
||||
const lnBalance = nodeInfo.channelsBalanceMsat;
|
||||
const onchainBalance = nodeInfo.onchainBalanceMsat;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
{{#include ../../snippets/react-native/getting_started.ts:fetch-balance}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -379,13 +226,7 @@ try {
|
||||
<section>
|
||||
|
||||
```dart
|
||||
try {
|
||||
NodeState? nodeInfo = await nodeInfo();
|
||||
int lnBalance = nodeInfo?.channelsBalanceMsat;
|
||||
int onchainBalance = nodeInfo?.onchainBalanceMsat;
|
||||
} catch (error) {
|
||||
// handle error
|
||||
}
|
||||
{{#include ../../snippets/dart_snippets/lib/getting_started.dart:fetch-balance}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -406,10 +247,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
if nodeInfo, err := sdkServices.NodeInfo(); err != nil {
|
||||
lnBalance := nodeInfo.ChannelsBalanceMsat
|
||||
onchainBalance := nodeInfo.OnchainBalanceMsat
|
||||
}
|
||||
{{#include ../../snippets/go/getting_started.go:fetch-balance}}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -417,15 +255,7 @@ if nodeInfo, err := sdkServices.NodeInfo(); err != nil {
|
||||
<section>
|
||||
|
||||
```cs
|
||||
try
|
||||
{
|
||||
var nodeInfo = sdk.NodeInfo();
|
||||
var lnBalance = nodeInfo?.channelsBalanceMsat;
|
||||
var onchainBalance = nodeInfo?.onchainBalanceMsat;
|
||||
}
|
||||
catch (Exception) {
|
||||
// Handle error
|
||||
}
|
||||
{{#include ../../snippets/csharp/GettingStarted.cs:fetch-balance}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user