# Pay Lightning Invoice

Source: https://developers.bitgo.com/docs/lightning-pay-invoice

## Overview

Payment receivers generate a Lightning invoice. You can pay a valid invoice by providing the invoice string and optional parameters such as fee limits and additional metadata. Payments route over the Lightning Network and typically settle (or fail) immediately.

> 📘 **Note**
>
> Currently, BitGo limits individual Lightning transactions to a value of $500 USD or less.

## Prerequisites

* [Get Started](docs/get-started-intro).
* [Set Up Go Account](/docs/crypto-as-a-service-go-accounts).
* Sign a Lightning license (`custodyLightningWallet` for custody wallets and `custodyGoLightning` for Go Lighting) for your enterprise by contacting support@bitgo.com.
* Fund Go Account (`ofcbtc` / `ofctbtc`), is using Go Lightning.

## Cookbook

Need just the steps? Expand the cookbook below to get started:

<Cookbook slug="lightning-pay-invoice-custody" title="Pay Lightning Invoice - Custody" />

<Cookbook slug="lightning-pay-invoice-go" title="Pay Lightning Invoice - Go Lightning (Manual)" />

<Cookbook slug="lightning-pay-invoice-go-express" title="Pay Lightning Invoice (Go Lightning Simple)" />

<Tabs>
<Tab title="Custody">

## 1. Pay Invoice

>Endpoint: [Lightning - Pay a Lightning Invoice](/reference/expresslightningpayinvoice)

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tlnbtc"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export ADDRESS="<DESTINATION_ADDRESS>"
export AMOUNT="<AMOUNT_IN_BASE_UNITS>"
export WALLET_PASSPHRASE="<YOUR_WALLET_PASSPHRASE>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/lightning/payment \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "invoice": string,                       # Encoded payment request (required)
    "passphrase": "'"$WALLET_PASSPHRASE"'",  # Wallet passphrase (required)
    "amountMsat": string,     # Amount to pay in millisatoshis (optional, required for zero-amount invoices)
    "feeLimitMsat": string,   # Maximum fee to pay in millisatoshis
    "feeLimitRatio": number,  # Maximum fee expressed as a ratio of the payment amount
    "sequenceId": string,     # Custom identifier for tracking the payment
    "comment": string         # Additional note or comment for internal reference
}'
```
```js JavaScript
  const { BitGo } = require('bitgo');
  const { getLightningWallet } = require('@bitgo/abstract-lightning');
  const accessToken = '<YOUR_ACCESS_TOKEN>';

  // Initialize the SDK
  const bitgo = new BitGo({
    accessToken: accessToken,
    env: 'test',
    customRootURI: 'https://app.bitgo-test.com',
  });

  // Enter your Lightning wallet
  const walletId = '<YOUR_WALLET_ID>'
  const existingWallet = await bitgo.coin('tlnbtc').wallets().get({ id: walletId });
  const lightningWallet = getLightningWallet(existingWallet);

  const payInvoice = await lightningWallet.payInvoice({
    invoice: 'lnbtc...',
    passphrase: 'your wallet passphrase',
  });
  console.dir(payInvoice);
```

#### Step Result

```json JSON
{
    "txRequestId": string,
    "txRequestState": delivered,
    "paymentStatus": {
      "status": pending,
      "paymentHash": string,
      "paymentPreimage": string,
      "amountMsat": string,
      "feeMsat": string,
      "failureReason": string
    },
    "transfer": {
      "id": string,
      "coin": string,
      "wallet": string,
      "walletType": string,
      "enterprise": string,
      "organization": string,
      "txid": string,
      "state": string,
      "type": string,
      "value": number,
      "valueString": string,
      "coinSpecific": {
        "isOffchain": boolean,
        "invoice": string
      }
    }
}
```

</Tab>
<Tab title="Go Lightning (Simple)">

The simple flow for Go Lightning wallets enables you to build, sign, and send a Lightning payment in one call using BitGo Express (`/sendcoins`). If you require more granular control, see the Go Lightning (Manual) tab.

## 1. Pay Invoice

Build, sign, and send the Lightning payment in one call using your Go Account wallet passphrase.

> Endpoint: [Send Transaction](/reference/expresswalletsendcoins)

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export COIN="ofctbtc"
export WALLET_ID="<YOUR_GO_ACCOUNT_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export WALLET_PASSPHRASE="<YOUR_GO_ACCOUNT_PASSPHRASE>"
export INVOICE="<LIGHTNING_INVOICE_STRING>"
export AMOUNT="<AMOUNT_IN_SATOSHIS>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/sendcoins \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "address": "'"$INVOICE"'",
    "amount": "'"$AMOUNT"'",
    "walletPassphrase": "'"$WALLET_PASSPHRASE"'"
}'
```
```javascript JavaScript
const wallet = await bitgo.coin('ofctbtc').wallets().get({ id: walletId });

const result = await wallet.send({
  address: 'lntbs1...', // Lightning invoice string
  amount: 1000,         // Amount in satoshis
  walletPassphrase: '<YOUR_GO_ACCOUNT_PASSPHRASE>',
});
console.dir(result);
```

#### Step Result

