Lightning Network Payments

Generate invoiceAPI-v2lightning::payments::generate_invoice

The lightning::payments::generate_invoice method generates an invoice to be paid by another node.

Request Parameters

ParameterTypeDescription
coinstringTicker of coin to generate invoice for.
descriptionstringA note to indicate the purpose of the invoice.
amount_in_msatintegerAmount to be paid, in millisatoshis (A thousandth of a satoshi; the same as 0.00000000001 bitcoin.)
expiryintegerOptional, defaults to 3600. Seconds until the invoice expires.

📌 Example

POST Generate invoice lightning::payments::generate_invoice
{
  "method": "lightning::payments::generate_invoice",
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "params": {
    "coin": "tBTC-lightning",
    "description": "For the burger on Tuesday",
    "amount_in_msat": 10000,
    "expiry": 600
  },
  "id": 1
}
Show Response

Response

{
	"mmrpc": "2.0",
	"result": {
		"payment_hash": "3ff39605f214a4b4159f9c4f44c94de3a273f300042ca18b7cb3d62f270a9ebc",
		"invoice": "lntb100n1pj9aq73dpggehhygr5dpjjqcn4wfnk2u3qdahzq4r4v4ekgctenp4qf3dqylh55jd8m5x5hh0g5q82h9p86yghwhl2s0t826nlyp8zdgjzpp58leevp0jzjjtg9vln385fj2duw388ucqqsk2rzmuk0tz7fc2n67qsp5k33rvvq46xtuppl22ggcq5q7qqywyekcemhzazt4m6vulwsarcrq9qyysgqcqpcxqzjcrzjqwyx8nu2hygyvgc02cwdtvuxe0lcxz06qt3lpsldzcdr46my5epmjfgaasqqqvqqqqqqqqlgqqqqqqgq9qpwesnhre7xmdg6tajvp939vl72vxm8csecy6hfcah9fzgazd5eyzjskgtt7u9xshj7gq2vkejjcquem08tqfrc2pj78xa95teazzf0qq7pnyqj"
	},
	"id": 1
}
Show Error Responses

InvalidRequest (invalid paramater value)

{
	"mmrpc": "2.0",
	"error": "Error parsing request: invalid type: string '56', expected u64",
	"error_path": "dispatcher",
	"error_trace": "dispatcher:109]",
	"error_type": "InvalidRequest",
	"error_data": "invalid type: string '56', expected u64",
	"id": 762
}

Send PaymentAPI-v2lightning::payments::send_payment

The lightning::payments::send_payment method sends a payment to another node.

Used to pay an invoice or send a payment via pubkey/address.

Request Parameters

ParameterTypeDescription
typestringTicker of the coin to query.
paymentobjectA standard LightningPayment object.

📌 Example using invoice

POST Send Payment lightning::payments::send_payment
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "lightning::payments::send_payment",
  "params": {
    "coin": "tBTC-lightning",
    "payment": {
      "type": "invoice",
      "invoice": "lntb20u1p32wwxapp5p8gjy2e79jku5tshhq2nkdauv0malqqhzefnqmx9pjwa8h83cmwqdp8xys9xcmpd3sjqsmgd9czq3njv9c8qatrvd5kumcxqrrsscqp79qy9qsqsp5m473qknpecv6ajmwwtjw7keggrwxerymehx6723avhdrlnxmuvhs54zmyrumkasvjp0fvvk2np30cx5xpjs329alvm60rwy3payrnkmsd3n8ahnky3kuxaraa3u4k453yf3age7cszdxhjxjkennpt75erqpsfmy4y"
    }
  },
  "id": 6
}
Show Response

Response

{
	"mmrpc": "2.0",
	"result": {
		"payment_hash": "c4e25cc10d77e3cd5f3d2af7b14ad72f123b2a5021bd6705c0b8ee8386bdeceb"
	},
	"id": 762
}

📌 Example using keysend

