Skip to content

Latest commit

 

History

History
64 lines (41 loc) · 2.36 KB

README.md

File metadata and controls

64 lines (41 loc) · 2.36 KB

LN Invoice Logo

Parse Bitcoin Lightning Network invoices (payment requests) in Kotlin. This library implements decoding of invoices as per BOLT-11: # Invoice Protocol for Lightning Payments

Getting Started

On the Sonatype page for ln-invoice, choose the latest version of ln-invoice and follow the instructions for inclusion in your build tool.

Parsing a payment request

const val sample = "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq" +
  "5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqq" +
  "qqqqqqqqqpqsq67gye39hfg3zd8rgc80k32tvy9xk2xunwm5lzexnvpx6fd77en8qaq424dxgt56cag2dpt359" +
  "k3ssyhetktkpqh24jqnjyw6uqd08sgptq44qu"

val request: ErrorOr<PaymentRequest> = PaymentRequest.parse(sample)

See app.cash.lninvoice.PaymentRequestTest for more parsing examples, lifted directly from the BOLT-11 spec.

LN-Invoice is functional programming safe by default, using Quiver (an extension of Arrow). If you prefer to deal with thrown exceptions when parsing, simply add .orThrow().

val request: PaymentRequest = PaymentRequest.parse(sample).orThrow()

Fields in PaymentRequest instances that contain binary data use Okio's ByteString. If you need this as a byte array, call .toByteArray()

val signature: ByteString = invoice.signature
val sigBytes: ByteArray = signature.toByteArray()

Documentation

The API documentation is published with each release.

Changelog

See a list of changes in each release in the CHANGELOG.

Contributing

Building

  1. Install Hermit, the hermetic project tooling tool.

  2. Use gradle to run all tests locally:

gradle build

For more details on contributing, see the CONTRIBUTING guide.