Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.4.0 docs #161

Merged
merged 48 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
65815d5
Replace `fetchReverseSwapFees` with `onchainPaymentLimits` (#139)
ok300 Mar 13, 2024
0a16679
Adapt serviceHealthCheck usage
dangeross Mar 13, 2024
939b543
Fix dart snippet
dangeross Mar 13, 2024
8e75662
Merge branch 'pre-release' into savage-static-health-check
dangeross Mar 13, 2024
d92f5e1
Fix RN snippet
dangeross Mar 13, 2024
3bbb393
Add `prepareOnchainPayment` snippets (#141)
ok300 Mar 14, 2024
7e53fb8
Merge pull request #143 from breez/savage-static-health-check
dangeross Mar 14, 2024
0886787
Consolidate send-all snippet (#142)
ok300 Mar 15, 2024
3c655c1
Replace `send_onchain` snippets with `pay_onchain` (#144)
ok300 Mar 15, 2024
278fb4c
Rename send_onchain snippets to pay_onchain (#146)
ok300 Mar 16, 2024
894a487
Replace in_progress_reverse_swaps snippets with v2 version (#148)
ok300 Mar 21, 2024
e743521
Add docs for iOS implementation of the notification plugin
dangeross Mar 26, 2024
4647cab
Add advanced Android notification plugin docs
dangeross Mar 27, 2024
6213ebb
Add Android notification plugin setup
dangeross Mar 27, 2024
2e19b2a
Remove empty file
dangeross Mar 27, 2024
e553d1c
Register additional notification group/channel in example
dangeross Mar 27, 2024
b4ec95b
Merge branch 'main' into pre-release
dangeross Mar 28, 2024
ed2b4ed
Merge branch 'pre-release' into savage-notification-plugin
dangeross Mar 28, 2024
aac93f6
Change the job finishing call
dangeross Mar 28, 2024
3c3b1fd
Apply suggestions from code review
dangeross Mar 28, 2024
fef0ff7
Add hidden links for previously shared urls, link to breez-sdk-swift …
dangeross Mar 28, 2024
553c500
Fix the NotificationService name
dangeross Mar 29, 2024
989e6b6
Add descriptions of handled notification types
dangeross Apr 4, 2024
ab0fcf3
Add optional payment label to snippets
dangeross Apr 11, 2024
ea84b46
Revert default sdk-ref
dangeross Apr 11, 2024
374054d
Remove newline in README.md
ok300 Apr 11, 2024
b29ccfe
Add CI steps for pre-release branch (#153)
ok300 Apr 11, 2024
38911fb
Merge pull request #150 from breez/savage-notification-plugin
dangeross Apr 11, 2024
458cc6e
Fix the android ForegroundService implementation
dangeross Apr 12, 2024
253aeed
import RN rescanSwaps
dangeross Apr 12, 2024
4636439
Merge pull request #154 from breez/savage-fix-android-impl
dangeross Apr 13, 2024
a342474
Update csharp syntax
dangeross Apr 13, 2024
b62e29d
Update swift syntax
dangeross Apr 13, 2024
20155f8
Merge pull request #152 from breez/savage-payment-label
dangeross Apr 13, 2024
42c4412
Address feedback
dangeross Apr 13, 2024
dd6fffa
Update LNURL response text
dangeross Apr 14, 2024
9cfe48d
Add onShutdown to the Kotlin custom notification example
dangeross Apr 14, 2024
51599c7
[pre-release] Bump SDK dependency to 0.4.0-rc1 (#155)
ok300 Apr 15, 2024
c0e869b
Merge pull request #156 from breez/savage-notification-feedback
dangeross Apr 15, 2024
0861e17
Change Logging title
dangeross Apr 15, 2024
d5d0be2
Add "receive payment" snippets for channel opening fees (#122)
ok300 Apr 30, 2024
13ab8d3
Update wording in Fees section title
ok300 Apr 30, 2024
e98cc6f
allow prerelease C# packages
JssDWt May 3, 2024
4ba3d51
Merge branch 'jssdwt-csharp-prerelease' into pre-release
JssDWt May 3, 2024
dc8e183
Clarify when to register a webhook URL
dangeross May 3, 2024
9015433
Merge pull request #160 from breez/savage-clarify-webhook-registration
dangeross May 3, 2024
d38f9f3
Update to 0.4.0
dangeross May 6, 2024
35e6410
Merge pull request #162 from breez/savage-bump-version
dangeross May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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 || '474ac7d4b5d19633dc851439b9ff7e159286fbd8' }}
package-version: '0.3.1'
sdk-ref: ${{ inputs.sdk-ref || '0.4.0-rc5' }}
package-version: '0.4.0-rc5'
steps:
- run: echo "set pre-setup output variables"

Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
- name: Add nuget dependency
working-directory: snippets/csharp
run: |
dotnet add package Breez.Sdk -s ./packages
dotnet add package Breez.Sdk -s ./packages --prerelease

- name: Build the csharp project
working-directory: snippets/csharp
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

The SDK docs are live at [https://sdk-doc.breez.technology](https://sdk-doc.breez.technology).


## Contributions

For syntax and supported features, see [https://rust-lang.github.io/mdBook](https://rust-lang.github.io/mdBook).
Expand Down
83 changes: 83 additions & 0 deletions snippets/csharp/CommunicatingFees.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Breez.Sdk;

public class CommunicatingFeesSnippets
{
public void getFeeInfoBeforeInvoiceCreated(BlockingBreezServices sdk)
{
// ANCHOR: get-fee-info-before-receiving-payment
try
{
var nodeInfo = sdk.NodeInfo();

var inboundLiquiditySat = nodeInfo?.inboundLiquidityMsats / 1_000;

var openingFeeResponse = sdk.OpenChannelFee(new OpenChannelFeeRequest(null));
var openingFees = openingFeeResponse?.feeParams;
if (openingFees != null)
{
var feePercentage = (openingFees.proportional * 100) / 1_000_000.0;
var minFeeSat = openingFees.minMsat / 1_000;

if (inboundLiquiditySat == 0)
{
Console.WriteLine(
$"A setup fee of {feePercentage}% with a minimum of {minFeeSat} sats will be applied."
);
}
else
{
Console.WriteLine(
$"A setup fee of {feePercentage}% with a minimum of {minFeeSat} sats will be applied " +
$"for receiving more than {inboundLiquiditySat} sats."
);
}
}
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: get-fee-info-before-receiving-payment
}

public void GetFeeInfoAfterInvoiceCreated(ReceivePaymentResponse receivePaymentResponse)
{
// ANCHOR: get-fee-info-after-invoice-created
var openingFeeSat = receivePaymentResponse.openingFeeMsat.GetValueOrDefault() / 1000;
Console.WriteLine($"A setup fee of {openingFeeSat} sats is applied to this invoice.");
// ANCHOR_END: get-fee-info-after-invoice-created
}

public void getFeeInfoReceiveOnchain(BlockingBreezServices sdk)
{
// ANCHOR: get-fee-info-receive-onchain
try
{
var swapInfo = sdk.ReceiveOnchain(new ReceiveOnchainRequest());

var minDepositSat = swapInfo?.minAllowedDeposit;
var maxDepositSat = swapInfo?.maxAllowedDeposit;

var nodeInfo = sdk.NodeInfo();
var inboundLiquiditySat = nodeInfo?.inboundLiquidityMsats / 1_000;

var swapOpeningFees = swapInfo?.channelOpeningFees;
if (swapOpeningFees != null)
{
var feePercentage = (swapOpeningFees.proportional * 100) / 1_000_000.0;
var minFeeSat = swapOpeningFees.minMsat / 1_000;

Console.WriteLine(
$"Send more than {minDepositSat} sats and up to {maxDepositSat} sats to this address. " +
$"A setup fee of {feePercentage}% with a minimum of {minFeeSat} sats will be applied " +
$"for sending more than {inboundLiquiditySat} sats. This address can only be used once."
);
}
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: get-fee-info-receive-onchain
}
}
6 changes: 4 additions & 2 deletions snippets/csharp/LnurlPay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public void LnurlPay(BlockingBreezServices sdk)
if (input is InputType.LnUrlPay lnurlp)
{
var amountMsat = lnurlp.data.minSendable;
var result = sdk.PayLnurl(
new LnUrlPayRequest(lnurlp.data, amountMsat, "comment"));
var optionalComment = "<comment>";
var optionalPaymentLabel = "<label>";
var req = new LnUrlPayRequest(lnurlp.data, amountMsat, optionalComment, optionalPaymentLabel);
var result = sdk.PayLnurl(req);
}
}
catch (Exception)
Expand Down
57 changes: 25 additions & 32 deletions snippets/csharp/SendOnchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,55 @@

public class SendOnchainSnippets
{
public void GetCurrentFees(BlockingBreezServices sdk)
public void GetCurrentLimits(BlockingBreezServices sdk)
{
// ANCHOR: estimate-current-reverse-swap-total-fees
// ANCHOR: get-current-reverse-swap-limits
try
{
var currentFees = sdk.FetchReverseSwapFees(
new ReverseSwapFeesRequest(50000));
Console.WriteLine(
$"Total estimated fees for reverse " +
$"swap: {currentFees.totalFees}");
var currentLimits = sdk.OnchainPaymentLimits();
Console.WriteLine($"Minimum amount, in sats: {currentLimits.minSat}");
Console.WriteLine($"Maximum amount, in sats: {currentLimits.maxSat}");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: estimate-current-reverse-swap-total-fees
// ANCHOR_END: get-current-reverse-swap-limits
}

public void ListCurrentFees(BlockingBreezServices sdk, ReverseSwapPairInfo currentFees)
public void PreparePayOnchain(BlockingBreezServices sdk, OnchainPaymentLimitsResponse currentLimits, uint feeRate)
{
// 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
}
// ANCHOR: prepare-pay-onchain
var amountSat = currentLimits.minSat;
var claimTxFeerate = feeRate;

public void MaxReverseSwapAmount(BlockingBreezServices sdk)
{
// ANCHOR: max-reverse-swap-amount
try
{
var maxAmountResponse = sdk.MaxReverseSwapAmount();
Console.WriteLine(
$"Max reverse swap amount {maxAmountResponse.totalSat}");
var prepareRes = sdk.PrepareOnchainPayment(
new PrepareOnchainPaymentRequest(
amountSat,
SwapAmountType.SEND,
claimTxFeerate));

Console.WriteLine($"Sender amount, in sats: {prepareRes.senderAmountSat}");
Console.WriteLine($"Recipient amount, in sats: {prepareRes.recipientAmountSat}");
Console.WriteLine($"Total fees, in sats: {prepareRes.totalFees}");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: max-reverse-swap-amount
// ANCHOR_END: prepare-pay-onchain
}

public void StartReverseSwap(BlockingBreezServices sdk, ReverseSwapPairInfo currentFees, uint feeRate)
public void StartReverseSwap(BlockingBreezServices sdk, PrepareOnchainPaymentResponse prepareRes)
{
// 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));
var reverseSwapInfo = sdk.PayOnchain(
new PayOnchainRequest(destinationAddress, prepareRes));
}
catch (Exception)
{
Expand All @@ -71,11 +64,11 @@ public void CheckReverseSwapStatus(BlockingBreezServices sdk)
// ANCHOR: check-reverse-swaps-status
try
{
var swaps = sdk.InProgressReverseSwaps();
var swaps = sdk.InProgressOnchainPayments();
foreach (var swap in swaps)
{
Console.WriteLine(
$"Reverse swap {swap.id} in progress, " +
$"Onchain payment {swap.id} in progress, " +
$"status is {swap.status}`");
}
}
Expand Down
7 changes: 4 additions & 3 deletions snippets/csharp/SendPayment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ public void SendPayment(BlockingBreezServices sdk)
{
// ANCHOR: send-payment
var bolt11 = "...";
ulong amountMsat = 3_000_000;

ulong optionalAmountMsat = 3_000_000;
var optionalLabel = "<label>";

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));
new SendPaymentRequest(bolt11, optionalAmountMsat, optionalLabel));
}
catch (Exception)
{
Expand Down
8 changes: 5 additions & 3 deletions snippets/csharp/SendSpontaneousPayment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ public void SendSpontaneousPayment(BlockingBreezServices sdk)
// ANCHOR: send-spontaneous-payment
var nodeId = "...";
ulong amountMsat = 3_000_000;
var optionalLabel = "<label>";

try
{
var response = sdk.SendSpontaneousPayment(
new SendSpontaneousPaymentRequest(nodeId, amountMsat));
new SendSpontaneousPaymentRequest(nodeId, amountMsat, label: optionalLabel));
}
catch (Exception)
{
Expand All @@ -26,14 +28,14 @@ public void SendSpontaneousPaymentWithTlvs(BlockingBreezServices sdk)
// ANCHOR: send-spontaneous-payment-with-tlvs
var nodeId = "...";
ulong amountMsat = 3_000_000;
var extraTlvs = new List<TlvEntry>{
var optionalExtraTlvs = new List<TlvEntry>{
new TlvEntry(34349334, Encoding.ASCII.GetBytes("Hello world!").ToList())
};

try
{
var response = sdk.SendSpontaneousPayment(
new SendSpontaneousPaymentRequest(nodeId, amountMsat, extraTlvs));
new SendSpontaneousPaymentRequest(nodeId, amountMsat, optionalExtraTlvs));
}
catch (Exception)
{
Expand Down
2 changes: 1 addition & 1 deletion snippets/csharp/ServiceStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public void HealthCheckStatus(BlockingBreezServices sdk)
// ANCHOR: health-check-status
try
{
var healthCheck = sdk.ServiceHealthCheck();
var healthCheck = BreezSdkMethods.ServiceHealthCheck("<api key>");
Console.WriteLine($"Current service status is: {healthCheck.status}");
}
catch (Exception)
Expand Down
52 changes: 52 additions & 0 deletions snippets/dart_snippets/lib/communicating_fees.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:breez_sdk/bridge_generated.dart';

Future<void> getFeeInfoBeforeInvoiceCreated() async {
// ANCHOR: get-fee-info-before-receiving-payment
NodeState? nodeInfo = await BreezSDK().nodeInfo();
if (nodeInfo != null) {
int inboundLiquiditySat = nodeInfo.inboundLiquidityMsats ~/ 1000;

OpenChannelFeeResponse openingFeeResponse = await BreezSDK().openChannelFee(req: OpenChannelFeeRequest());

OpeningFeeParams openingFees = openingFeeResponse.feeParams;
double feePercentage = (openingFees.proportional * 100) / 1000000;
int minFeeSat = openingFees.minMsat ~/ 1000;

if (inboundLiquiditySat == 0) {
print("A setup fee of $feePercentage% with a minimum of $minFeeSat sats will be applied.");
} else {
print("A setup fee of $feePercentage% with a minimum of $minFeeSat sats will be applied for receiving more than $inboundLiquiditySat sats.");
}
}
// ANCHOR_END: get-fee-info-before-receiving-payment
}

Future<void> getFeeInfoAfterInvoiceCreated({required ReceivePaymentResponse receivePaymentResponse}) async {
// ANCHOR: get-fee-info-after-invoice-created
int openingFeeSat = (receivePaymentResponse.openingFeeMsat ?? 0) / 1000 as int;
print("A setup fee of $openingFeeSat sats is applied to this invoice.");
// ANCHOR_END: get-fee-info-after-invoice-created
}

Future<void> getFeeInfoReceiveOnchain() async {
// ANCHOR: get-fee-info-receive-onchain
SwapInfo swapInfo = await BreezSDK().receiveOnchain(req: ReceiveOnchainRequest());

int minDepositSat = swapInfo.minAllowedDeposit;
int maxDepositSat = swapInfo.maxAllowedDeposit;

NodeState? nodeInfo = await BreezSDK().nodeInfo();
if (nodeInfo != null) {
int inboundLiquiditySat = nodeInfo.inboundLiquidityMsats ~/ 1000;

OpeningFeeParams? swapOpeningFees = swapInfo.channelOpeningFees;
if (swapOpeningFees != null) {
double feePercentage = (swapOpeningFees.proportional * 100) / 1000000;
int minFeeSat = swapOpeningFees.minMsat ~/ 1000;

print("Send more than $minDepositSat sats and up to $maxDepositSat sats to this address. A setup fee of $feePercentage% with a minimum of $minFeeSat sats will be applied for sending more than $inboundLiquiditySat sats. This address can only be used once.");
}
}
// ANCHOR_END: get-fee-info-receive-onchain
}
5 changes: 4 additions & 1 deletion snippets/dart_snippets/lib/lnurl_pay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ Future<void> lnurlPay() async {
InputType inputType = await BreezSDK().parseInput(input: lnurlPayUrl);
if (inputType is InputType_LnUrlPay) {
int amountMsat = inputType.data.minSendable;
String optionalComment = "<comment>";
String optionalPaymentLabel = "<label>";
LnUrlPayRequest req = LnUrlPayRequest(
data: inputType.data,
amountMsat: amountMsat,
comment: "<comment>",
comment: optionalComment,
paymentLabel: optionalPaymentLabel,
);
LnUrlPayResult result = await BreezSDK().lnurlPay(req: req);
print(result.data);
Expand Down
Loading
Loading