POST Send Payment lightning::payments::send_payment
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "lightning::payments::send_payment",
  "params": {
    "coin": "tBTC-lightning",
    "payment": {
      "type": "keysend",
      "destination": "038863cf8ab91046230f561cd5b386cbff8309fa02e3f0c3ed161a3aeb64a643b9",
      "amount_in_msat": 1000,
      "expiry": 24
    }
  },
  "id": 6
}
Show Response

Response

{
	"mmrpc": "2.0",
	"result": {
		"payment_hash": "2620d47033fd366bff40cfe0879c47f683ef66c3882d0fab88a9bc72b5499655"
	},
	"id": 762
}
Show Error Responses

PaymentError (attempt to pay self)

{
	"mmrpc": "2.0",
	"error": "Payment error: Error paying invoice: Routing(LightningError { err: "Cannot generate a route to ourselves", action: IgnoreError })",
	"error_path": "send_payment.lightning",
	"error_trace": "send_payment:102] lightning:231]",
	"error_type": "PaymentError",
	"error_data": "Error paying invoice: Routing(LightningError { err: "Cannot generate a route to ourselves", action: IgnoreError })",
	"id": 6
}

PaymentError (no outbound routes)

{
	"mmrpc": "2.0",
	"error": "Payment error: Error paying invoice: Routing(LightningError { err: 'Cannot route when there are no outbound routes away from us ', action: IgnoreError })",
	"error_path": "send_payment.lightning",
	"error_trace": "send_payment:102] lightning:232]",
	"error_type": "PaymentError",
	"error_data": "Error paying invoice: Routing(LightningError { err: 'Cannot route when there are no outbound routes away from us ', action: IgnoreError })",
	"id": 762
}

PaymentError (keysend - no path to destination)

{
	"mmrpc": "2.0",
	"error": "Payment error: Keysend error: Routing(LightningError { err: "Failed to find a path to the given destination", action: IgnoreError })",
	"error_path": "send_payment.lightning",
	"error_trace": "send_payment:107] lightning:256]",
	"error_type": "PaymentError",
	"error_data": "Keysend error: Routing(LightningError { err: "Failed to find a path to the given destination", action: IgnoreError })",
	"id": 762
}

PaymentError (invoice - no path to destination)

{
	"mmrpc": "2.0",
	"error": "Payment error: Error paying invoice: Routing(LightningError { err: 'Failed to find a path to the given destination', action: IgnoreError })",
	"error_path": "send_payment.lightning",
	"error_trace": "send_payment:102] lightning:232]",
	"error_type": "PaymentError",
	"error_data": "Error paying invoice: Routing(LightningError { err: 'Failed to find a path to the given destination', action: IgnoreError })",
	"id": 762
}

InvalidRequest (request is missing a required field)

{
	"mmrpc": "2.0",
	"error": "Error parsing request: missing field `payment`",
	"error_path": "dispatcher",
	"error_trace": "dispatcher:109]",
	"error_type": "InvalidRequest",
	"error_data": "missing field `payment`",
	"id": 762
}

InvalidRequest (A required field is invalid)

{
	"mmrpc": "2.0",
	"error": "Error parsing request: ParseError(Bech32Error(MissingSeparator))",
	"error_path": "dispatcher",
	"error_trace": "dispatcher:109]",
	"error_type": "InvalidRequest",
	"error_data": "ParseError(Bech32Error(MissingSeparator))",
	"id": 762
}

Get Payment DetailsAPI-v2lightning::payments::get_payment_details

The lightning::payments::get_payment_details method returns details about a lightning payment from a given payment_hash.

Request Parameters

ParameterTypeDescription
coinstringTicker of the coin to query.
payment_hashstringThe hexadecimal string which identifies a invoice. The payment_hash is returned from a lightning::payments::send_payment request if the payment was sent by us, or from a lightning::payments::generate_invoice request if the payment is received (or will be received) by us.

📌 Example

