Merge branch 'main' into ok300-bump-sdk-dependency-version

# Conflicts:
#	.github/workflows/main.yml
#	snippets/go/go.mod
#	snippets/kotlin_mpp_lib/shared/build.gradle.kts
#	snippets/python/src/send_spontaneous_payment.py
#	snippets/react-native/yarn.lock
#	snippets/rust/Cargo.lock
#	snippets/rust/Cargo.toml
#	snippets/swift/BreezSDKExamples/Package.resolved
#	snippets/swift/BreezSDKExamples/Package.swift
#	src/guide/install.md
This commit is contained in:
ok300
2024-01-30 15:59:42 +01:00
25 changed files with 364 additions and 47 deletions

View File

@@ -1,4 +1,6 @@
using Breez.Sdk;
using System;
using System.Text;
public class SendSpontaneousPaymentSnippets
{
@@ -17,5 +19,26 @@ public class SendSpontaneousPaymentSnippets
// Handle error
}
// ANCHOR_END: send-spontaneous-payment
}
public void SendSpontaneousPaymentWithTlvs(BlockingBreezServices sdk)
{
// ANCHOR: send-spontaneous-payment-with-tlvs
var nodeId = "...";
ulong amountMsat = 3_000_000;
var extraTlvs = new List<TlvEntry>{
new TlvEntry(34349334, Encoding.ASCII.GetBytes("Hello world!").ToList())
};
try
{
var response = sdk.SendSpontaneousPayment(
new SendSpontaneousPaymentRequest(nodeId, amountMsat, extraTlvs));
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: send-spontaneous-payment-with-tlvs
}
}

View File

@@ -1,5 +1,6 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:breez_sdk/bridge_generated.dart';
import 'dart:convert';
Future<SendPaymentResponse> sendSpontaneousPayment({
required String nodeId,
@@ -13,3 +14,23 @@ Future<SendPaymentResponse> sendSpontaneousPayment({
// ANCHOR_END: send-spontaneous-payment
return resp;
}
Future<SendPaymentResponse> sendSpontaneousPaymentWithTlvs({
required String nodeId,
}) async {
// ANCHOR: send-spontaneous-payment-with-tlvs
List<TlvEntry> extraTlvs = [
TlvEntry(
fieldNumber: 34349334,
value: utf8.encode("Hello world!"),
)
];
SendSpontaneousPaymentRequest req = SendSpontaneousPaymentRequest(
amountMsat: 3000000,
nodeId: nodeId,
extraTlvs: extraTlvs,
);
SendPaymentResponse resp = await BreezSDK().sendSpontaneousPayment(req: req);
// ANCHOR_END: send-spontaneous-payment-with-tlvs
return resp;
}

View File

@@ -2,6 +2,6 @@ module main
go 1.19
require github.com/breez/breez-sdk-go v0.2.14
require github.com/breez/breez-sdk-go v0.2.15
replace github.com/breez/breez-sdk-go => ./packages/breez-sdk-go

View File

@@ -1,6 +1,7 @@
package example
import (
"encoding/hex"
"log"
"github.com/breez/breez-sdk-go/breez_sdk"
@@ -17,3 +18,22 @@ func SendSpontaneousPayment() {
}
// ANCHOR_END: send-spontaneous-payment
}
func SendSpontaneousPaymentWithTlvs() {
// ANCHOR: send-spontaneous-payment-with-tlvs
value, _ := hex.DecodeString("Hello world!")
extraTlvs := []breez_sdk.TlvEntry{
breez_sdk.TlvEntry{
FieldNumber: uint64(34349334),
Value: value,
},
}
sendSpontaneousPaymentRequest := breez_sdk.SendSpontaneousPaymentRequest{
NodeId: "...",
AmountMsat: uint64(3_000_000),
ExtraTlvs: &extraTlvs,
}
if response, err := sdk.SendSpontaneousPayment(sendSpontaneousPaymentRequest); err == nil {
log.Printf("%#v", response)
}
// ANCHOR_END: send-spontaneous-payment-with-tlvs
}

View File

@@ -34,7 +34,7 @@ kotlin {
}
val commonMain by getting {
dependencies {
implementation("technology.breez:breez-sdk-kmp:0.2.14")
implementation("technology.breez:breez-sdk-kmp:0.2.15")
}
}
}

View File

@@ -14,4 +14,20 @@ class SendSpontaneousPayment {
}
// ANCHOR_END: send-spontaneous-payment
}
fun send_spontaneous_payment_with_tlvs(sdk: BlockingBreezServices) {
// ANCHOR: send-spontaneous-payment-with-tlvs
val nodeId = "..."
val amountMsat = 3_000_000.toULong()
val extraTlvs = listOf<TlvEntry>(
TlvEntry(34_349_334.toULong(), "Hello world!".encodeToByteArray().asUByteArray().toList())
)
try {
val response = sdk.sendSpontaneousPayment(
SendSpontaneousPaymentRequest(nodeId, amountMsat, extraTlvs))
} catch (e: Exception) {
// handle error
}
// ANCHOR_END: send-spontaneous-payment-with-tlvs
}
}