```json JSON
{
  "transfer": {
    "id": "<TRANSFER_ID>",
    "coin": "ofctbtc",
    "wallet": "<WALLET_ID>",
    "walletType": "trading",
    "enterprise": "<ENTERPRISE_ID>",
    "txid": "<TRANSACTION_ID>",
    "date": "2026-04-09T12:00:01.000Z",
    "type": "send",
    "valueString": "-1000",
    "feeString": "0",
    "state": "signed"
  },
  "txid": "<TRANSACTION_ID>",
  "status": "signed"
}
```

</Tab>
<Tab title="Go Lightning Manual">

## 1. Build Transaction

Build a transaction from your Go Account with the Lightning invoice as the recipient address. Pass the Lightning invoice string as the recipient `address` and the amount in **satoshis**.


> Endpoint: [Build a Transaction](/reference/v2wallettxbuild)

```shell cURL
export COIN="ofctbtc"
export WALLET_ID="<YOUR_GO_ACCOUNT_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export INVOICE="<LIGHTNING_INVOICE_STRING>"
export AMOUNT="<AMOUNT_IN_SATOSHIS>"

curl -X POST \
  https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/tx/build \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "recipients": [
      {
        "amount": "'"$AMOUNT"'",
        "address": "'"$INVOICE"'"
      }
    ]
}'
```
```javascript JavaScript
const wallet = await bitgo.coin('ofctbtc').wallets().get({ id: walletId });

const buildResult = await wallet.prebuildTransaction({
  recipients: [
    {
      amount: 1000,
      address: 'lntbs1...', // Lightning invoice string
    },
  ],
});
console.dir(buildResult);
```

#### Step Result

```json JSON
{
  "payload": "{\"coin\":\"ofctbtc\",\"recipients\":[{\"address\":\"lntbs1...\",\"amount\":\"1000\"}],\"fromAccount\":\"<WALLET_ID>\",\"nonce\":\"<NONCE>\",\"timestamp\":\"2026-04-09T12:00:00.000Z\",\"feeString\":\"0\"}",
  "feeInfo": { "feeString": "0" },
  "coin": "ofc",
  "token": "ofctbtc"
}
```

## 2. Authenticate Transaction

Use your Go Account passphrase to authenticate the transaction. To ensure your passphrase isn't passed over the Internet, you must use ether the JavaScript SDK or BitGo Express in [external-signing mode](/docs/wallets-external-signer-mode#/versions).

```shell cURL (External Signing-Mode)
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export WALLET_ID="<YOUR_GO_ACCOUNT_WALLET_ID>"
export WALLET_PASSPHRASE="<YOUR_GO_ACCOUNT_PASSPHRASE>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/ofc/signPayload \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
   "walletId": "'"$WALLET_ID"'",
   "walletPassphrase": "'"$WALLET_PASSPHRASE"'",
   "payload": "<PAYLOAD_FROM_BUILD_STEP>"
}'
```
```javascript JavaScript
const tradingAccount = wallet.toTradingAccount();
const signature = await tradingAccount.signPayload({
  payload: JSON.stringify(buildResult.payload),
  walletPassphrase: '<YOUR_GO_ACCOUNT_PASSPHRASE>',
});
console.dir(signature);
```

#### Step Result

```json JSON
{
  "coin": "ofctbtc",
  "recipients": [
    {
      "address": "lntbs1...",
      "amount": "1000"
    }
  ],
  "fromAccount": "<WALLET_ID>",
  "nonce": "<NONCE>",
  "timestamp": "2026-04-09T12:00:00.000Z",
  "feeString": "0",
  "payload": "<SIGNED_PAYLOAD>",
  "signature": "<SIGNATURE>"
}
```

## 3. Send Transaction

> Endpoint: [Send Half-Signed Transaction](/reference/v2wallettxsend)

```shell cURL
export COIN="ofctbtc"
export WALLET_ID="<YOUR_GO_ACCOUNT_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"

curl -X POST \
  https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/tx/send \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "halfSigned": {
      "coin": "ofctbtc",
      "recipients": [
        {
          "address": "lntbs1...",
          "amount": "1000"
        }
      ],
      "fromAccount": "<WALLET_ID>",
      "nonce": "<NONCE>",
      "timestamp": "2026-04-09T12:00:00.000Z",
      "feeString": "0",
      "payload": "<SIGNED_PAYLOAD>",
      "signature": "<SIGNATURE>"
    }
  }'
```

#### Step Result

```json JSON
{
  "transfer": {
    "id": "<TRANSFER_ID>",
    "coin": "ofctbtc",
    "wallet": "<WALLET_ID>",
    "walletType": "trading",
    "enterprise": "<ENTERPRISE_ID>",
    "txid": "<TRANSACTION_ID>",
    "date": "2026-04-09T12:00:01.000Z",
    "type": "send",
    "valueString": "-1000",
    "feeString": "0",
    "state": "signed"
  },
  "txid": "<TRANSACTION_ID>",
  "status": "signed"
}
```

</Tab>
</Tabs>

## See Also

[Blockchain Reference: Bitcoin Lightning Network](https://assets.bitgo.com/coins/bitcoin-lightning)