POST Get Payment Details lightning::payments::get_payment_details
{
  "method": "lightning::payments::get_payment_details",
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "params": {
    "coin": "tBTC-lightning",
    "payment_hash": "414f9b3524fc4e48c99f2723952732d8bc2eba1b35ce3bf2a70f5144b40f599e"
  },
  "id": 1
}
Show Response
{
	"mmrpc": "2.0",
	"result": {
		"payment_details": {
			"payment_hash": "c4e25cc10d77e3cd5f3d2af7b14ad72f123b2a5021bd6705c0b8ee8386bdeceb",
			"payment_type": {
				"type": "Outbound Payment",
				"destination": "0348cc1a9479697cd52db445ea74149ad40bb01bb2045a3e8acba21b70f94ab7cf"
			},
			"description": "1 Blokaccino",
			"amount_in_msat": 1000000,
			"fee_paid_msat": 1803,
			"status": "succeeded",
			"created_at": 1684081413,
			"last_updated": 1684081419
		}
	},
	"id": 762
}
Show Error Responses

NoSuchPayment (payment hash not found)

{
	"mmrpc": "2.0",
	"error": "Payment with hash: 414f9b3524fc4e48c99f2723952732d8bc2eba1b35ce3bf2a70f5144b40f599e is not found",
	"error_path": "get_payment_details",
	"error_trace": "get_payment_details:75]",
	"error_type": "NoSuchPayment",
	"error_data": "414f9b3524fc4e48c99f2723952732d8bc2eba1b35ce3bf2a70f5144b40f599e",
	"id": 762
}

InvalidRequest (payment_hash not a hash string)

{
	"mmrpc": "2.0",
	"error": "Error parsing request: invalid value: string '', expected a hash string",
	"error_path": "dispatcher",
	"error_trace": "dispatcher:109]",
	"error_type": "InvalidRequest",
	"error_data": "invalid value: string '', expected a hash string",
	"id": 762
}

List Payments by FilterAPI-v2lightning::payments::list_payments_by_filter

The lightning::payments::list_payments_by_filter method returns a list of payments (sent and/or received) for a coin which match the given filter.

Request Parameters

ParameterTypeDescription
coinstringTicker of the coin to query.
filterobjectOptional. A standard LightningPaymentFilter object.
paging_optionsobjectOptional. A standard Pagination object.
limitintegerOptional, defaults to 10. Maximum number of results to return.

📌 Example without filter

POST List Payments by Filter lightning::payments::list_payments_by_filter
{
  "method": "lightning::payments::list_payments_by_filter",
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "params": {
    "coin": "tBTC-lightning"
  },
  "id": 1
}
Show Response

Response

{
	"mmrpc": "2.0",
	"result": {
		"payments": [{
			"payment_hash": "59175643db24fc79c77da073994d596444b6909fb2d452bde662ae386115c758",
			"payment_type": {
				"type": "Inbound Payment"
			},
			"description": "For the burger on Tuesday",
			"amount_in_msat": 10000,
			"status": "pending",
			"created_at": 1683917593,
			"last_updated": 1683917593
		}, {
			"payment_hash": "3ff39605f214a4b4159f9c4f44c94de3a273f300042ca18b7cb3d62f270a9ebc",
			"payment_type": {
				"type": "Outbound Payment"
			},
			"description": "A 1:24 scale model of a 1981 DeLorean DMC-12",
			"amount_in_msat": 88000,
			"status": "succeeded",
			"created_at": 1683815625,
			"last_updated": 1683815721
		}, {
			"payment_hash": "c4f44c94214a4b4159f9273f30de3a3ff39605f18b7c27b3d62f0a9ebc",
			"payment_type": {
				"type": "Outbound Payment"
			},
			"description": "Grays Sports Almanac, 1950-2000",
			"amount_in_msat": 1000000000,
			"status": "succeeded",
			"created_at": 1683714225,
			"last_updated": 1683805721
		}, {
			"payment_hash": "c4f44c94214a4b4159f9273f30de3a3ff39605f18b7c27b3d62f0a9ebc",
			"payment_type": {
				"type": "Outbound Payment"
			},
			"description": "ACME shrink ray",
			"amount_in_msat": 4000012,
			"status": "succeeded",
			"created_at": 1683814625,
			"last_updated": 1683815321
		}],
		"limit": 10,
		"skipped": 0,
		"total": 6,
		"total_pages": 1,
		"paging_options": {
			"PageNumber": 1
		}
	},
	"id": 1
}