View File

@@ -7,7 +7,7 @@ from src.connecting_lsp import get_lsp_info, connect_lsp
from src.buy_btc import buy
from src.send_onchain import get_current_fees, list_current_fees, check_reverse_swap_status, start_reverse_swap
from src.static_channel_backup import retrieve_backup_files
from src.send_spontaneous_payment import send_spontaneous_payment
from src.send_spontaneous_payment import send_spontaneous_payment, send_spontaneous_payment_with_tlvs
from src.receive_payment import receive_payment
from src.receive_onchain import generate_receive_onchain_address, get_in_progress_swap, list_refundables, execute_refund, get_channel_opening_fees
from src.fiat_currencies import list_supported_fiat_currencies, get_current_rates
@@ -73,6 +73,7 @@ def main():
#send spontaneous payment
send_spontaneous_payment(sdk_services)
send_spontaneous_payment_with_tlvs(sdk_services)
# fiat currencies
list_supported_fiat_currencies(sdk_services)

View File

@@ -3,14 +3,28 @@ import breez_sdk
def send_spontaneous_payment(sdk_services):
# ANCHOR: send-spontaneous-payment
node_id = "..."
amount_msat = 300000
try:
# ANCHOR: send-spontaneous-payment
node_id = "..."
amount_msat = 3000000
req = breez_sdk.SendSpontaneousPaymentRequest(node_id,amount_msat)
req = breez_sdk.SendSpontaneousPaymentRequest(node_id, amount_msat)
result = sdk_services.send_spontaneous_payment(req)
# ANCHOR_END: send-spontaneous-payment
# ANCHOR: send-spontaneous-payment
return result
except Exception as error:
print(error)
raise
def send_spontaneous_payment_with_tlvs(sdk_services):
# ANCHOR: send-spontaneous-payment-with-tlvs
node_id = "..."
amount_msat = 300000
extra_tlvs = [breez_sdk.TlvEntry(34349334, str.encode("Hello world!"))]
try:
req = breez_sdk.SendSpontaneousPaymentRequest(node_id, amount_msat, extra_tlvs)
result = sdk_services.send_spontaneous_payment(req)
# ANCHOR: send-spontaneous-payment-with-tlvs
return result
except Exception as error:
print(error)

View File

@@ -1,4 +1,7 @@
import { sendSpontaneousPayment } from '@breeztech/react-native-breez-sdk'
import {
sendSpontaneousPayment,
type TlvEntry
} from '@breeztech/react-native-breez-sdk'
const exampleSendSpontaneousPayment = async () => {
// ANCHOR: send-spontaneous-payment
@@ -10,3 +13,26 @@ const exampleSendSpontaneousPayment = async () => {
})
// ANCHOR_END: send-spontaneous-payment
}
const stringToBytes = (str: string): number[] => {
const bytes: number[] = []
for (let i = 0; i < str.length; ++i) {
bytes.push(str.charCodeAt(i))
}
return bytes
}
const exampleSendSpontaneousPaymentWithTlvs = async () => {
// ANCHOR: send-spontaneous-payment-with-tlvs
const nodeId = '...'
const extraTlvs: TlvEntry[] = [
{ fieldNumber: 34349334, value: stringToBytes('Hello world!') }
]
const sendPaymentResponse = await sendSpontaneousPayment({
nodeId,
amountMsat: 3000000,
extraTlvs
})
// ANCHOR_END: send-spontaneous-payment-with-tlvs
}

View File

@@ -714,10 +714,10 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"
"@breeztech/react-native-breez-sdk@0.2.14":
version "0.2.14"
resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk/-/react-native-breez-sdk-0.2.14.tgz#1e9472bf4ad694be788036a6c40d90e90558b816"
integrity sha512-Z2gIr9VpkPh7bV1mmJreateYzrXWHvqiA8TZ1phxOo7B1HRuTT890jsOHIk1dRt0vmb3lKaQN0swSej5J94UtA==
"@breeztech/react-native-breez-sdk@0.2.15":
version "0.2.15"
resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk/-/react-native-breez-sdk-0.2.15.tgz#0a415747e94b08f0dbbca8aae23f2d4231881db3"
integrity sha512-VxT4wdZCyDrhZBe6heHJKUJc1nbVJ4Y0qbOm1B+LJa6JOq0YDooUFnbtHMq1PHQ3xviwuM1pCzAco0orWqnvDA==
"@esbuild/android-arm64@0.18.20":
version "0.18.20"

View File

