Skip to content

Commit

Permalink
Merge pull request #151 from breez/savage-unregister-webhook
Browse files Browse the repository at this point in the history
Unregister webhook
  • Loading branch information
dangeross authored May 17, 2024
2 parents 35e6410 + ea955cf commit 3ace4c3
Show file tree
Hide file tree
Showing 24 changed files with 228 additions and 88 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
name: setup
runs-on: ubuntu-latest
outputs:
sdk-ref: ${{ inputs.sdk-ref || '0.4.0' }}
package-version: '0.4.0'
sdk-ref: ${{ inputs.sdk-ref || 'd658f85c7c349bd7ed96c05c3d008b7b75e6273a' }}
package-version: '0.4.1'
steps:
- run: echo "set pre-setup output variables"

Expand Down
14 changes: 7 additions & 7 deletions snippets/csharp/Webhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

public class ServiceStatusSnippets
{
public void Webhook(BlockingBreezServices sdk)
public void RegisterWebhook(BlockingBreezServices sdk)
{
// ANCHOR: register-webook
try
{
sdk.RegisterWebhook("https://yourapplication.com");
sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: register-webook
}

public void PaymentWebhook(BlockingBreezServices sdk)
public void UnregisterWebhook(BlockingBreezServices sdk)
{
// ANCHOR: register-payment-webook
// ANCHOR: unregister-webook
try
{
sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
sdk.UnregisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: register-payment-webook
// ANCHOR_END: unregister-webook
}
}
12 changes: 6 additions & 6 deletions snippets/dart_snippets/lib/webhook.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:breez_sdk/breez_sdk.dart';

Future<void> webhook() async {
Future<void> registerWebhook() async {
// ANCHOR: register-webook
await BreezSDK().registerWebhook(webhookUrl: "https://yourapplication.com");
await BreezSDK().registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
// ANCHOR_END: register-webook
}

Future<void> paymentWebhook({required String paymentHash}) async {
// ANCHOR: register-payment-webook
await BreezSDK().registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
// ANCHOR_END: register-payment-webook
Future<void> unregisterWebhook() async {
// ANCHOR: unregister-webook
await BreezSDK().unregisterWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
// ANCHOR_END: unregister-webook
}
2 changes: 1 addition & 1 deletion snippets/dart_snippets/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ packages:
path: "packages/breez-sdk-flutter"
relative: true
source: path
version: "0.4.0"
version: "0.4.1"
build:
dependency: transitive
description:
Expand Down
16 changes: 8 additions & 8 deletions snippets/go/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import (
"log"
)

func Webhook() {
func RegisterWebhook() {
// ANCHOR: register-webook
if err := sdk.RegisterWebhook("https://yourapplication.com"); err != nil {
log.Printf("Webhook registration failed: %v", err)
if err := sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>"); err != nil {
log.Printf("Webhook register failed: %v", err)
}
// ANCHOR_END: register-webook
}

func PaymentWebhook() {
// ANCHOR: register-payment-webook
if err := sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>"); err != nil {
log.Printf("Webhook registration failed: %v", err)
func UnregisterWebhook() {
// ANCHOR: unregister-webook
if err := sdk.UnregisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>"); err != nil {
log.Printf("Webhook unregister failed: %v", err)
}
// ANCHOR_END: register-payment-webook
// ANCHOR_END: unregister-webook
}
2 changes: 1 addition & 1 deletion snippets/kotlin_mpp_lib/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ kotlin {
}
val commonMain by getting {
dependencies {
implementation("technology.breez:breez-sdk-kmp:0.4.0")
implementation("technology.breez:breez-sdk-kmp:0.4.1")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ package com.example.kotlinmpplib

import breez_sdk.*
class Webhooks {
fun webhook(sdk: BlockingBreezServices) {
fun registerWebhook(sdk: BlockingBreezServices) {
// ANCHOR: register-webook
try {
sdk.registerWebhook("https://yourapplication.com")
sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
} catch (e: Exception) {
// Handle error
}
// ANCHOR_END: register-webook
}

fun paymentWebhook(sdk: BlockingBreezServices) {
// ANCHOR: register-payment-webook
fun unregisterWebhook(sdk: BlockingBreezServices) {
// ANCHOR: unregister-webook
try {
sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
sdk.unregisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
} catch (e: Exception) {
// Handle error
}
// ANCHOR_END: register-payment-webook
// ANCHOR_END: unregister-webook
}
}
14 changes: 7 additions & 7 deletions snippets/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from src.getting_started import getting_started,getting_started_node_info
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.pay_onchain import get_current_limits, prepare_pay_onchain, 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, send_spontaneous_payment_with_tlvs
from src.receive_payment import receive_payment
Expand All @@ -16,7 +16,7 @@
from src.lnurl_withdraw import withdraw
from src.production import production_node_config
from src.service_status import health_check_status, report_payment_failure
from src.webhook import webhook, payment_webhook
from src.webhook import register_webhook, unregister_webhook
import tempfile
import os

Expand Down Expand Up @@ -48,10 +48,10 @@ def main():
buy(sdk_services)

# send onchain
current_fees = get_current_fees(sdk_services)
list_current_fees(current_fees)
current_limits = get_current_limits(sdk_services)
prepare_res = prepare_pay_onchain(sdk_services, current_limits, 7)
check_reverse_swap_status(sdk_services)
start_reverse_swap(sdk_services,current_fees, 7)
start_reverse_swap(sdk_services, prepare_res)

# static backup
temp_dir2 = tempfile.TemporaryDirectory()
Expand All @@ -61,8 +61,8 @@ def main():
receive_payment(sdk_services)

# payment notifications
webhook(sdk_services)
payment_webhook(sdk_services)
register_webhook(sdk_services)
unregister_webhook(sdk_services)

# receive onchain
generate_receive_onchain_address(sdk_services)
Expand Down
16 changes: 8 additions & 8 deletions snippets/python/src/webhook.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import breez_sdk

def webhook(sdk_services):
try:
def register_webhook(sdk_services):
try:
# ANCHOR: register-webook
sdk_services.register_webhook("https://yourapplication.com")
sdk_services.register_webhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
# ANCHOR_END: register-webook
except Exception as error:
except Exception as error:
print(error)
raise

def payment_webhook(sdk_services):
def unregister_webhook(sdk_services):
try:
# ANCHOR: register-payment-webook
sdk_services.register_webhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
# ANCHOR_END: register-payment-webook
# ANCHOR: unregister-webook
sdk_services.unregister_webhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
# ANCHOR_END: unregister-webook
except Exception as error:
print(error)
raise
14 changes: 7 additions & 7 deletions snippets/react-native/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { registerWebhook } from '@breeztech/react-native-breez-sdk'
import { registerWebhook, unregisterWebhook } from '@breeztech/react-native-breez-sdk'

const webhook = async () => {
const _registerWebhook = async () => {
// ANCHOR: register-webook
try {
await registerWebhook('https://yourapplication.com')
await registerWebhook('https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>')
} catch (err) {
console.error(err)
}
// ANCHOR_END: register-webook
}

const paymentWebhook = async () => {
// ANCHOR: register-payment-webook
const _unregisterWebhook = async () => {
// ANCHOR: unregister-webook
try {
await registerWebhook('https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>')
await unregisterWebhook('https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>')
} catch (err) {
console.error(err)
}
// ANCHOR_END: register-payment-webook
// ANCHOR_END: unregister-webook
}
5 changes: 0 additions & 5 deletions snippets/react-native/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,6 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"

"@breeztech/[email protected]":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk/-/react-native-breez-sdk-0.4.0.tgz#986136d9414ff9fb5d67c1b005b966c0b4440637"
integrity sha512-9OGmYUIxfhFUTbvnRXKG551xM77bAW4Fb4SgKa7KieFI3oytFR5xPl3OHU1baUqAUqB86QEAVxljYMA+YUR4gA==

"@esbuild/[email protected]":
version "0.18.20"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz#984b4f9c8d0377443cc2dfcef266d02244593622"
Expand Down
4 changes: 2 additions & 2 deletions snippets/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion snippets/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.0" }
breez-sdk-core = { git = "https://github.com/breez/breez-sdk", rev = "d658f85c7c349bd7ed96c05c3d008b7b75e6273a" }
log = "0.4"
tokio = "1.29"
10 changes: 5 additions & 5 deletions snippets/rust/src/receive_onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ async fn get_channel_opening_fees(sdk: Arc<BreezServices>, amount_msat: Option<u
}

async fn rescan_swaps(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: rescan-swaps
sdk.rescan_swaps().await?;
// ANCHOR_END: rescan-swaps
// ANCHOR: rescan-swaps
sdk.rescan_swaps().await?;
// ANCHOR_END: rescan-swaps

Ok(())
}
Ok(())
}
2 changes: 1 addition & 1 deletion snippets/rust/src/send_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async fn send_payment(sdk: Arc<BreezServices>) -> Result<()> {
let req = SendPaymentRequest {
bolt11: "...".into(),
amount_msat: optional_amount_msat,
label: optional_label
label: optional_label,
};
let response = sdk.send_payment(req).await?;
// ANCHOR_END: send-payment
Expand Down
16 changes: 9 additions & 7 deletions snippets/rust/src/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ use anyhow::Result;
use breez_sdk_core::*;
use std::sync::Arc;

async fn webhook(sdk: Arc<BreezServices>) -> Result<()> {
async fn register_webhook(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: register-webook
sdk.register_webhook("https://yourapplication.com".to_string())
.await?;
sdk.register_webhook(
"https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>".to_string(),
)
.await?;
// ANCHOR_END: register-webook

Ok(())
}

async fn payment_webhook(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: register-payment-webook
sdk.register_webhook(
async fn unregister_webhook(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: unregister-webook
sdk.unregister_webhook(
"https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>".to_string(),
)
.await?;
// ANCHOR_END: register-payment-webook
// ANCHOR_END: unregister-webook

Ok(())
}
4 changes: 2 additions & 2 deletions snippets/swift/BreezSDKExamples/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/breez/breez-sdk-swift",
"state" : {
"revision" : "687a6a0c50ac966e55fbc24c2a717e484bb0d962",
"version" : "0.4.0"
"revision" : "89c41a72006d03c05b3072d1d20c41eed6784e06",
"version" : "0.4.1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion snippets/swift/BreezSDKExamples/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
platforms: [.macOS(.v13)],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"),
.package(url: "https://github.com/breez/breez-sdk-swift", from: "0.4.0")
.package(url: "https://github.com/breez/breez-sdk-swift", from: "0.4.1")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
14 changes: 7 additions & 7 deletions snippets/swift/BreezSDKExamples/Sources/Webhook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import Foundation
import BreezSDK

func webhook(sdk: BlockingBreezServices) throws {
func registerWebhook(sdk: BlockingBreezServices) throws {
// ANCHOR: register-webook
try sdk.registerWebhook(webhookUrl: "https://yourapplication.com")
// ANCHOR_END: register-webook
try sdk.registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
// ANCHOR_END: register-webook
}

func paymentWebhook(sdk: BlockingBreezServices) throws {
// ANCHOR: register-payment-webook
try sdk.registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
// ANCHOR_END: register-payment-webook
func unregisterWebhook(sdk: BlockingBreezServices) throws {
// ANCHOR: unregister-webook
try sdk.unregisterWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
// ANCHOR_END: unregister-webook
}
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

- [Implementing mobile notifications](notifications/getting_started.md)
- [Setting up an NDS](notifications/setup_nds.md)
- [Registering a webhook](notifications/register_webhook.md)
- [Using webhooks](notifications/using_webhooks.md)
- [Integrating the plugin](notifications/setup_plugin.md)
- [Android](notifications/android_setup.md)
- [Setting up the Foreground Service](notifications/android_service.md)
Expand Down
2 changes: 1 addition & 1 deletion src/guide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.0" }
breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.4.1" }
```

## Flutter/Dart
Expand Down
Loading

0 comments on commit 3ace4c3

Please sign in to comment.