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 optional_amount_msat: Option<u64> = None;
let optional_label = Some("<label>".to_string());
let req = SendPaymentRequest {
bolt11: "...".into(),
amount_msat: optional_amount_msat,
label: optional_label,
};
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 optionalAmountMsat: UInt64 = 3_000_000
let optionalLabel = "<label>"
let req = SendPaymentRequest(bolt11: "...", amountMsat: optionalAmountMsat, label: optionalLabel)
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 optionalAmountMsat = 3_000_000.toULong()
val optionalLabel = "<label>"
val req = SendPaymentRequest(bolt11, optionalAmountMsat, optionalLabel)
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 optionalAmountMsat = 3000000
const optionalLabel = '<label>'
const response = await sendPayment({
bolt11,
amountMsat: optionalAmountMsat,
label: optionalLabel
})
} 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'.
int optionalAmountMsat = 3000000;
String optionalLabel = "<label>";
SendPaymentRequest req = SendPaymentRequest(bolt11: bolt11, amountMsat: optionalAmountMsat, label: optionalLabel);
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'.
optional_amount_msat = 3000000
optional_label = "<label>"
req = breez_sdk.SendPaymentRequest(bolt11=bolt11, amount_msat=optional_amount_msat, label=optional_label)
sdk_services.send_payment(req=req)
except Exception as error:
print(error)
raise
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'.
optionalAmountMsat := uint64(3_000_000)
optionalLabel := "<label>"
sendPaymentRequest := breez_sdk.SendPaymentRequest{
Bolt11: bolt11,
AmountMsat: &optionalAmountMsat,
Label: &optionalLabel,
}
if response, err := sdk.SendPayment(sendPaymentRequest); err == nil {
log.Printf("%#v", response)
}
C#
var bolt11 = "...";
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, optionalAmountMsat, optionalLabel));
}
catch (Exception)
{
// Handle error
}