-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from breez/pre-release
Release v0.4.0 docs
- Loading branch information
Showing
107 changed files
with
2,539 additions
and
913 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.