Files
breez-sdk-docs/src/guide/payments.md
Ross Savage dfdfc63c08 Merge branch 'connect-api' into go-examples
# Conflicts:
#	src/guide/getting_started.md
#	src/guide/lnurl_auth.md
#	src/guide/lnurl_pay.md
#	src/guide/lnurl_withdraw.md
#	src/guide/payments.md
#	src/guide/receive_onchain.md
#	src/guide/send_onchain.md
2023-07-11 09:32:20 +02:00

4.4 KiB

Sending and receiving Lightning payments

Rust

Receiving Lightning Payments

Breez SDK doesn't require you to open a channel and set up your inbound liquidity. Breez SDK automatically connects your node to the LSP peer and you can now receive payments:

let invoice = sdk.receive_payment(3000, "Invoice for 3000 sats".into()).await?;

Sending Lightning Payments

let bolt11 = "...";
sdk.send_payment(bolt11.into(), Some(3000)).await?;

Sending Spontaneous Lightning Payments

let node_id = "...";
sdk.send_payment(node_id.into(), Some(3000)).await?;
Swift

Receiving Lightning Payments

Breez SDK doesn't require you to open a channel and set up your inbound liquidity. Breez SDK automatically connects your node to the LSP peer and you can now receive payments:

do {
  let invoice = try sdk.receivePayment(amountSats: 3000, description: "Invoice for 3000 sats")
} catch {
    // handle error
}

Sending Lightning Payments

let bolt11 = "...";
do {
  let payment = try sdk.sendPayment(bolt11: bolt11, amountSats: 3000)
} catch {
    // handle error
}

Sending Spontaneous Lightning Payments

let nodeId = "...";
do {
  let payment = try sdk.sendSpontaneousPayment(nodeId: nodeId, amountSats: 3000)
} catch {
    // handle error
}
React Native

Receiving Lightning Payments

Breez SDK doesn't require you to open a channel and set up your inbound liquidity. Breez SDK automatically connects your node to the LSP peer and you can now receive payments:

try {
    const invoice = await receivePayment(3000, "Invoice for 3000 sats")
} catch (error) {
    console.log(error)
}

Sending Lightning Payments

const bolt11 = "...";
try {
    const payment = await sendPayment(bolt11, 3000)
} catch (error) {
    console.log(error)
}

Sending Spontaneous Lightning Payments

const nodeId = "...";
try {
    const payment = await sendSpontaneousPayment(nodeId, 3000)
} catch (error) {
    console.log(error)
}
Dart

Receiving Lightning Payments

Breez SDK doesn't require you to open a channel and set up your inbound liquidity. Breez SDK automatically connects your node to the LSP peer and you can now receive payments:

try {
    ReceivePaymentRequestData requestData = ReceivePaymentRequestData(amountSats: 3000, description: "Invoice for 3000 sats");
    ReceivePaymentResponse invoice = await receivePayment(reqData: requestData);
} catch (error) {
    // handle error
}

Sending Lightning Payments

String bolt11 = "...";
try {
    Payment payment = await sendPayment(
      bolt11: bolt11,
      amountSats: 3000,
    );
} catch (error) {
    // handle error
}

Sending Spontaneous Lightning Payments

String nodeId = "...";
try {
    Payment payment = await sendSpontaneousPayment(
      nodeId: nodeId,
      amountSats: 3000,
    );
} catch (error) {
    // handle error
}
Python

Receiving Lightning Payments

Breez SDK doesn't require you to open a channel and set up your inbound liquidity. Breez SDK automatically connects your node to the LSP peer and you can now receive payments:

try:
  invoice = sdk_services.receive_payment(3000, "Invoice for 3000 sats")
except Exception as error:
  # Handle error

Sending Lightning Payments

bolt11 = "..."
try:
  sdk_services.send_payment(bolt11, 3000)
except Exception as error:
  # Handle error

Sending Spontaneous Lightning Payments

let node_id = "..."
try:
  sdk_services.send_spontaneous_payment(node_id, 3000)
except Exception as error:
  # Handle error
Go

Receiving Lightning Payments

Breez SDK doesn't require you to open a channel and set up your inbound liquidity. Breez SDK automatically connects your node to the LSP peer and you can now receive payments:

invoice, err := sdkServices.ReceivePayment(3000, "Invoice for 3000 sats")

Sending Lightning Payments

const bolt11 = "...";
payment, err := sdkServices.SendPayment(bolt11, 3000)

Sending Spontaneous Lightning Payments

const nodeId = "...";
payment, err := sdkServices.SendSpontaneousPayment(nodeId, 3000)