@@ -460,8 +460,8 @@ dependencies = [
[[package]]
name = "breez-sdk-core"
version = "0.2.14"
source = "git+https://github.com/breez/breez-sdk?tag=0.2.14#cc7ec482d8e9ebfb47a9e6be7329cc155f3a8e12"
version = "0.2.15"
source = "git+https://github.com/breez/breez-sdk?tag=0.2.15#5486f167e046d28b0a3f9885b4bf9c44cd3e1ba8"
dependencies = [
"aes",
"anyhow",

View File

@@ -6,6 +6,6 @@ edition = "2021"
[dependencies]
anyhow = "1"
bip39 = { version = "2", features = ["rand"] }
breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.2.14" }
breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.2.15" }
log = "0.4"
tokio = "1.29"

View File

@@ -1,14 +1,13 @@
use anyhow::Result;
use breez_sdk_core::*;
fn production_node_config() -> Result<NodeConfig> {
// ANCHOR: moving-to-production
// Read your Greenlight credentials from secure storage
let device_key: Vec<u8> = vec![];
let device_cert: Vec<u8> = vec![];
let greenlight_credentials = GreenlightCredentials {
device_key,
device_key,
device_cert,
};

View File

@@ -12,8 +12,14 @@ async fn generate_receive_onchain_address(sdk: Arc<BreezServices>) -> Result<()>
// Send your funds to the below bitcoin address
let address = swap_info.bitcoin_address;
info!("Minimum amount allowed to deposit in sats: {}", swap_info.min_allowed_deposit);
info!("Maximum amount allowed to deposit in sats: {}", swap_info.max_allowed_deposit);
info!(
"Minimum amount allowed to deposit in sats: {}",
swap_info.min_allowed_deposit
);
info!(
"Maximum amount allowed to deposit in sats: {}",
swap_info.max_allowed_deposit
);
// ANCHOR_END: generate-receive-onchain-address
Ok(())

View File

@@ -32,14 +32,9 @@ async fn list_current_fees(current_fees: ReverseSwapPairInfo) -> Result<()> {
async fn max_reverse_swap_amount(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: max-reverse-swap-amount
let max_amount = sdk
.max_reverse_swap_amount()
.await?;
let max_amount = sdk.max_reverse_swap_amount().await?;
info!(
"Max reverse swap amount: {:?}",
max_amount.total_sat
);
info!("Max reverse swap amount: {:?}", max_amount.total_sat);
// ANCHOR_END: max-reverse-swap-amount
Ok(())

View File

@@ -17,3 +17,22 @@ async fn send_spontaneous_payment(sdk: Arc<BreezServices>) -> Result<()> {
Ok(())
}
async fn send_spontaneous_payment_with_tlvs(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: send-spontaneous-payment-with-tlvs
let node_id = "...".into();
let extra_tlvs = vec![TlvEntry {
field_number: 34349334,
value: "Hello world!".as_bytes().to_vec(),
}];
sdk.send_spontaneous_payment(SendSpontaneousPaymentRequest {
amount_msat: 3_000_000,
node_id,
extra_tlvs: Some(extra_tlvs),
})
.await?;
// ANCHOR_END: send-spontaneous-payment-with-tlvs
Ok(())
}

View File

@@ -1,19 +1,23 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
use std::sync::Arc;
async fn webhook(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: register-webook
sdk.register_webhook("https://yourapplication.com".to_string()).await?;
sdk.register_webhook("https://yourapplication.com".to_string())
.await?;
// ANCHOR_END: register-webook
Ok(())
}
async fn payment_webhook(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: register-payment-webook
sdk.register_webhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>".to_string()).await?;
// ANCHOR_END: register-payment-webook
// ANCHOR: register-payment-webook
sdk.register_webhook(
"https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>".to_string(),
)
.await?;
// ANCHOR_END: register-payment-webook
Ok(())
Ok(())
}

View File

@@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/breez/breez-sdk-swift",
"state" : {
"revision" : "756730450bcd7e82d89930a4fa24412059b93274",
"version" : "0.2.14"
"revision" : "73c7bf88ce51471f4a6313aa583fa1a5394442f7",
"version" : "0.2.15"
}
},
{

View File

@@ -5,10 +5,10 @@ import PackageDescription
let package = Package(
name: "BreezSDKDocs",
platforms: [.macOS(.v13)],
platforms: [.macOS(.v12)],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"),
.package(url: "https://github.com/breez/breez-sdk-swift", from:"0.2.14")
.package(url: "https://github.com/breez/breez-sdk-swift", from:"0.2.15")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.

View File

@@ -16,6 +16,17 @@ func sendSpontaneousPayment(sdk: BlockingBreezServices) -> SendPaymentResponse?
nodeId: "...",
amountMsat: 3_000_000))
// ANCHOR_END: send-spontaneous-payment
return response
return response
}
func sendSpontaneousPaymentWithTlvs(sdk: BlockingBreezServices) -> SendPaymentResponse? {
// ANCHOR: send-spontaneous-payment-with-tlvs
let extraTlvs = [TlvEntry(fieldNumber: 34_349_334, value: Array("Hello world!".utf8))]
let response = try? sdk.sendSpontaneousPayment(
req: SendSpontaneousPaymentRequest(
nodeId: "...",
amountMsat: 3_000_000,
extraTlvs: extraTlvs))
// ANCHOR_END: send-spontaneous-payment-with-tlvs
return response
}