Skip to content

Add BOLT12 payer note docs #108

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

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion examples/breez-nodeless-llms/breez-nodeless-dart-llms.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ Future<PrepareSendResponse> prepareSendPaymentLightningBolt12() async {

try {
PayAmount_Bitcoin optionalAmount = PayAmount_Bitcoin(receiverAmountSat: BigInt.from(5000));
String optionalComment = "<comment>";
PrepareSendResponse prepareSendResponse = await breezSDKLiquid.instance!.prepareSendPayment(
req: PrepareSendRequest(destination: destination, amount: optionalAmount),
req: PrepareSendRequest(destination: destination, amount: optionalAmount, comment: optionalComment),
);
return prepareSendResponse;
} catch (error) {
Expand Down
4 changes: 3 additions & 1 deletion examples/breez-nodeless-llms/breez-nodeless-python-llms.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,13 @@ def prepare_send_payment_lightning_bolt12(sdk: BindingLiquidSdk):
destination = "<bolt12 offer>"
try:
optional_amount = PayAmount.BITCOIN(5_000)
optional_comment = "<comment>"

prepare_response = sdk.prepare_send_payment(
PrepareSendRequest(
destination=destination,
amount=optional_amount
amount=optional_amount,
comment=optional_comment
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,10 +1205,12 @@ const prepareSendPaymentLightningBolt12 = async () => {
type: PayAmountVariant.BITCOIN,
receiverAmountSat: 5_000
}
const optionalComment = '<comment>'

const prepareResponse = await prepareSendPayment({
destination: '<bolt12 offer>',
amount: optionalAmount
amount: optionalAmount,
comment: optionalComment
})

return prepareResponse
Expand Down
8 changes: 8 additions & 0 deletions examples/breez-nodeless-llms/breez-nodeless-rust-llms.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ async fn prepare_send_payment_lightning_bolt11(sdk: Arc<LiquidSdk>) -> Result<()
.prepare_send_payment(&PrepareSendRequest {
destination: "<bolt11 invoice>".to_string(),
amount: None,
comment: None,
})
.await?;

Expand All @@ -245,10 +246,12 @@ async fn prepare_send_payment_lightning_bolt12(sdk: Arc<LiquidSdk>) -> Result<()
let optional_amount = Some(PayAmount::Bitcoin {
receiver_amount_sat: 5_000,
});
let optional_comment = Some("<comment>".to_string());
let prepare_response = sdk
.prepare_send_payment(&PrepareSendRequest {
destination: "<bolt12 offer>".to_string(),
amount: optional_amount,
comment: optional_comment,
})
.await?;

Expand All @@ -268,6 +271,7 @@ async fn prepare_send_payment_liquid(sdk: Arc<LiquidSdk>) -> Result<()> {
.prepare_send_payment(&PrepareSendRequest {
destination: "<Liquid BIP21 or address>".to_string(),
amount: optional_amount,
comment: None,
})
.await?;

Expand All @@ -285,6 +289,7 @@ async fn prepare_send_payment_liquid_drain(sdk: Arc<LiquidSdk>) -> Result<()> {
.prepare_send_payment(&PrepareSendRequest {
destination: "<Liquid BIP21 or address>".to_string(),
amount: optional_amount,
comment: None,
})
.await?;

Expand Down Expand Up @@ -723,6 +728,7 @@ async fn prepare_send_payment_asset(sdk: Arc<LiquidSdk>) -> Result<()> {
.prepare_send_payment(&PrepareSendRequest {
destination: "<Liquid BIP21 or address>".to_string(),
amount: optional_amount,
comment: None,
})
.await?;

Expand Down Expand Up @@ -1084,6 +1090,7 @@ async fn main() -> Result<()> {
let prepare_response = sdk.prepare_send_payment(&PrepareSendRequest {
destination,
amount,
comment: None,
}).await?;

// Send payment
Expand Down Expand Up @@ -1304,6 +1311,7 @@ async fn safe_payment(sdk: Arc<LiquidSdk>, destination: String, amount_sat: u64,
let prepare_response = sdk.prepare_send_payment(&PrepareSendRequest {
destination,
amount: Some(PayAmount::Bitcoin { receiver_amount_sat: amount_sat }),
comment: None,
}).await?;

// Check if fees are acceptable
Expand Down
4 changes: 3 additions & 1 deletion examples/breez-nodeless-llms/breez-nodeless-wasm-llms.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,12 @@ const prepareSendPaymentLightningBolt12 = async (sdk) => {
type: 'bitcoin',
receiverAmountSat: 5_000
};
const optionalComment = '<comment>'

const prepareResponse = await sdk.prepareSendPayment({
destination: '<bolt12 offer>',
amount: optionalAmount
amount: optionalAmount,
comment: optionalComment
});

return prepareResponse;
Expand Down
4 changes: 3 additions & 1 deletion snippets/csharp/SendPayment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
try
{
var optionalAmount = new PayAmount.Bitcoin(5000);
var prepareResponse = sdk.PrepareSendPayment(new PrepareSendRequest(destination, optionalAmount));
var optionalComment = "<comment>";
var prepareRequest = new PrepareSendRequest(destination, optionalAmount, optionalComment);

Check failure on line 34 in snippets/csharp/SendPayment.cs

View workflow job for this annotation

GitHub Actions / Check C# snippets

'PrepareSendRequest' does not contain a constructor that takes 3 arguments

Check failure on line 34 in snippets/csharp/SendPayment.cs

View workflow job for this annotation

GitHub Actions / Check C# snippets

'PrepareSendRequest' does not contain a constructor that takes 3 arguments
var prepareResponse = sdk.PrepareSendPayment(prepareRequest);
}
catch (Exception)
{
Expand Down
7 changes: 6 additions & 1 deletion snippets/dart_snippets/lib/send_payment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ Future<PrepareSendResponse> prepareSendPaymentLightningBolt12() async {
// ANCHOR: prepare-send-payment-lightning-bolt12
// Set the bolt12 offer you wish to pay
PayAmount_Bitcoin optionalAmount = PayAmount_Bitcoin(receiverAmountSat: 5000 as BigInt);
String optionalComment = "<comment>";
PrepareSendResponse prepareSendResponse = await breezSDKLiquid.instance!.prepareSendPayment(
req: PrepareSendRequest(destination: "<bolt12 offer>", amount: optionalAmount),
req: PrepareSendRequest(
destination: "<bolt12 offer>",
amount: optionalAmount,
comment: optionalComment
),
);
// ANCHOR_END: prepare-send-payment-lightning-bolt12
return prepareSendResponse;
Expand Down
2 changes: 2 additions & 0 deletions snippets/go/send_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ func PrepareSendPaymentLightningBolt12(sdk *breez_sdk_liquid.BindingLiquidSdk) {
var optionalAmount breez_sdk_liquid.PayAmount = breez_sdk_liquid.PayAmountBitcoin{
ReceiverAmountSat: uint64(5_000),
}
optionalComment := "<comment>"
prepareRequest := breez_sdk_liquid.PrepareSendRequest{
Destination: destination,
Amount: &optionalAmount,
Comment: &optionalComment,
}
prepareResponse, err := sdk.PrepareSendPayment(prepareRequest)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class SendPayment {
val destination = "<bolt12 offer>"
try {
val optionalAmount = PayAmount.Bitcoin(5_000.toULong())
val prepareResponse = sdk.prepareSendPayment(PrepareSendRequest(destination, optionalAmount))
val optionalComment = "<comment>"
val prepareRequest = PrepareSendRequest(destination, optionalAmount, optionalComment)
val prepareResponse = sdk.prepareSendPayment(prepareRequest)
} catch (e: Exception) {
// handle error
}
Expand Down
4 changes: 3 additions & 1 deletion snippets/python/src/send_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ def prepare_send_payment_lightning_bolt12(sdk: BindingLiquidSdk):
destination = "<bolt12 offer>"
try:
optional_amount = PayAmount.BITCOIN(5_000)
optional_comment = "<comment>"

prepare_response = sdk.prepare_send_payment(
PrepareSendRequest(
destination=destination,
amount=optional_amount
amount=optional_amount,
comment=optional_comment
)
)

Expand Down
4 changes: 3 additions & 1 deletion snippets/react-native/send_payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ const examplePrepareSendPaymentLightningBolt12 = async () => {
type: PayAmountVariant.BITCOIN,
receiverAmountSat: 5_000
}
const optionalComment = '<comment>'

const prepareResponse = await prepareSendPayment({
destination: '<bolt12 offer>',
amount: optionalAmount
amount: optionalAmount,
comment: optionalComment
})
// ANCHOR_END: prepare-send-payment-lightning-bolt12
}
Expand Down
2 changes: 2 additions & 0 deletions snippets/rust/src/non_bitcoin_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async fn prepare_send_payment_asset(sdk: Arc<LiquidSdk>) -> Result<()> {
.prepare_send_payment(&PrepareSendRequest {
destination,
amount: optional_amount,
comment: None,
})
.await?;

Expand All @@ -67,6 +68,7 @@ async fn prepare_send_payment_asset_fees(sdk: Arc<LiquidSdk>) -> Result<()> {
.prepare_send_payment(&PrepareSendRequest {
destination,
amount: optional_amount,
comment: None,
})
.await?;

Expand Down
3 changes: 3 additions & 0 deletions snippets/rust/src/send_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async fn prepare_send_payment_lightning_bolt11(sdk: Arc<LiquidSdk>) -> Result<()
.prepare_send_payment(&PrepareSendRequest {
destination: "<bolt11 invoice>".to_string(),
amount: None,
comment: None,
})
.await?;

Expand All @@ -27,10 +28,12 @@ async fn prepare_send_payment_lightning_bolt12(sdk: Arc<LiquidSdk>) -> Result<()
let optional_amount = Some(PayAmount::Bitcoin {
receiver_amount_sat: 5_000,
});
let optional_comment = Some("<comment>".to_string());
let prepare_response = sdk
.prepare_send_payment(&PrepareSendRequest {
destination: "<bolt12 offer>".to_string(),
amount: optional_amount,
comment: optional_comment,
})
.await?;
// ANCHOR_END: prepare-send-payment-lightning-bolt12
Expand Down
4 changes: 3 additions & 1 deletion snippets/swift/BreezSDKExamples/Sources/SendPayment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ func prepareSendPaymentLightningBolt12(sdk: BindingLiquidSdk) -> PrepareSendResp
// ANCHOR: prepare-send-payment-lightning-bolt12
// Set the bolt12 offer you wish to pay
let optionalAmount = PayAmount.bitcoin(receiverAmountSat: 5_000)
let optionalComment = "<comment>"
let prepareResponse = try? sdk
.prepareSendPayment(req: PrepareSendRequest (
destination: "<bolt12 offer>",
amount: optionalAmount
amount: optionalAmount,
comment: optionalComment
))
// ANCHOR_END: prepare-send-payment-lightning-bolt12
return prepareResponse
Expand Down
4 changes: 3 additions & 1 deletion snippets/wasm/send_payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const examplePrepareSendPaymentLightningBolt12 = async (sdk: BindingLiquidSdk) =
type: 'bitcoin',
receiverAmountSat: 5_000
}
const optionalComment = '<comment>'

const prepareResponse = await sdk.prepareSendPayment({
destination: '<bolt12 offer>',
amount: optionalAmount
amount: optionalAmount,
comment: optionalComment
})
// ANCHOR_END: prepare-send-payment-lightning-bolt12
}
Expand Down
2 changes: 1 addition & 1 deletion src/guide/send_payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The SDK will also validate that the amount is within the send lightning limits o

#### BOLT12 offer

Payments to a BOLT12 offer can be done in a similar way. However, when paying to a BOLT12 offer, the SDK's prepare request **must** include an amount.
Payments to a BOLT12 offer can be done in a similar way. However, when paying to a BOLT12 offer, the SDK's prepare request **must** include an amount. The payment can also include an optional `comment`, which will be included in the invoice as a payer note.

<custom-tabs category="lang">
<div slot="title">Rust</div>
Expand Down
Loading