Sending Lightning Payments
Once you have outbound liquidity you can start sending payments too.
Rust
// The `amount_msat` param is optional and should only passed if the bolt11 doesn't specify an amount.
// The amount_msat is required in case an amount is not specified in the bolt11 invoice'.
let amount_msat: Option<u64> = None;
let req = SendPaymentRequest {
bolt11: "...".into(),
amount_msat,
};
let response = sdk.send_payment(req).await?;
Swift
// 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'.
let req = SendPaymentRequest(bolt11: "...", amountMsat: 3_000_000)
let response = try? sdk.sendPayment(req: req)
Kotlin
val bolt11 = "..."
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'.
val amountMsat = 3_000_000.toULong()
val req = SendPaymentRequest(bolt11, amountMsat)
val response = sdk.sendPayment(req)
} catch (e: Exception) {
// handle error
}
React Native
try {
const bolt11 = 'bolt11 invoice'
// 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'.
const amountMsat = 3000000
const response = await sendPayment({ bolt11, amountMsat })
} catch (err) {
console.error(err)
}
Dart
// 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'.
SendPaymentRequest req = SendPaymentRequest(bolt11: bolt11, amountMsat: 3000000);
SendPaymentResponse resp = await BreezSDK().sendPayment(req: req);
Python
bolt11 = "..."
try:
# The `amount_msat` param is optional and should only passed if the bolt11 doesn't specify an amount.
# The amount_msat is required in case an amount is not specified in the bolt11 invoice'.
req = breez_sdk.SendPaymentRequest(bolt11=bolt11, amount_msat=3000000)
sdk_services.send_payment(req=req)
except Exception as error:
# Handle error
Go
bolt11 := "bolt11 invoice"
// 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'.
amountMsat := uint64(3_000_000)
sendPaymentRequest := breez_sdk.SendPaymentRequest{
Bolt11: bolt11,
AmountMsat: &amountMsat,
}
if response, err := sdk.SendPayment(sendPaymentRequest); err == nil {
log.Printf("%#v", response)
}
C#
var bolt11 = "...";
ulong amountMsat = 3_000_000;
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));
}
catch (Exception)
{
// Handle error
}