2021-01-07 19:48:47 +01:00
lightning-decode -- Command for decoding an invoice string (low-level)
=======================================================================
SYNOPSIS
--------
**decode** *string*
DESCRIPTION
-----------
2022-07-16 15:18:27 +02:00
The **decode** RPC command checks and parses:
- a *bolt11* or *bolt12* string (optionally prefixed by `lightning:`
or `LIGHTNING:` ) as specified by the BOLT 11 and BOLT 12
specifications.
- a *rune* as created by lightning-commando-rune(7).
2023-11-10 06:11:57 +01:00
- an *emergency\_recover* string generated by hsmtool like
`lightning-hsmtool getemergencyrecover <path/to/emergency.recover>` .
It holds `emergency.recover` contents and starts with `clnemerg1` .
2022-07-16 15:18:27 +02:00
It may decode other formats in future.
2021-01-07 19:48:47 +01:00
RETURN VALUE
------------
2021-05-26 07:54:01 +02:00
[comment]: # (GENERATE-FROM-SCHEMA-START)
On success, an object is returned, containing:
2022-09-05 23:33:09 +02:00
2023-10-26 05:15:50 +02:00
- **type** (string): what kind of object it decoded to (one of "bolt12 offer", "bolt12 invoice", "bolt12 invoice\_request", "bolt11 invoice", "rune", "emergency recover")
2021-05-26 07:54:01 +02:00
- **valid** (boolean): if this is false, you *MUST* not use the result except for diagnostics!
If **type** is "bolt12 offer", and **valid** is *true* :
2022-09-05 23:33:09 +02:00
2022-11-09 03:32:00 +01:00
- **offer\_id** (hex): the id we use to identify this offer (always 64 characters)
- **offer\_description** (string): the description of the purpose of the offer
- **offer\_node\_id** (pubkey): public key of the offering node
2023-01-30 07:24:17 +01:00
- **offer\_chains** (array of hashs, optional): which blockchains this offer is for (missing implies bitcoin mainnet only):
- the genesis blockhash
2023-12-30 10:34:22 +01:00
- **offer\_metadata** (hex, optional): any metadata the creator of the offer includes
2022-11-09 03:32:00 +01:00
- **offer\_currency** (string, optional): ISO 4217 code of the currency (missing implies Bitcoin) (always 3 characters)
- **currency\_minor\_unit** (u32, optional): the number of decimal places to apply to amount (if currency known)
- **offer\_amount** (u64, optional): the amount in the `offer_currency` adjusted by `currency_minor_unit` , if any
- **offer\_amount\_msat** (msat, optional): the amount in bitcoin (if specified, and no `offer_currency` )
- **offer\_issuer** (string, optional): the description of the creator of the offer
- **offer\_features** (hex, optional): the feature bits of the offer
- **offer\_absolute\_expiry** (u64, optional): UNIX timestamp of when this offer expires
- **offer\_quantity\_max** (u64, optional): the maximum quantity (or, if 0, means any quantity)
- **offer\_paths** (array of objects, optional): Paths to the destination:
2022-10-17 02:37:05 +02:00
- **first\_node\_id** (pubkey): the (presumably well-known) public key of the start of the path
2021-05-26 07:54:01 +02:00
- **blinding** (pubkey): blinding factor for this path
- **path** (array of objects): an individual path:
2022-11-11 03:03:13 +01:00
- **blinded\_node\_id** (pubkey): node\_id of the hop
2022-09-05 23:45:06 +02:00
- **encrypted\_recipient\_data** (hex): encrypted TLV entry for this hop
2022-11-09 03:32:00 +01:00
- **offer\_recurrence** (object, optional): how often to this offer should be used:
2022-09-05 23:45:06 +02:00
- **time\_unit** (u32): the BOLT12 time unit
2022-11-09 03:32:00 +01:00
- **period** (u32): how many `time_unit` per payment period
- **time\_unit\_name** (string, optional): the name of `time_unit` (if valid)
2021-05-26 07:54:01 +02:00
- **basetime** (u64, optional): period starts at this UNIX timestamp
2023-11-24 18:21:42 +01:00
- **start\_any\_period** (boolean, optional): you can start at any period (only if `basetime` present)
2021-05-26 07:54:01 +02:00
- **limit** (u32, optional): maximum period number for recurrence
- **paywindow** (object, optional): when within a period will payment be accepted (default is prior and during the period):
2022-09-05 23:45:06 +02:00
- **seconds\_before** (u32): seconds prior to period start
- **seconds\_after** (u32): seconds after to period start
2023-12-30 10:34:22 +01:00
- **proportional\_amount** (boolean, optional): amount should be scaled if paid after period start (always *true* )
2022-11-09 03:32:01 +01:00
- **unknown\_offer\_tlvs** (array of objects, optional): Any extra fields we didn't know how to parse:
- **type** (u64): The type
- **length** (u64): The length
- **value** (hex): The value
2021-05-26 07:54:01 +02:00
- the following warnings are possible:
2022-11-09 03:32:00 +01:00
- **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit` )
2021-05-26 07:54:01 +02:00
If **type** is "bolt12 offer", and **valid** is *false* :
2022-09-05 23:33:09 +02:00
2021-05-26 07:54:01 +02:00
- the following warnings are possible:
2022-11-09 03:32:00 +01:00
- **warning\_missing\_offer\_node\_id**: `offer_node_id` is not present
- **warning\_invalid\_offer\_description**: `offer_description` is not valid UTF8
- **warning\_missing\_offer\_description**: `offer_description` is not present
- **warning\_invalid\_offer\_currency**: `offer_currency_code` is not valid UTF8
- **warning\_invalid\_offer\_issuer**: `offer_issuer` is not valid UTF8
2022-11-11 03:03:13 +01:00
If **type** is "bolt12 invoice\_request", and **valid** is *true* :
2022-11-09 03:32:00 +01:00
- **offer\_description** (string): the description of the purpose of the offer
- **offer\_node\_id** (pubkey): public key of the offering node
2022-11-11 03:03:13 +01:00
- **invreq\_metadata** (hex): the payer-provided blob to derive invreq\_payer\_id
2022-11-09 03:32:00 +01:00
- **invreq\_payer\_id** (hex): the payer-provided key
2022-11-11 03:03:13 +01:00
- **signature** (bip340sig): BIP-340 signature of the `invreq_payer_id` on this invoice\_request
2022-11-09 03:32:00 +01:00
- **offer\_id** (hex, optional): the id we use to identify this offer (always 64 characters)
- **offer\_chains** (array of hexs, optional): which blockchains this offer is for (missing implies bitcoin mainnet only):
- the genesis blockhash (always 64 characters)
- **offer\_metadata** (hex, optional): any metadata the creator of the offer includes
- **offer\_currency** (string, optional): ISO 4217 code of the currency (missing implies Bitcoin) (always 3 characters)
- **currency\_minor\_unit** (u32, optional): the number of decimal places to apply to amount (if currency known)
- **offer\_amount** (u64, optional): the amount in the `offer_currency` adjusted by `currency_minor_unit` , if any
- **offer\_amount\_msat** (msat, optional): the amount in bitcoin (if specified, and no `offer_currency` )
- **offer\_issuer** (string, optional): the description of the creator of the offer
- **offer\_features** (hex, optional): the feature bits of the offer
- **offer\_absolute\_expiry** (u64, optional): UNIX timestamp of when this offer expires
- **offer\_quantity\_max** (u64, optional): the maximum quantity (or, if 0, means any quantity)
- **offer\_paths** (array of objects, optional): Paths to the destination:
- **first\_node\_id** (pubkey): the (presumably well-known) public key of the start of the path
- **blinding** (pubkey): blinding factor for this path
- **path** (array of objects): an individual path:
2022-11-11 03:03:13 +01:00
- **blinded\_node\_id** (pubkey): node\_id of the hop
2022-11-09 03:32:00 +01:00
- **encrypted\_recipient\_data** (hex): encrypted TLV entry for this hop
- **offer\_recurrence** (object, optional): how often to this offer should be used:
- **time\_unit** (u32): the BOLT12 time unit
- **period** (u32): how many `time_unit` per payment period
- **time\_unit\_name** (string, optional): the name of `time_unit` (if valid)
- **basetime** (u64, optional): period starts at this UNIX timestamp
2023-11-24 18:21:42 +01:00
- **start\_any\_period** (boolean, optional): you can start at any period (only if `basetime` present)
2022-11-09 03:32:00 +01:00
- **limit** (u32, optional): maximum period number for recurrence
- **paywindow** (object, optional): when within a period will payment be accepted (default is prior and during the period):
- **seconds\_before** (u32): seconds prior to period start
- **seconds\_after** (u32): seconds after to period start
2023-12-30 10:34:22 +01:00
- **proportional\_amount** (boolean, optional): amount should be scaled if paid after period start (always *true* )
2022-11-09 03:32:00 +01:00
- **invreq\_chain** (hex, optional): which blockchain this offer is for (missing implies bitcoin mainnet only) (always 64 characters)
- **invreq\_amount\_msat** (msat, optional): the amount the invoice should be for
2022-11-11 03:03:13 +01:00
- **invreq\_features** (hex, optional): the feature bits of the invoice\_request
2022-11-09 03:32:00 +01:00
- **invreq\_quantity** (u64, optional): the number of items to invoice for
- **invreq\_payer\_note** (string, optional): a note attached by the payer
- **invreq\_recurrence\_counter** (u32, optional): which number request this is for the same invoice
- **invreq\_recurrence\_start** (u32, optional): when we're requesting to start an invoice at a non-zero period
2022-11-09 03:32:01 +01:00
- **unknown\_invoice\_request\_tlvs** (array of objects, optional): Any extra fields we didn't know how to parse:
- **type** (u64): The type
- **length** (u64): The length
- **value** (hex): The value
2022-11-09 03:32:00 +01:00
- the following warnings are possible:
- **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit` )
2022-11-11 03:03:13 +01:00
If **type** is "bolt12 invoice\_request", and **valid** is *false* :
2022-11-09 03:32:00 +01:00
- the following warnings are possible:
- **warning\_invalid\_offer\_description**: `offer_description` is not valid UTF8
- **warning\_missing\_offer\_description**: `offer_description` is not present
- **warning\_invalid\_offer\_currency**: `offer_currency_code` is not valid UTF8
- **warning\_invalid\_offer\_issuer**: `offer_issuer` is not valid UTF8
- **warning\_missing\_invreq\_metadata**: `invreq_metadata` is not present
- **warning\_missing\_invreq\_payer\_id**: `invreq_payer_id` is not present
- **warning\_invalid\_invreq\_payer\_note**: `invreq_payer_note` is not valid UTF8
- **warning\_missing\_invoice\_request\_signature**: `signature` is not present
- **warning\_invalid\_invoice\_request\_signature**: Incorrect `signature`
2021-05-26 07:54:01 +02:00
If **type** is "bolt12 invoice", and **valid** is *true* :
2022-09-05 23:33:09 +02:00
2022-11-09 03:32:00 +01:00
- **offer\_description** (string): the description of the purpose of the offer
- **offer\_node\_id** (pubkey): public key of the offering node
2022-11-11 03:03:13 +01:00
- **invreq\_metadata** (hex): the payer-provided blob to derive invreq\_payer\_id
2022-11-09 03:32:00 +01:00
- **invreq\_payer\_id** (hex): the payer-provided key
- **invoice\_paths** (array of objects): Paths to pay the destination:
2022-10-17 02:37:05 +02:00
- **first\_node\_id** (pubkey): the (presumably well-known) public key of the start of the path
2021-05-26 07:54:01 +02:00
- **blinding** (pubkey): blinding factor for this path
2023-01-12 04:58:03 +01:00
- **payinfo** (object):
- **fee\_base\_msat** (msat): basefee for path
- **fee\_proportional\_millionths** (u32): proportional fee for path
- **cltv\_expiry\_delta** (u32): CLTV delta for path
- **features** (hex): features allowed for path
2021-05-26 07:54:01 +02:00
- **path** (array of objects): an individual path:
2022-11-11 03:03:13 +01:00
- **blinded\_node\_id** (pubkey): node\_id of the hop
2022-09-05 23:45:06 +02:00
- **encrypted\_recipient\_data** (hex): encrypted TLV entry for this hop
2022-11-09 03:32:00 +01:00
- **invoice\_created\_at** (u64): the UNIX timestamp of invoice creation
2022-11-11 03:03:13 +01:00
- **invoice\_payment\_hash** (hex): the hash of the *payment\_preimage* (always 64 characters)
2022-11-09 03:32:00 +01:00
- **invoice\_amount\_msat** (msat): the amount required to fulfill invoice
- **signature** (bip340sig): BIP-340 signature of the `offer_node_id` on this invoice
- **offer\_id** (hex, optional): the id we use to identify this offer (always 64 characters)
- **offer\_chains** (array of hexs, optional): which blockchains this offer is for (missing implies bitcoin mainnet only):
- the genesis blockhash (always 64 characters)
- **offer\_metadata** (hex, optional): any metadata the creator of the offer includes
- **offer\_currency** (string, optional): ISO 4217 code of the currency (missing implies Bitcoin) (always 3 characters)
- **currency\_minor\_unit** (u32, optional): the number of decimal places to apply to amount (if currency known)
- **offer\_amount** (u64, optional): the amount in the `offer_currency` adjusted by `currency_minor_unit` , if any
- **offer\_amount\_msat** (msat, optional): the amount in bitcoin (if specified, and no `offer_currency` )
- **offer\_issuer** (string, optional): the description of the creator of the offer
- **offer\_features** (hex, optional): the feature bits of the offer
- **offer\_absolute\_expiry** (u64, optional): UNIX timestamp of when this offer expires
- **offer\_quantity\_max** (u64, optional): the maximum quantity (or, if 0, means any quantity)
- **offer\_paths** (array of objects, optional): Paths to the destination:
- **first\_node\_id** (pubkey): the (presumably well-known) public key of the start of the path
- **blinding** (pubkey): blinding factor for this path
- **path** (array of objects): an individual path:
2022-11-11 03:03:13 +01:00
- **blinded\_node\_id** (pubkey): node\_id of the hop
2022-11-09 03:32:00 +01:00
- **encrypted\_recipient\_data** (hex): encrypted TLV entry for this hop
- **offer\_recurrence** (object, optional): how often to this offer should be used:
- **time\_unit** (u32): the BOLT12 time unit
- **period** (u32): how many `time_unit` per payment period
- **time\_unit\_name** (string, optional): the name of `time_unit` (if valid)
- **basetime** (u64, optional): period starts at this UNIX timestamp
2023-11-24 18:21:42 +01:00
- **start\_any\_period** (boolean, optional): you can start at any period (only if `basetime` present)
2022-11-09 03:32:00 +01:00
- **limit** (u32, optional): maximum period number for recurrence
- **paywindow** (object, optional): when within a period will payment be accepted (default is prior and during the period):
- **seconds\_before** (u32): seconds prior to period start
- **seconds\_after** (u32): seconds after to period start
2023-12-30 10:34:22 +01:00
- **proportional\_amount** (boolean, optional): amount should be scaled if paid after period start (always *true* )
2022-11-09 03:32:00 +01:00
- **invreq\_chain** (hex, optional): which blockchain this offer is for (missing implies bitcoin mainnet only) (always 64 characters)
- **invreq\_amount\_msat** (msat, optional): the amount the invoice should be for
2022-11-11 03:03:13 +01:00
- **invreq\_features** (hex, optional): the feature bits of the invoice\_request
2022-11-09 03:32:00 +01:00
- **invreq\_quantity** (u64, optional): the number of items to invoice for
- **invreq\_payer\_note** (string, optional): a note attached by the payer
- **invreq\_recurrence\_counter** (u32, optional): which number request this is for the same invoice
- **invreq\_recurrence\_start** (u32, optional): when we're requesting to start an invoice at a non-zero period
2022-11-11 03:03:13 +01:00
- **invoice\_relative\_expiry** (u32, optional): the number of seconds after *invoice\_created\_at* when this expires
2022-11-09 03:32:00 +01:00
- **invoice\_fallbacks** (array of objects, optional): onchain addresses:
2021-05-26 07:54:01 +02:00
- **version** (u8): Segwit address version
- **hex** (hex): Raw encoded segwit address
- **address** (string, optional): bech32 segwit address
2022-11-09 03:32:00 +01:00
- **invoice\_features** (hex, optional): the feature bits of the invoice
2022-11-11 03:03:13 +01:00
- **invoice\_node\_id** (pubkey, optional): the id to pay (usually the same as offer\_node\_id)
2022-11-09 03:32:00 +01:00
- **invoice\_recurrence\_basetime** (u64, optional): the UNIX timestamp to base the invoice periods on
2022-11-09 03:32:01 +01:00
- **unknown\_invoice\_tlvs** (array of objects, optional): Any extra fields we didn't know how to parse:
- **type** (u64): The type
- **length** (u64): The length
- **value** (hex): The value
2022-11-09 03:32:00 +01:00
- the following warnings are possible:
- **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit` )
2021-05-26 07:54:01 +02:00
If **type** is "bolt12 invoice", and **valid** is *false* :
2022-09-05 23:33:09 +02:00
2021-05-26 07:54:01 +02:00
- **fallbacks** (array of objects, optional):
- the following warnings are possible:
2022-11-09 03:32:00 +01:00
- **warning\_invoice\_fallbacks\_version\_invalid**: `version` is > 16
2021-05-26 07:54:01 +02:00
- the following warnings are possible:
2022-11-09 03:32:00 +01:00
- **warning\_invalid\_offer\_description**: `offer_description` is not valid UTF8
- **warning\_missing\_offer\_description**: `offer_description` is not present
- **warning\_invalid\_offer\_currency**: `offer_currency_code` is not valid UTF8
- **warning\_invalid\_offer\_issuer**: `offer_issuer` is not valid UTF8
- **warning\_missing\_invreq\_metadata**: `invreq_metadata` is not present
- **warning\_invalid\_invreq\_payer\_note**: `invreq_payer_note` is not valid UTF8
- **warning\_missing\_invoice\_paths**: `invoice_paths` is not present
- **warning\_missing\_invoice\_blindedpay**: `invoice_blindedpay` is not present
- **warning\_missing\_invoice\_created\_at**: `invoice_created_at` is not present
- **warning\_missing\_invoice\_payment\_hash**: `invoice_payment_hash` is not present
- **warning\_missing\_invoice\_amount**: `invoice_amount` is not present
- **warning\_missing\_invoice\_recurrence\_basetime**: `invoice_recurrence_basetime` is not present
- **warning\_missing\_invoice\_node\_id**: `invoice_node_id` is not present
- **warning\_missing\_invoice\_signature**: `signature` is not present
- **warning\_invalid\_invoice\_signature**: Incorrect `signature`
2021-05-26 07:54:01 +02:00
If **type** is "bolt11 invoice", and **valid** is *true* :
2022-09-05 23:33:09 +02:00
2021-05-26 07:54:01 +02:00
- **currency** (string): the BIP173 name for the currency
2022-09-05 23:45:06 +02:00
- **created\_at** (u64): the UNIX-style timestamp of the invoice
2022-11-09 03:32:00 +01:00
- **expiry** (u64): the number of seconds this is valid after `created_at`
2021-05-26 07:54:01 +02:00
- **payee** (pubkey): the public key of the recipient
2023-01-30 07:24:17 +01:00
- **payment\_hash** (hash): the hash of the *payment\_preimage*
2021-05-26 07:54:01 +02:00
- **signature** (signature): signature of the *payee* on this invoice
2022-09-05 23:45:06 +02:00
- **min\_final\_cltv\_expiry** (u32): the minimum CLTV delay for the final node
- **amount\_msat** (msat, optional): Amount the invoice asked for
2021-05-26 07:54:01 +02:00
- **description** (string, optional): the description of the purpose of the purchase
2023-01-30 07:24:17 +01:00
- **description\_hash** (hash, optional): the hash of the description, in place of *description*
- **payment\_secret** (secret, optional): the secret to hand to the payee node
2021-05-26 07:54:01 +02:00
- **features** (hex, optional): the features bitmap for this invoice
2022-11-11 03:03:13 +01:00
- **payment\_metadata** (hex, optional): the payment\_metadata to put in the payment
2021-05-26 07:54:01 +02:00
- **fallbacks** (array of objects, optional): onchain addresses:
2023-10-26 05:32:08 +02:00
- **type** (string): the address type (if known) (one of "P2PKH", "P2SH", "P2WPKH", "P2WSH", "P2TR")
2021-05-26 07:54:01 +02:00
- **hex** (hex): Raw encoded address
- **addr** (string, optional): the address in appropriate format for *type*
- **routes** (array of arrays, optional): Route hints to the *payee* :
- hops in the route:
- **pubkey** (pubkey): the public key of the node
2022-09-08 03:08:00 +02:00
- **short\_channel\_id** (short\_channel\_id): a channel to the next peer
2022-09-05 23:45:06 +02:00
- **fee\_base\_msat** (msat): the base fee for payments
- **fee\_proportional\_millionths** (u32): the parts-per-million fee for payments
- **cltv\_expiry\_delta** (u32): the CLTV delta across this hop
2021-05-26 07:54:01 +02:00
- **extra** (array of objects, optional): Any extra fields we didn't know how to parse:
- **tag** (string): The bech32 letter which identifies this field (always 1 characters)
- **data** (string): The bech32 data for this field
2021-09-03 12:07:59 +02:00
2022-07-25 03:23:30 +02:00
If **type** is "rune", and **valid** is *true* :
2022-09-05 23:45:04 +02:00
2022-07-25 03:23:30 +02:00
- **valid** (boolean) (always *true* )
2022-07-16 15:18:27 +02:00
- **string** (string): the string encoding of the rune
- **restrictions** (array of objects): restrictions built into the rune: all must pass:
- **alternatives** (array of strings): each way restriction can be met: any can pass:
- the alternative of form fieldname condition fieldname
- **summary** (string): human-readable summary of this restriction
2022-09-05 23:45:06 +02:00
- **unique\_id** (string, optional): unique id (always a numeric id on runes we create)
2022-07-16 15:18:27 +02:00
- **version** (string, optional): rune version, not currently set on runes we create
2022-07-25 03:23:30 +02:00
If **type** is "rune", and **valid** is *false* :
2022-09-05 23:45:04 +02:00
2022-07-25 03:23:30 +02:00
- **valid** (boolean) (always *false* )
- **hex** (hex, optional): the raw rune in hex
- the following warnings are possible:
2022-09-05 23:45:06 +02:00
- **warning\_rune\_invalid\_utf8**: the rune contains invalid UTF-8 strings
2022-07-16 15:18:27 +02:00
2023-10-26 05:15:50 +02:00
If **type** is "emergency recover", and **valid** is *true* :
- **decrypted** (hex): The decrypted value of the provided bech32 of emergency.recover *(added v23.11)*
2021-05-26 07:54:01 +02:00
[comment]: # (GENERATE-FROM-SCHEMA-END)
2021-01-07 19:48:47 +01:00
AUTHOR
------
Rusty Russell < < rusty @ rustcorp . com . au > > is mainly responsible.
SEE ALSO
--------
2023-01-30 07:04:03 +01:00
lightning-pay(7), lightning-offer(7), lightning-fetchinvoice(7), lightning-sendinvoice(7), lightning-commando-rune(7)
2021-01-07 19:48:47 +01:00
2022-12-09 08:09:07 +01:00
[BOLT #11 ](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md )
2021-01-07 19:48:47 +01:00
2022-12-09 08:09:07 +01:00
[BOLT #12 ](https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md ) (experimental, [bolt ](https://github.com/lightning/bolts ) #798 )
2021-01-07 19:48:47 +01:00
RESOURCES
---------
Main web site: < https: / / github . com / ElementsProject / lightning >
2023-11-24 18:21:42 +01:00
[comment]: # ( SHA256STAMP:59bcc38bf3c4b2aa6f4258c1327d16171c4ba37276ac3a96528a2f12a2ef3ad5)