Create Lightning Invoice
Create a Lightning invoice and optionally retrieve it. See the Guide.
-
You generate a Lightning invoice by specifying the amount in millisatoshis (
valueMsat) or satoshis (valueSat) and optional metadata such as amemoorexpirytime. Share the invoice with a payer to complete the payment. Custody wallets accept bothvalueSatandvalueMsat; Go Lightning only acceptsvalueSat.BitGo currently limits individual Lightning transactions to a value of $500 USD or less.
-
You can retrieve an individual Lightning invoice using the
paymentHashfrom the creation response, or list all invoices for a wallet.
// 1. Create Lightning Invoice
export COIN="tlnbtc"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X POST \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/lightning/invoice \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"valueMsat": string, # Amount in millisatoshis
"valueSat": string, # Amount in satoshis
"memo": string, # Description of the invoice (optional)
"expiry": number # Expiration time in seconds (optional)
}'
// 2. (Optional) Get Lightning Invoice
export PAYMENT_HASH="<YOUR_INVOICE_PAYMENT_HASH>"
curl -X GET \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/lightning/invoice/$PAYMENT_HASH \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"
// 1. Create Lightning Invoice
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 invoice = await lightningWallet.createInvoice({ valueMsat: 1000n, memo: 'test', expiry: 36000 });
console.dir(invoice);
// 2. (Optional) Get Lightning Invoice
const invoiceResult = await lightningWallet.getInvoice('<YOUR_LIGHTNING_PAYMENT_HASH>');
console.dir(invoiceResult);
Response
// 1. Create Lightning Invoice Response
{
"valueMsat": "bigint",
"valueSat": "bigint",
"memo": "string",
"paymentHash": "string",
"invoice": "string",
"walletId": "string",
"status": "open",
"expiresAt": "string"
}
// 2. (Optional) Get Lightning Invoice Response
{
"memo": "Payment for the coffee",
"amtPaidMsat": "string",
"invoice": "lnbc500n1p3zv5vk...",
"paymentHash": "63d9ce82e09d16761a85116ed8b65407db4fb22f85d03573de09c480f2c6d175",
"valueMsat": "50000",
"expiresAt": "2022-04-01T18:46:24.677Z",
"status": "open",
"walletId": "59cd72485007a239fb00282ed480da1f",
"createdAt": "2022-04-01T18:46:24.677Z",
"updatedAt": "2022-04-01T18:46:24.677Z"
}