📌 Example for Inbound Payment payment_type, limit and pagination

POST List Payments by Filter lightning::payments::list_payments_by_filter
{
  "method": "lightning::payments::list_payments_by_filter",
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "params": {
    "coin": "tBTC-lightning",
    "filter": {
      "payment_type": {
        "type": "Inbound Payment"
      }
    },
    "limit": 2,
    "paging_options": {
      "PageNumber": 2
    }
  },
  "id": 1
}
Show Response
{
	"mmrpc": "2.0",
	"result": {
		"payments": [{
			"payment_hash": "e51f1526d3322ddc0aaa0e893e5875418ddd12f206b7e1545c8e4375c97d0e31",
			"payment_type": {
				"type": "Inbound Payment"
			},
			"description": "For the burger on Tuesday",
			"amount_in_msat": 10000,
			"status": "pending",
			"created_at": 1683916900,
			"last_updated": 1683916900
		}, {
			"payment_hash": "605f214a4b4b159f9c4f44c94de3a273f3ff39300042ca18b7cbb4159f3d62f2",
			"payment_type": {
				"type": "Inbound Payment"
			},
			"description": "14 pallets of frozen spinach",
			"amount_in_msat": 56005000,
			"status": "succeeded",
			"created_at": 1683815625,
			"last_updated": 1683815721
		}],
		"limit": 2,
		"skipped": 2,
		"total": 7,
		"total_pages": 4,
		"paging_options": {
			"PageNumber": 2
		}
	},
	"id": 1
}

📌 Example for pending payments between 10000 and 40000 millisatoshis

POST List Payments by Filter lightning::payments::list_payments_by_filter
{
  "method": "lightning::payments::list_payments_by_filter",
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "params": {
    "coin": "tBTC-lightning",
    "filter": {
      "status": "pending",
      "from_amount_msat": 10000,
      "to_amount_msat": 40000
    }
  },
  "id": 1
}
Show Response

Response

{
	"mmrpc": "2.0",
	"result": {
		"payments": [{
			"payment_hash": "e51f1526d3322ddc0aaa0e893e5875418ddd12f206b7e1545c8e4375c97d0e31",
			"payment_type": {
				"type": "Inbound Payment"
			},
			"description": "For the burger on Tuesday",
			"amount_in_msat": 10000,
			"status": "pending",
			"created_at": 1683916900,
			"last_updated": 1683916900
		}],
		"limit": 10,
		"skipped": 6,
		"total": 1,
		"total_pages": 1,
		"paging_options": {
			"PageNumber": 1
		}
	},
	"id": 1
}

📌 Example for successful payments on the 20th of April 2023

POST List Payments by Filter lightning::payments::list_payments_by_filter
{
  "method": "lightning::payments::list_payments_by_filter",
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "params": {
    "coin": "tBTC-lightning",
    "filter": {
      "status": "succeeded",
      "from_timestamp": 1681948800,
      "to_timestamp": 1682035199
    }
  },
  "id": 1
}
Show Response

Response

{
	"mmrpc": "2.0",
	"result": {
		"payments": [{
			"payment_hash": "c4f44c94214a4b4159f9273f30de3a3ff39605f18b7c27b3d62f0a9ebc",
			"payment_type": {
				"type": "Outbound Payment"
			},
			"description": "Grays Sports Almanac, 1950-2000",
			"amount_in_msat": 1000000000,
			"status": "succeeded",
			"created_at": 1681998480,
			"last_updated": 1682008491
		}],
		"limit": 10,
		"skipped": 6,
		"total": 1,
		"total_pages": 1,
		"paging_options": {
			"PageNumber": 1
		}
	},
	"id": 1
}