mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 05:44:20 +01:00
Merge branch 'main' into ok300-bump-sdk-dependency-version
# Conflicts: # .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:
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -25,8 +25,8 @@ jobs:
|
||||
name: setup
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
sdk-ref: ${{ inputs.sdk-ref || '7713e2db533dba7d0b6c013a59e1fa066e86ae4f' }}
|
||||
package-version: '0.2.14'
|
||||
sdk-ref: ${{ inputs.sdk-ref || '0.2.15' }}
|
||||
package-version: '0.2.15'
|
||||
steps:
|
||||
- run: echo "set pre-setup output variables"
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
4
snippets/rust/Cargo.lock
generated
4
snippets/rust/Cargo.lock
generated
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
- [Receiving an on-chain transaction](guide/receive_onchain.md)
|
||||
- [Sending an on-chain transaction](guide/send_onchain.md)
|
||||
|
||||
- [Using LNURL](guide/lnurl.md)
|
||||
- [LNURL-Pay](guide/lnurl_pay.md)
|
||||
- [LNURL-Withdraw](guide/lnurl_withdraw.md)
|
||||
- [LNURL-Auth](guide/lnurl_auth.md)
|
||||
- [Using LNURL & Lightning addresses](guide/lnurl.md)
|
||||
- [Sending payments using LNURL-Pay/Lightning address](guide/lnurl_pay.md)
|
||||
- [Receiving payments using LNURL-Pay/Lightning address](guide/lnurlpay.md)
|
||||
- [Receiving payments using LNURL-Withdraw](guide/lnurl_withdraw.md)
|
||||
- [Authenticating using LNURL-Auth](guide/lnurl_auth.md)
|
||||
- [Supporting fiat currencies](guide/fiat_currencies.md)
|
||||
- [Buying Bitcoin](guide/buy_btc.md)
|
||||
- [Exporting channels backup](guide/static_channel_backup.md)
|
||||
|
||||
@@ -93,7 +93,7 @@ Check https://github.com/breez/breez-sdk/releases for the latest version.
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
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" }
|
||||
```
|
||||
|
||||
## Flutter/Dart
|
||||
|
||||
91
src/guide/lnurlpay.md
Normal file
91
src/guide/lnurlpay.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# Receiving payments using LNURL-Pay
|
||||
|
||||
Breez SDK users have the ability to receive Lightning payments using [LNURL-Pay](https://github.com/lnurl/luds/blob/luds/06.md).
|
||||
|
||||
LNURL-Pay requires a web service that serves LNURL-Pay requests. This service needs to communicate with the user node in order to fetch the necessary metadata data and the associated payment request.
|
||||
To interact with the user node, the service uses a simple protocol over push notifications:
|
||||
* The service sends a push notification to the user's mobile app with the LNURL-Pay request and a reply URL.
|
||||
* The app responds to reply URL with the required data.
|
||||
* The data is forwarded from the service to the payer.
|
||||
|
||||
## General workflow
|
||||
The following workflow is application specific and the steps detailed below refer to the c-breez wallet implementation which requires running <b>[breez-lnurl](https://github.com/breez/breez-lnurl) </b>service.
|
||||
|
||||

|
||||
|
||||
### Step 1: Registering for an LNURL-Pay service
|
||||
Use a POST request to the service endpoint:
|
||||
|
||||
```
|
||||
https://app.domain/lnurlpay/[pubkey]
|
||||
```
|
||||
With the following payload:
|
||||
|
||||
```
|
||||
{
|
||||
"time": "seconds since epoch",
|
||||
"webhook_url": "notification service webhook url",
|
||||
"signature": "signed payload"
|
||||
}
|
||||
```
|
||||
|
||||
to register the app for an LNURL-Pay service.
|
||||
The signature is refers to the following string: ```[time]-[webhook_url]``` where ```time``` and ```webhook_url``` are the payload fields.
|
||||
|
||||
The service responds with following payload:
|
||||
```>
|
||||
{
|
||||
"lnurl": "https://app.domain.com/lnurlp/[pubkey]",
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2: Processing an LNURL-Pay request
|
||||
When an LNURL-Pay request is triggered a GET request to:
|
||||
```
|
||||
https://app.domain.com/lnurlp/[pubkey]
|
||||
```
|
||||
The service then sends a push notification to the app with the LNURL-Pay request and a callback URL. Such payload may look like the following:
|
||||
|
||||
```
|
||||
{
|
||||
"template": "lnurlpay_info",
|
||||
"data": {
|
||||
"reply_url": https://app.domain.com/respond/<request_id>
|
||||
"callback_url": https://app.domain.com/lnurlpay/invoice
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The <b>reply_url</b> is used by the app to respond to the lnurlpay request.
|
||||
The <b>callback_url</b> s the LNURL-Pay callback URL, used by the payer to fetch the invoice.
|
||||
|
||||
### Step 3: Responding to the callback url
|
||||
When the app receives the push notification, it parses the payload and then uses the reply_url to respond with the required data, for example:
|
||||
|
||||
```
|
||||
{
|
||||
"callback": "https://app.domain.com/lnurlpay/invoice",
|
||||
"maxSendable": 10000,
|
||||
"minSendable": 1000,
|
||||
"metadata": "[[\"text/plain\",\"Pay to Breez\"]]",
|
||||
"tag": "payRequest"
|
||||
}
|
||||
```
|
||||
|
||||
The service receives the response from the app and forwards it to the sender.
|
||||
|
||||
### Step 4: Fetching a bolt11 invoice
|
||||
|
||||
The sender fetchs a bolt11 invoice by invoking a GET request to the callback_url with adding a specific amount as a query parameter. For example:
|
||||
```
|
||||
https://app.domain.com/lnurlpay/invoice?amount=1000
|
||||
```
|
||||
An additional push notification is triggered to send the invoice request to the app. Then the app replied with the bolt11 invoice data.
|
||||
|
||||
### Step 5: Paying the invoice
|
||||
In the last step, the payer pays the received bolt11 invoice. Follow the steps [here](payment_notification.md) to receive payments via push notifications.
|
||||
|
||||
## Reference implementation
|
||||
For a complete reference implementation, see:
|
||||
* [Breez's NotificationService](https://github.com/breez/c-breez/blob/main/ios/Breez%20Notification%20Service%20Extension/NotificationService.swift)
|
||||
* [Breez's LNURL-Pay service](https://github.com/breez/breez-lnurl)
|
||||
@@ -67,3 +67,73 @@ They can even be spontaneous payments to a node without a bolt11 invoice.
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
|
||||
## Adding Extra TLVs to a Spontaneous Payment
|
||||
|
||||
A list of extra TLV data can also be sent with the sponaneous payment.
|
||||
|
||||
<custom-tabs category="lang">
|
||||
<div slot="title">Rust</div>
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
{{#include ../../snippets/rust/src/send_spontaneous_payment.rs:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Swift</div>
|
||||
<section>
|
||||
|
||||
```swift,ignore
|
||||
{{#include ../../snippets/swift/BreezSDKExamples/Sources/SendSpontaneous.swift:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Kotlin</div>
|
||||
<section>
|
||||
|
||||
```kotlin,ignore
|
||||
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/SendSpontaneousPayment.kt:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">React Native</div>
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
{{#include ../../snippets/react-native/send_spontaneous_payment.ts:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Dart</div>
|
||||
<section>
|
||||
|
||||
```dart,ignore
|
||||
{{#include ../../snippets/dart_snippets/lib/send_spontaneous_payment.dart:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Python</div>
|
||||
<section>
|
||||
|
||||
```python,ignore
|
||||
{{#include ../../snippets/python/src/send_spontaneous_payment.py:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Go</div>
|
||||
<section>
|
||||
|
||||
```go,ignore
|
||||
{{#include ../../snippets/go/send_spontaneous_payment.go:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">C#</div>
|
||||
<section>
|
||||
|
||||
```cs,ignore
|
||||
{{#include ../../snippets/csharp/SendSpontaneousPayment.cs:send-spontaneous-payment-with-tlvs}}
|
||||
```
|
||||
</section>
|
||||
</custom-tabs>
|
||||
|
||||
Reference in New Issue
Block a user