diff --git a/.github/scripts/sync-rpc-cmds.py b/.github/scripts/sync-rpc-cmds.py index 368f37a077dc..eb915aab4805 100644 --- a/.github/scripts/sync-rpc-cmds.py +++ b/.github/scripts/sync-rpc-cmds.py @@ -5,8 +5,11 @@ from enum import Enum # readme url -URL = "https://api.readme.com/v2/branches/stable" +BRANCH = "stable" +URL = f"https://api.readme.com/v2/branches/{BRANCH}" CATEGORY_SLUG = "JSON-RPC" +NOTIFICATIONS_CATEGORY_SLUG = "Notifications" +HOOKS_CATEGORY_SLUG = "Hooks" class Action(Enum): @@ -15,8 +18,8 @@ class Action(Enum): DELETE = 'delete' -def getListOfRPCDocs(headers): - response = requests.get(f"{URL}/categories/reference/{CATEGORY_SLUG}/pages", headers=headers) +def getListOfDocs(headers, category): + response = requests.get(f"{URL}/categories/reference/{category}/pages", headers=headers) if response.status_code == 200: return response.json().get('data', []) else: @@ -47,15 +50,15 @@ def check_renderable(response, action, title): return True -def publishDoc(action, title, body, position, headers): +def publishDoc(action, title, body, position, headers, category): payload = { - "title": title, + "title": get_display_name(title), "type": "basic", "content": { "body": body, }, "category": { - "uri": f"/branches/stable/categories/reference/{CATEGORY_SLUG}" + "uri": f"/branches/{BRANCH}/categories/reference/{category}" }, "hidden": False, "position": position, @@ -99,18 +102,78 @@ def publishDoc(action, title, body, position, headers): print("Invalid action") -def extract_rpc_commands(rst_content): +def extract_all_from_rst(rst_content): manpages_block = re.search( - r"\.\. block_start manpages(.*?)" r"\.\. block_end manpages", + r"\.\. block_start manpages(.*?)\.\. block_end manpages", rst_content, re.DOTALL, ) - if manpages_block: - commands = re.findall( - r"\b([a-zA-Z0-9_-]+)" r"\s+<([^>]+)>\n", manpages_block.group(1) - ) - return commands - return [] + + if not manpages_block: + return [], [], [] + + entries = re.findall( + r"^\s*([a-zA-Z0-9_-]+)\s+<([^>]+)>", + manpages_block.group(1), + re.MULTILINE, + ) + + rpc_commands = [] + notifications = [] + hooks = [] + + for name, target in entries: + if name.startswith("notification-"): + notifications.append((name, target)) + elif name.startswith("hook-"): + hooks.append((name, target)) + else: + rpc_commands.append((name, target)) + + return rpc_commands, notifications, hooks + + +def sync_docs(local_items, readme_items, category_slug, headers, label): + local_titles = {name for name, _ in local_items} + readme_titles = {item['slug'] for item in readme_items} + + to_delete = readme_titles - local_titles + to_add = local_titles - readme_titles + + # Deletions + for name in to_delete: + publishDoc(Action.DELETE, name, "", 0, headers, category_slug) + sleep(1) + + # Add / Update + if not local_items: + print(f"⚠️ No {label} found in the Manpages block.") + return + + position = 0 + for name, file in local_items: + file_path = os.path.join("doc", file) + + if not os.path.exists(file_path): + print(f"⚠️ WARNING: File not found: {file_path}, skipping {name}") + continue + + with open(file_path) as f: + body = f.read() + + action = Action.ADD if name in to_add else Action.UPDATE + publishDoc(action, name, body, position, headers, category_slug) + + position += 1 + sleep(1) + + +def get_display_name(name): + if name.startswith("notification-"): + return name[len("notification-"):] + if name.startswith("hook-"): + return name[len("hook-"):] + return name def main(): @@ -136,34 +199,34 @@ def main(): with open(path_to_rst, "r") as file: rst_content = file.read() - commands_from_local = extract_rpc_commands(rst_content) - commands_from_readme = getListOfRPCDocs(headers) + commands_from_local, notifications_from_local, hooks_from_local = extract_all_from_rst(rst_content) + commands_from_readme = getListOfDocs(headers, CATEGORY_SLUG) + notifications_from_readme = getListOfDocs(headers, NOTIFICATIONS_CATEGORY_SLUG) + hooks_from_readme = getListOfDocs(headers, HOOKS_CATEGORY_SLUG) + + sync_docs( + commands_from_local, + commands_from_readme, + CATEGORY_SLUG, + headers, + "commands" + ) - # Compare local and server commands list to get the list of command to add or delete - commands_local_title = set(command[0] for command in commands_from_local) - commands_readme_title = set(command['slug'] for command in commands_from_readme) - commands_to_delete = commands_readme_title - commands_local_title - commands_to_add = commands_local_title - commands_readme_title - for name in commands_to_delete: - publishDoc(Action.DELETE, name, "", 0, headers) - sleep(1) + sync_docs( + notifications_from_local, + notifications_from_readme, + NOTIFICATIONS_CATEGORY_SLUG, + headers, + "notifications" + ) - if commands_from_local: - position = 0 - for name, file in commands_from_local: - file_path = "doc/" + file - if not os.path.exists(file_path): - print(f"⚠️ WARNING: File not found: {file_path}, skipping {name}") - continue - - with open(file_path) as f: - body = f.read() - action = Action.ADD if name in commands_to_add else Action.UPDATE - publishDoc(action, name, body, position, headers) - position += 1 - sleep(1) - else: - print("⚠️ No commands found in the Manpages block.") + sync_docs( + hooks_from_local, + hooks_from_readme, + HOOKS_CATEGORY_SLUG, + headers, + "hooks" + ) print("\n✨ Sync complete!") diff --git a/contrib/msggen/msggen/schema.json b/contrib/msggen/msggen/schema.json index 88b241c8e00d..156151cec622 100644 --- a/contrib/msggen/msggen/schema.json +++ b/contrib/msggen/msggen/schema.json @@ -5131,47 +5131,47 @@ "type": "string", "description": [ "This format string is used for each income event (note that `lightning-cli` can get confused if the format begins and ends with `{` and `}`, so you may need to add a space). The following tags in braces are replaced:", - "{account}: account name (channel id, or 'wallet')", - "{tag}: event tag. This will be one of:", - " * `deposit`: an onchain send to the wallet by `outpoint`.", - " * `htlc_fulfill`: an onchain HTLC fulfill (due to unilaterally closed channel) at `outpoint`.", - " * `invoice`: either incoming (positive credit) or outgoing (positive debit) payment.", - " * `invoice_fee`: the routing fee paid to pay an outgoing invoice", - " * `journal_entry`: an accounting fixup, caused by loss of data (or, a node which predates bookkeeper)", - " * `lease_fee`: a fee paid or received to lease a channel via the experimental liquidity advertisement option", - " * `onchain_fee,`: a miner fee paid to open/close a channel, or make a bitcoin payment. The `txid` will correspond to a `withdrawal` `outpoint` for withdrawl", - " * `pushed`: an amount pushed to or from us on channel open.", - " * `rebalance_fee`: routing fee paid for sending a payment to ourselves.", - " * `routed`: credit gained from routing a payment", - " * `withdrawal`: debit from an onchain spend.", - "{description}: description as provided in the invoice, if present", - "{credit}: credit amount in BTC", - "{debit}: debit amount in BTC", - "{fees}: fee amount in BTC", - "{localtime}: event timestamp in local time as YYYY-MM-DD HH:MM:SS", - "{utctime}: event timestamp in UTC as YYYY-MM-DD HH:MM:SS", - "{outpoint}: outpoint, if present", - "{txid}: txid, if present", - "{payment_id}: payment hash, if present", - "{bkpr-currency}: value of bkpr-currency, if any", - "{currencyrate}: exchange rate for 1 BTC at that event time, if available", - "{creditdebit}: +credit or -debit (or 0) in BTC", - "{currencycredit}: credit amount converted into bkpr-currency", - "{currencydebit}: debit amount converted into bkpr-currency", - "{currencycreditdebit}: +credit or -debit (or 0) in bkpr-currency", + " * `{account}`: account name (channel id, or 'wallet')", + " * `{tag}`: event tag. This will be one of:", + " * `deposit`: an onchain send to the wallet by `outpoint`.", + " * `htlc_fulfill`: an onchain HTLC fulfill (due to unilaterally closed channel) at `outpoint`.", + " * `invoice`: either incoming (positive credit) or outgoing (positive debit) payment.", + " * `invoice_fee`: the routing fee paid to pay an outgoing invoice", + " * `journal_entry`: an accounting fixup, caused by loss of data (or, a node which predates bookkeeper)", + " * `lease_fee`: a fee paid or received to lease a channel via the experimental liquidity advertisement option", + " * `onchain_fee,`: a miner fee paid to open/close a channel, or make a bitcoin payment. The `txid` will correspond to a `withdrawal` `outpoint` for withdrawl", + " * `pushed`: an amount pushed to or from us on channel open.", + " * `rebalance_fee`: routing fee paid for sending a payment to ourselves.", + " * `routed`: credit gained from routing a payment", + " * `withdrawal`: debit from an onchain spend.", + " * `{description}`: description as provided in the invoice, if present", + " * `{credit}`: credit amount in BTC", + " * `{debit}`: debit amount in BTC", + " * `{fees}`: fee amount in BTC", + " * `{localtime}`: event timestamp in local time as YYYY-MM-DD HH:MM:SS", + " * `{utctime}`: event timestamp in UTC as YYYY-MM-DD HH:MM:SS", + " * `{outpoint}`: outpoint, if present", + " * `{txid}`: txid, if present", + " * `{payment_id}`: payment hash, if present", + " * `{bkpr-currency}`: value of bkpr-currency, if any", + " * `{currencyrate}`: exchange rate for 1 BTC at that event time, if available", + " * `{creditdebit}`: +credit or -debit (or 0) in BTC", + " * `{currencycredit}`: credit amount converted into bkpr-currency", + " * `{currencydebit}`: debit amount converted into bkpr-currency", + " * `{currencycreditdebit}`: +credit or -debit (or 0) in bkpr-currency", "", - "If a field is unavailable, it expands to an empty string (or 0 for credit, debit, fees and creditdebit).", + " If a field is unavailable, it expands to an empty string (or 0 for credit, debit, fees and creditdebit).", "", - "Tags support C-style conditional syntax: {tag[?if-set][:if-not-set]}", - " * if-set: text to use when the tag is present (and non-zero for credit, debit, fees and creditdebit). Default is the tag value itself.", - " * if-not-set: text to use when the tag is absent (or zero for amount fields). Default is empty string (or 0 for amount fields).", - "Either or both parts may be omitted, and each part can itself contain tags. For example:", - " * {outpoint:NONE}: the outpoint value, or 'NONE' if not available", - " * {credit:0.00}: the credit value, or '0.00' if zero", - " * {outpoint?[{outpoint}]:NONE}: '[]' if outpoint is available, or 'NONE' if not", - " * {payment_id:{txid:UNKNOWN}}: the payment_id, or the txid if no payment_id, or 'UNKNOWN' if neither", + " Tags support C-style conditional syntax: `{tag[?if-set][:if-not-set]}`", + " * if-set: text to use when the tag is present (and non-zero for credit, debit, fees and creditdebit). Default is the tag value itself.", + " * if-not-set: text to use when the tag is absent (or zero for amount fields). Default is empty string (or 0 for amount fields).", + " Either or both parts may be omitted, and each part can itself contain tags. For example:", + " * `{outpoint:NONE}`: the outpoint value, or 'NONE' if not available", + " * `{credit:0.00}`: the credit value, or '0.00' if zero", + " * `{outpoint?[{outpoint}]:NONE}`: `[]` if outpoint is available, or 'NONE' if not", + " * `{payment_id:{txid:UNKNOWN}}`: the payment_id, or the txid if no payment_id, or 'UNKNOWN' if neither", "", - "To include a literal {, write {{." + " To include a literal `{`, write `{{`." ] }, "headers": { @@ -37900,11 +37900,8 @@ "The **balance_snapshot** notification informs whenever lightningd emits a balance snapshot for bookkeeping." ], "added": "v24.11", - "request": { - "added": "v24.11" - }, + "request": {}, "response": { - "added": "v24.11", "required": [ "node_id", "blockheight", @@ -37916,32 +37913,27 @@ "type": "pubkey", "description": [ "The node id the snapshot was taken for." - ], - "added": "v24.11" + ] }, "blockheight": { "type": "u32", "description": [ "The blockheight at which the snapshot was taken." - ], - "added": "v24.11" + ] }, "timestamp": { "type": "u32", "description": [ "The snapshot time as seconds since epoch." - ], - "added": "v24.11" + ] }, "accounts": { "type": "array", "description": [ "The balances for each tracked account at the snapshot time." ], - "added": "v24.11", "items": { "type": "object", - "added": "v24.11", "additionalProperties": false, "required": [ "account_id", @@ -37953,22 +37945,19 @@ "type": "string", "description": [ "The account identifier for the balance." - ], - "added": "v24.11" + ] }, "balance_msat": { "type": "msat", "description": [ "The account balance in millisatoshis." - ], - "added": "v24.11" + ] }, "coin_type": { "type": "string", "description": [ "The BIP173 coin type name for the balance." - ], - "added": "v24.11" + ] } } } @@ -37997,15 +37986,13 @@ "type": "hash", "description": [ "The hash of the block." - ], - "added": "v22.11" + ] }, "height": { "type": "u32", "description": [ "The total block height." - ], - "added": "v22.11" + ] } } } @@ -38030,8 +38017,7 @@ "type": "hash", "description": [ "The channel id of the channel." - ], - "added": "pre-v0.10.1" + ] } } } @@ -38059,29 +38045,25 @@ "type": "pubkey", "description": [ "The id of the peer which opened the channel" - ], - "added": "pre-v0.10.1" + ] }, "funding_msat": { "type": "msat", "description": [ "The amount of the funding transaction" - ], - "added": "pre-v0.10.1" + ] }, "funding_txid": { "type": "txid", "description": [ "The transaction id of the funding transaction" - ], - "added": "pre-v0.10.1" + ] }, "channel_ready": { "type": "boolean", "description": [ "true if the channel is ready" - ], - "added": "pre-v0.10.1" + ] } } } @@ -38093,7 +38075,7 @@ "notification": "channel_state_changed", "title": "Notification for channel state change", "description": [ - "The **channel_state_changed** informs whenever the state of the channel has been updated." + "The **channel_state_changed** notification informs whenever the state of the channel has been updated." ], "added": "pre-v0.10.1", "request": {}, @@ -38110,29 +38092,25 @@ "type": "pubkey", "description": [ "The peer id of the channel." - ], - "added": "pre-v0.10.1" + ] }, "channel_id": { "type": "hash", "description": [ "The channel id of the channel." - ], - "added": "pre-v0.10.1" + ] }, "short_channel_id": { "type": "short_channel_id", "description": [ "The short channel id of the channel. If the channel is not yet confirmed, this field will be null." - ], - "added": "pre-v0.10.1" + ] }, "timestamp": { "type": "string", "description": [ "The timestamp of the state change." - ], - "added": "pre-v0.10.1" + ] }, "old_state": { "type": "string", @@ -38155,8 +38133,7 @@ "description": [ "The channel state, in particular \"CHANNELD_NORMAL\" and \"CHANNELD_AWAITING_SPLICE\" mean the channel can be used normally.", "The deprecated value 'unknown' is also present for new channels: after v26.04 this field will be omitted instead." - ], - "added": "pre-v0.10.1" + ] }, "new_state": { "type": "string", @@ -38178,10 +38155,9 @@ "CLOSED" ], "description": [ - "The channel state, in particular \"CHANNELD_NORMAL\" and \"CHANNELD_AWAITING_SPLICE\" mean the channel can be used normally", + "The channel state, in particular \"CHANNELD_NORMAL\" and \"CHANNELD_AWAITING_SPLICE\" mean the channel can be used normally.", "Note: *CLOSED* state was only added in v25.12." - ], - "added": "pre-v0.10.1" + ] }, "cause": { "type": "string", @@ -38195,15 +38171,13 @@ ], "description": [ "The cause of the state change." - ], - "added": "pre-v0.10.1" + ] }, "message": { "type": "string", "description": [ "The state change message." - ], - "added": "pre-v0.10.1" + ] } } } @@ -38218,11 +38192,8 @@ "The **coin_movement** notification informs whenever lightningd records a finalized ledger movement." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "version", "coin_type", @@ -38240,22 +38211,19 @@ "type": "u32", "description": [ "The coin movement schema version." - ], - "added": "pre-v0.10.1" + ] }, "coin_type": { "type": "string", "description": [ "The BIP173 coin type name." - ], - "added": "pre-v0.10.1" + ] }, "node_id": { "type": "pubkey", "description": [ "The node id that emitted the notification." - ], - "added": "pre-v0.10.1" + ] }, "type": { "type": "string", @@ -38265,8 +38233,7 @@ ], "description": [ "Whether this is a channel or chain movement." - ], - "added": "pre-v0.10.1" + ] }, "created_index": { "type": "u64", @@ -38279,43 +38246,37 @@ "type": "string", "description": [ "The account identifier for the movement." - ], - "added": "pre-v0.10.1" + ] }, "credit_msat": { "type": "msat", "description": [ "Amount credited to the account." - ], - "added": "pre-v0.10.1" + ] }, "debit_msat": { "type": "msat", "description": [ "Amount debited from the account." - ], - "added": "pre-v0.10.1" + ] }, "timestamp": { "type": "u64", "description": [ "The UNIX timestamp when the movement was recorded." - ], - "added": "pre-v0.10.1" + ] }, "tags": { "type": "array", "description": [ "Deprecated legacy combined tag array, emitted only for deprecated output compatibility." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" ], "items": { "type": "string", - "added": "pre-v0.10.1", "description": [ "A legacy movement tag." ] @@ -38361,7 +38322,6 @@ "added": "v25.09", "items": { "type": "string", - "added": "v25.09", "description": [ "An additional movement tag." ] @@ -38371,29 +38331,25 @@ "type": "hash", "description": [ "The payment hash associated with the movement, if any." - ], - "added": "pre-v0.10.1" + ] }, "part_id": { "type": "u64", "description": [ "The part id for a multi-part channel payment." - ], - "added": "pre-v0.10.1" + ] }, "group_id": { "type": "u64", "description": [ "The group id for a multi-part channel payment." - ], - "added": "pre-v0.10.1" + ] }, "fees_msat": { "type": "msat", "description": [ "The fees associated with a channel movement." - ], - "added": "pre-v0.10.1" + ] }, "utxo": { "type": "outpoint", @@ -38406,22 +38362,19 @@ "type": "pubkey", "description": [ "The peer associated with a chain movement, if any." - ], - "added": "pre-v0.10.1" + ] }, "originating_account": { "type": "string", "description": [ "The originating account for an external chain movement, if any." - ], - "added": "pre-v0.10.1" + ] }, "txid": { "type": "txid", "description": [ "Deprecated legacy field for the spending transaction id." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" @@ -38439,7 +38392,6 @@ "description": [ "Deprecated legacy field for the outpoint transaction id." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" @@ -38450,7 +38402,6 @@ "description": [ "Deprecated legacy field for the outpoint output index." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" @@ -38460,22 +38411,19 @@ "type": "msat", "description": [ "The output amount for a chain movement." - ], - "added": "pre-v0.10.1" + ] }, "output_count": { "type": "u32", "description": [ "The number of outputs in the spending transaction, if known." - ], - "added": "pre-v0.10.1" + ] }, "blockheight": { "type": "u32", "description": [ "The blockheight for a chain movement." - ], - "added": "pre-v0.10.1" + ] } }, "allOf": [ @@ -38524,7 +38472,7 @@ "notification": "connect", "title": "Notification for connection with a peer", "description": [ - "The **connect** informs whenever the node is connected to a peer." + "The **connect** notification informs whenever the node is connected to a peer." ], "additionalProperties": false, "added": "pre-v0.10.1", @@ -38540,8 +38488,7 @@ "type": "pubkey", "description": [ "The id of the peer which sent the custom message" - ], - "added": "pre-v0.10.1" + ] }, "direction": { "type": "string", @@ -38551,15 +38498,13 @@ ], "description": [ "Direction of the connection" - ], - "added": "pre-v0.10.1" + ] }, "address": { "type": "object", "description": [ "Address information (mainly useful if **direction** is *out*)" ], - "added": "pre-v0.10.1", "additionalProperties": true, "required": [ "type" @@ -38567,7 +38512,6 @@ "properties": { "type": { "type": "string", - "added": "pre-v0.10.1", "enum": [ "local socket", "ipv4", @@ -38602,7 +38546,6 @@ "type": {}, "socket": { "type": "string", - "added": "pre-v0.10.1", "description": [ "Socket filename" ] @@ -38634,14 +38577,12 @@ "type": {}, "address": { "type": "string", - "added": "pre-v0.10.1", "description": [ "Address in expected format for **type**" ] }, "port": { "type": "u16", - "added": "pre-v0.10.1", "description": [ "Port number" ] @@ -38675,15 +38616,13 @@ "type": "pubkey", "description": [ "The id of the peer which sent the custom message" - ], - "added": "v24.02" + ] }, "payload": { "type": "hex", "description": [ "The hex-encoded payload. The first 2 bytes represent the BOLT-8 message type followed by the message content" - ], - "added": "v24.02" + ] } } } @@ -38698,11 +38637,8 @@ "The **deprecated_oneshot** notification informs a plugin that the immediately following command uses different deprecation handling than the global setting." ], "added": "v24.02", - "request": { - "added": "v24.02" - }, + "request": {}, "response": { - "added": "v24.02", "required": [ "deprecated_ok" ], @@ -38711,8 +38647,7 @@ "type": "boolean", "description": [ "Whether deprecated APIs are allowed for the immediately following command." - ], - "added": "v24.02" + ] } } } @@ -38727,11 +38662,8 @@ "The **disconnect** notification informs whenever the node disconnects from a peer." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "id" ], @@ -38740,8 +38672,7 @@ "type": "pubkey", "description": [ "The id of the peer that disconnected." - ], - "added": "pre-v0.10.1" + ] } } } @@ -38756,11 +38687,8 @@ "The **forward_event** notification informs whenever the status of a forwarded HTLC changes." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "payment_hash", "in_channel", @@ -38773,43 +38701,37 @@ "type": "hash", "description": [ "The payment hash for the forwarded HTLC." - ], - "added": "pre-v0.10.1" + ] }, "in_channel": { "type": "short_channel_id", "description": [ "The inbound channel that received the HTLC." - ], - "added": "pre-v0.10.1" + ] }, "out_channel": { "type": "short_channel_id", "description": [ "The outbound channel used for the forward, if one was selected." - ], - "added": "pre-v0.10.1" + ] }, "in_msat": { "type": "msat", "description": [ "The amount of the incoming HTLC." - ], - "added": "pre-v0.10.1" + ] }, "out_msat": { "type": "msat", "description": [ "The amount forwarded to the outbound channel, if known." - ], - "added": "pre-v0.10.1" + ] }, "fee_msat": { "type": "msat", "description": [ "The fee earned on the forward, if an outbound amount is known." - ], - "added": "pre-v0.10.1" + ] }, "status": { "type": "string", @@ -38821,22 +38743,19 @@ ], "description": [ "The current forwarding status." - ], - "added": "pre-v0.10.1" + ] }, "failcode": { "type": "u32", "description": [ "The BOLT 4 failcode when the forward failed locally." - ], - "added": "pre-v0.10.1" + ] }, "failreason": { "type": "string", "description": [ "The symbolic failcode name when the forward failed locally." - ], - "added": "pre-v0.10.1" + ] }, "style": { "type": "string", @@ -38853,15 +38772,13 @@ "type": "number", "description": [ "The UNIX timestamp when the HTLC was received." - ], - "added": "pre-v0.10.1" + ] }, "resolved_time": { "type": "number", "description": [ "The UNIX timestamp when the HTLC was resolved, if it has been resolved." - ], - "added": "pre-v0.10.1" + ] } } } @@ -38876,11 +38793,8 @@ "The **invoice_creation** notification informs whenever a new invoice is created." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "preimage", "label" @@ -38890,22 +38804,19 @@ "type": "msat", "description": [ "The invoice amount, if the invoice amount was specified at creation time." - ], - "added": "pre-v0.10.1" + ] }, "preimage": { "type": "secret", "description": [ "The payment preimage for the created invoice." - ], - "added": "pre-v0.10.1" + ] }, "label": { "type": "string", "description": [ "The label of the created invoice." - ], - "added": "pre-v0.10.1" + ] } } } @@ -38920,11 +38831,8 @@ "The **invoice_payment** notification informs whenever an invoice is paid." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "msat", "preimage", @@ -38935,15 +38843,13 @@ "type": "msat", "description": [ "The amount paid for the invoice." - ], - "added": "pre-v0.10.1" + ] }, "preimage": { "type": "secret", "description": [ "The payment preimage for the invoice." - ], - "added": "pre-v0.10.1" + ] }, "outpoint": { "type": "outpoint", @@ -38956,8 +38862,7 @@ "type": "string", "description": [ "The label of the paid invoice." - ], - "added": "pre-v0.10.1" + ] } } } @@ -38972,11 +38877,8 @@ "The **log** notification informs whenever lightningd emits a log message and exposes the same payload shape as **warning**." ], "added": "v24.02", - "request": { - "added": "v24.02" - }, + "request": {}, "response": { - "added": "v24.02", "required": [ "level", "time", @@ -38997,36 +38899,31 @@ ], "description": [ "The log level of the emitted message." - ], - "added": "v24.02" + ] }, "time": { "type": "string", "description": [ "The event time as seconds since epoch with subsecond precision." - ], - "added": "v24.02" + ] }, "timestamp": { "type": "string", "description": [ "The event time in ISO 8601 format." - ], - "added": "v24.02" + ] }, "source": { "type": "string", "description": [ "The source component that emitted the log entry." - ], - "added": "v24.02" + ] }, "log": { "type": "string", "description": [ "The original log message." - ], - "added": "v24.02" + ] } } } @@ -39041,11 +38938,8 @@ "The **onionmessage_forward_fail** notification informs whenever lightningd cannot forward an onion message." ], "added": "v24.11", - "request": { - "added": "v24.11" - }, + "request": {}, "response": { - "added": "v24.11", "required": [ "source", "incoming", @@ -39056,43 +38950,37 @@ "type": "pubkey", "description": [ "The node that sent the incoming onion message." - ], - "added": "v24.11" + ] }, "incoming": { "type": "hex", "description": [ "The incoming onion message payload." - ], - "added": "v24.11" + ] }, "path_key": { "type": "pubkey", "description": [ "The path key used for the attempted forward." - ], - "added": "v24.11" + ] }, "outgoing": { "type": "hex", "description": [ "The outgoing onion message payload if a next hop had already been selected." - ], - "added": "v24.11" + ] }, "next_node_id": { "type": "pubkey", "description": [ "The next node id for the attempted forward when the next hop is a node." - ], - "added": "v24.11" + ] }, "next_short_channel_id_dir": { "type": "short_channel_id_dir", "description": [ "The next short_channel_id_dir for the attempted forward when the next hop is a channel." - ], - "added": "v24.11" + ] } } } @@ -39107,11 +38995,8 @@ "The **openchannel_peer_sigs** notification informs whenever a peer provides signatures for an in-progress channel open." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "channel_id", "signed_psbt" @@ -39121,15 +39006,13 @@ "type": "hash", "description": [ "The channel id for the channel open attempt." - ], - "added": "pre-v0.10.1" + ] }, "signed_psbt": { "type": "string", "description": [ "The signed PSBT from the peer." - ], - "added": "pre-v0.10.1" + ] } } } @@ -39144,11 +39027,8 @@ "The **plugin_started** notification informs whenever a plugin has started and registered its methods." ], "added": "v25.02", - "request": { - "added": "v25.02" - }, + "request": {}, "response": { - "added": "v25.02", "required": [ "plugin_name", "plugin_path", @@ -39159,28 +39039,24 @@ "type": "string", "description": [ "The short name of the plugin." - ], - "added": "v25.02" + ] }, "plugin_path": { "type": "string", "description": [ "The executable path of the plugin." - ], - "added": "v25.02" + ] }, "methods": { "type": "array", "description": [ "The RPC methods registered by the plugin." ], - "added": "v25.02", "items": { "type": "string", "description": [ "A method registered by the plugin." - ], - "added": "v25.02" + ] } } } @@ -39196,11 +39072,8 @@ "The **plugin_stopped** notification informs whenever a plugin stops and exposes the same payload shape as **plugin_started**." ], "added": "v25.02", - "request": { - "added": "v25.02" - }, + "request": {}, "response": { - "added": "v25.02", "required": [ "plugin_name", "plugin_path", @@ -39211,28 +39084,24 @@ "type": "string", "description": [ "The short name of the plugin." - ], - "added": "v25.02" + ] }, "plugin_path": { "type": "string", "description": [ "The executable path of the plugin." - ], - "added": "v25.02" + ] }, "methods": { "type": "array", "description": [ "The RPC methods registered by the plugin." ], - "added": "v25.02", "items": { "type": "string", "description": [ "A method registered by the plugin." - ], - "added": "v25.02" + ] } } } @@ -39248,11 +39117,8 @@ "The **sendpay_failure** notification informs whenever a payment attempt completes with failed status." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "code", "message", @@ -39263,15 +39129,13 @@ "type": "integer", "description": [ "The JSON-RPC error code for the payment failure." - ], - "added": "pre-v0.10.1" + ] }, "message": { "type": "string", "description": [ "The human-readable payment failure message." - ], - "added": "pre-v0.10.1" + ] }, "data": { "type": "object", @@ -39279,7 +39143,6 @@ "description": [ "The structured payment failure details." ], - "added": "pre-v0.10.1", "properties": { "created_index": { "type": "u64", @@ -39292,22 +39155,19 @@ "type": "u64", "description": [ "Old synonym for created_index." - ], - "added": "pre-v0.10.1" + ] }, "payment_hash": { "type": "hash", "description": [ "The hash of the payment preimage." - ], - "added": "pre-v0.10.1" + ] }, "groupid": { "type": "u64", "description": [ "Grouping key for multiple attempts on the same payment." - ], - "added": "pre-v0.10.1" + ] }, "updated_index": { "type": "u64", @@ -39320,43 +39180,37 @@ "type": "u64", "description": [ "Part number for a multi-part payment." - ], - "added": "pre-v0.10.1" + ] }, "destination": { "type": "pubkey", "description": [ "The final destination of the payment, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_msat": { "type": "msat", "description": [ "The amount intended for the destination, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_sent_msat": { "type": "msat", "description": [ "The total amount sent including fees." - ], - "added": "pre-v0.10.1" + ] }, "created_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment was initiated." - ], - "added": "pre-v0.10.1" + ] }, "completed_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment completed." - ], - "added": "pre-v0.10.1" + ] }, "status": { "type": "string", @@ -39367,29 +39221,25 @@ ], "description": [ "The terminal status for a failed sendpay notification." - ], - "added": "pre-v0.10.1" + ] }, "payment_preimage": { "type": "secret", "description": [ "The payment preimage, if the payment later completed through another path." - ], - "added": "pre-v0.10.1" + ] }, "label": { "type": "string", "description": [ "The optional label associated with the payment." - ], - "added": "pre-v0.10.1" + ] }, "bolt11": { "type": "string", "description": [ "The bolt11 invoice string, if present." - ], - "added": "pre-v0.10.1" + ] }, "bolt12": { "type": "string", @@ -39402,71 +39252,61 @@ "type": "string", "description": [ "The description associated with the payment, if present." - ], - "added": "pre-v0.10.1" + ] }, "erroronion": { "type": "hex", "description": [ "The raw error onion if one was retained for the payment." - ], - "added": "pre-v0.10.1" + ] }, "onionreply": { "type": "hex", "description": [ "The onion reply for an unparseable onion failure." - ], - "added": "pre-v0.10.1" + ] }, "erring_index": { "type": "u32", "description": [ "The position in the route where the failure occurred." - ], - "added": "pre-v0.10.1" + ] }, "failcode": { "type": "u32", "description": [ "The BOLT 4 failcode." - ], - "added": "pre-v0.10.1" + ] }, "failcodename": { "type": "string", "description": [ "The symbolic name for the failcode, if known." - ], - "added": "pre-v0.10.1" + ] }, "erring_node": { "type": "pubkey", "description": [ "The node that produced the failure, if known." - ], - "added": "pre-v0.10.1" + ] }, "erring_channel": { "type": "short_channel_id", "description": [ "The channel that produced the failure, if known." - ], - "added": "pre-v0.10.1" + ] }, "erring_direction": { "type": "u32", "description": [ "The direction within the erring channel." - ], - "added": "pre-v0.10.1" + ] }, "raw_message": { "type": "hex", "description": [ "The raw failure message payload, if present." - ], - "added": "pre-v0.10.1" + ] } } } @@ -39483,11 +39323,8 @@ "The **sendpay_success** notification informs whenever a payment attempt completes successfully." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "created_index", "id", @@ -39509,22 +39346,19 @@ "type": "u64", "description": [ "Old synonym for created_index." - ], - "added": "pre-v0.10.1" + ] }, "payment_hash": { "type": "hash", "description": [ "The hash of the payment preimage." - ], - "added": "pre-v0.10.1" + ] }, "groupid": { "type": "u64", "description": [ "Grouping key for multiple attempts on the same payment." - ], - "added": "pre-v0.10.1" + ] }, "updated_index": { "type": "u64", @@ -39537,43 +39371,37 @@ "type": "u64", "description": [ "Part number for a multi-part payment." - ], - "added": "pre-v0.10.1" + ] }, "destination": { "type": "pubkey", "description": [ "The final destination of the payment, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_msat": { "type": "msat", "description": [ "The amount delivered to the destination, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_sent_msat": { "type": "msat", "description": [ "The total amount sent including fees." - ], - "added": "pre-v0.10.1" + ] }, "created_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment was initiated." - ], - "added": "pre-v0.10.1" + ] }, "completed_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment completed." - ], - "added": "pre-v0.10.1" + ] }, "status": { "type": "string", @@ -39582,29 +39410,25 @@ ], "description": [ "The terminal status for a successful sendpay notification." - ], - "added": "pre-v0.10.1" + ] }, "payment_preimage": { "type": "secret", "description": [ "The payment preimage proving success." - ], - "added": "pre-v0.10.1" + ] }, "label": { "type": "string", "description": [ "The optional label associated with the payment." - ], - "added": "pre-v0.10.1" + ] }, "bolt11": { "type": "string", "description": [ "The bolt11 invoice string, if present." - ], - "added": "pre-v0.10.1" + ] }, "bolt12": { "type": "string", @@ -39617,15 +39441,13 @@ "type": "string", "description": [ "The description associated with the payment, if present." - ], - "added": "pre-v0.10.1" + ] }, "erroronion": { "type": "hex", "description": [ "The raw error onion if one was retained for the payment." - ], - "added": "pre-v0.10.1" + ] } } } @@ -39637,14 +39459,14 @@ "notification": "shutdown", "title": "Notification for plugin shutdown", "description": [ - "The **shutdown** notification informs a plugin that lightningd is shutting down." + "The **shutdown** notification informs a plugin that lightningd is shutting down.", + "", + "It is expected that the plugin terminates it's own process when subscribing to this notification.", + "If it does not do so, lightningd will kill the plugin's process after a timeout." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "properties": {} } }, @@ -39658,11 +39480,8 @@ "The **warning** notification informs whenever lightningd emits a warning or error level event that should be surfaced to plugins." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "level", "time", @@ -39679,15 +39498,13 @@ ], "description": [ "The log level of the warning notification." - ], - "added": "pre-v0.10.1" + ] }, "time": { "type": "string", "description": [ "The event time as seconds since epoch with subsecond precision." - ], - "added": "pre-v0.10.1" + ] }, "timestamp": { "type": "string", @@ -39700,15 +39517,13 @@ "type": "string", "description": [ "The source component that emitted the log entry." - ], - "added": "pre-v0.10.1" + ] }, "log": { "type": "string", "description": [ "The original log message." - ], - "added": "pre-v0.10.1" + ] } } } @@ -39723,11 +39538,8 @@ "The **pay_part_end** notification is emitted by the xpay plugin when a payment part completes." ], "added": "v25.09", - "request": { - "added": "v25.09" - }, + "request": {}, "response": { - "added": "v25.09", "required": [ "status", "duration", @@ -39744,78 +39556,67 @@ ], "description": [ "Whether the payment part succeeded or failed." - ], - "added": "v25.09" + ] }, "duration": { "type": "number", "description": [ "The time in seconds from send to result." - ], - "added": "v25.09" + ] }, "payment_hash": { "type": "hash", "description": [ "The payment hash for the xpay invocation." - ], - "added": "v25.09" + ] }, "groupid": { "type": "u64", "description": [ "The xpay group identifier for the payment attempt." - ], - "added": "v25.09" + ] }, "partid": { "type": "u64", "description": [ "The identifier for this payment part." - ], - "added": "v25.09" + ] }, "failed_msg": { "type": "hex", "description": [ "The decrypted onion error message, if available." - ], - "added": "v25.09" + ] }, "failed_node_id": { "type": "pubkey", "description": [ "The node that generated the failure, if known." - ], - "added": "v25.09" + ] }, "failed_short_channel_id": { "type": "short_channel_id", "description": [ "The short channel id complained about, if known." - ], - "added": "v25.09" + ] }, "failed_direction": { "type": "u32", "description": [ "The direction within the failed short channel id, if known." - ], - "added": "v25.09" + ] }, "error_code": { "type": "u32", "description": [ "The xpay error code, if known." - ], - "added": "v25.09" + ] }, "error_message": { "type": "string", "description": [ "The human-readable xpay error message." - ], - "added": "v25.09" + ] } } } @@ -39830,11 +39631,8 @@ "The **pay_part_start** notification is emitted by the xpay plugin when a payment part begins." ], "added": "v25.09", - "request": { - "added": "v25.09" - }, + "request": {}, "response": { - "added": "v25.09", "required": [ "payment_hash", "groupid", @@ -39848,46 +39646,39 @@ "type": "hash", "description": [ "The payment hash for the xpay invocation." - ], - "added": "v25.09" + ] }, "groupid": { "type": "u64", "description": [ "The xpay group identifier for the payment attempt." - ], - "added": "v25.09" + ] }, "partid": { "type": "u64", "description": [ "The identifier for this payment part." - ], - "added": "v25.09" + ] }, "total_payment_msat": { "type": "msat", "description": [ "The total payment amount for the xpay invocation." - ], - "added": "v25.09" + ] }, "attempt_msat": { "type": "msat", "description": [ "The amount this payment part attempts to deliver." - ], - "added": "v25.09" + ] }, "hops": { "type": "array", "description": [ "The route hops for this payment part." ], - "added": "v25.09", "items": { "type": "object", - "added": "v25.09", "additionalProperties": false, "required": [ "next_node", @@ -39901,36 +39692,31 @@ "type": "pubkey", "description": [ "The next node for this hop." - ], - "added": "v25.09" + ] }, "short_channel_id": { "type": "short_channel_id", "description": [ "The short channel id used for this hop." - ], - "added": "v25.09" + ] }, "direction": { "type": "u32", "description": [ "The direction within the short channel id." - ], - "added": "v25.09" + ] }, "channel_in_msat": { "type": "msat", "description": [ "The amount entering the hop." - ], - "added": "v25.09" + ] }, "channel_out_msat": { "type": "msat", "description": [ "The amount leaving the hop." - ], - "added": "v25.09" + ] } } } @@ -39944,7 +39730,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "commitment_revocation", + "hook": "commitment_revocation", "title": "Hook fired when a commitment transaction is revoked", "description": [ "The **commitment_revocation** hook is called whenever a channel state is updated, and the old state was revoked. State updates in Lightning consist of the following steps:", @@ -40019,7 +39805,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "custommsg", + "hook": "custommsg", "title": "Hook for handling custom peer messages", "description": [ "The **custommsg** hook is the receiving counterpart to the sendcustommsg RPC method and is called whenever a peer sends a custom message that is not handled internally by Core Lightning.", @@ -40083,7 +39869,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "db_write", + "hook": "db_write", "title": "Hook fired before database writes are committed", "description": [ "The **db_write** hook is called whenever a change is about to be committed to the database, if you are using a SQLITE3 database (the default).", @@ -40172,7 +39958,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "htlc_accepted", + "hook": "htlc_accepted", "title": "Hook for handling incoming HTLCs", "description": [ "The **htlc_accepted** hook is called whenever an incoming HTLC is accepted.", @@ -40493,7 +40279,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "invoice_payment", + "hook": "invoice_payment", "title": "Hook fired when a payment for an invoice is received", "description": [ "The **invoice_payment** hook is called whenever a valid payment for an unpaid invoice has arrived.", @@ -40501,8 +40287,8 @@ "The hook is deliberately sparse. Plugins can use `listinvoices` to retrieve additional information.", "", "The plugin can:", - "- accept the payment by returning {\"result\": \"continue\"}", - "- reject the payment with a generic error using {\"result\": \"reject\"}", + "- accept the payment by returning `{\"result\": \"continue\"}`", + "- reject the payment with a generic error using `{\"result\": \"reject\"}`", "- reject the payment with a custom BOLT 4 failure message using the `failure_message` field", "", "If `failure_message` is provided, the payment will be failed with that message.", @@ -40607,14 +40393,14 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "onion_message_recv", + "hook": "onion_message_recv", "title": "Hook for receiving unsolicited onion messages", "description": [ "The **onion_message_recv** hook is used for unsolicited onion messages (where the source knows that it is sending to this node).", "", "Replies MUST be ignored unless they use the correct path (see onion_message_recv_secret).", "", - "Returning anything other than {\"result\": \"continue\"} prevents further hook processing." + "Returning anything other than `{\"result\": \"continue\"}` prevents further hook processing." ], "request": { "required": [ @@ -40778,7 +40564,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "onion_message_recv_secret", + "hook": "onion_message_recv_secret", "title": "Hook for receiving onion messages via blinded paths", "description": [ "The **onion_message_recv_secret** hook is used when an onion message is received via a blinded path previously provided by this node.", @@ -40787,7 +40573,7 @@ "", "Replies MUST only be sent when the `pathsecret` matches expectations.", "", - "Returning anything other than {\"result\": \"continue\"} prevents further hook processing." + "Returning anything other than `{\"result\": \"continue\"}` prevents further hook processing." ], "request": { "required": [ @@ -40963,7 +40749,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel", + "hook": "openchannel", "title": "Hook fired when a peer proposes opening a channel using v1 protocol", "description": [ "The **openchannel** hook is called whenever a remote peer tries to fund a channel using the v1 protocol, after passing basic sanity checks.", @@ -41189,7 +40975,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel2", + "hook": "openchannel2", "title": "Hook fired when a peer proposes opening a channel using v2 protocol", "description": [ "The **openchannel2** hook is called whenever a remote peer tries to fund a channel using the v2 (dual-funding) protocol, after passing basic sanity checks.", @@ -41478,7 +41264,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel2_changed", + "hook": "openchannel2_changed", "title": "Hook for handling updates to the dual-funding PSBT", "description": [ "The **openchannel2_changed** hook is called when the peer sends an updated PSBT during dual-funding channel negotiation.", @@ -41578,7 +41364,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel2_sign", + "hook": "openchannel2_sign", "title": "Hook for signing the dual-funding PSBT", "description": [ "The **openchannel2_sign** hook is called after commitment transactions have been received during dual-funding channel establishment.", @@ -41647,7 +41433,7 @@ } } }, - "example_notifications": [ + "example_hooks": [ { "method": "openchannel2_sign", "params": { @@ -41681,7 +41467,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "peer_connected", + "hook": "peer_connected", "title": "Hook fired when a peer connects and completes handshake", "description": [ "The **peer_connected** hook is called whenever a peer has connected and successfully completed the cryptographic handshake.", @@ -41777,7 +41563,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "rbf_channel", + "hook": "rbf_channel", "title": "Hook for handling RBF channel funding requests", "description": [ "The **rbf_channel** hook is called when a peer proposes replacing the funding transaction of an existing channel using Replace-By-Fee (RBF).", @@ -41934,7 +41720,7 @@ "$schema": "../rpc-schema-draft.json", "added": "v23.08", "type": "object", - "notification": "recover", + "hook": "recover", "title": "Hook fired when node starts in recovery mode", "description": [ "The **recover** hook is called whenever the node is started using the --recovery flag.", @@ -41981,7 +41767,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "rpc_command", + "hook": "rpc_command", "title": "Hook for intercepting and modifying RPC commands", "description": [ "The **rpc_command** hook allows a plugin to take over any RPC command.", diff --git a/doc/Makefile b/doc/Makefile index fbf4b64d749b..c430de68c693 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -160,6 +160,23 @@ MARKDOWNPAGES := doc/addgossip.7 \ doc/withdraw.7 \ doc/xpay.7 +NOTIFICATION_SCHEMAS := $(wildcard doc/schemas/notification/*.json) +NOTIFICATION_MARKDOWNPAGES := $(patsubst doc/schemas/notification/%.json,doc/notification-%.7,$(NOTIFICATION_SCHEMAS)) + +HOOK_SCHEMAS := $(wildcard doc/schemas/hook/*.json) +HOOK_MARKDOWNPAGES := $(patsubst doc/schemas/hook/%.json,doc/hook-%.7,$(HOOK_SCHEMAS)) + +MARKDOWNPAGES += $(NOTIFICATION_MARKDOWNPAGES) $(HOOK_MARKDOWNPAGES) + +$(foreach s,$(wildcard doc/schemas/*.json), \ + $(eval doc/$(basename $(notdir $(s))).7.md: $(s))) + +$(foreach s,$(wildcard doc/schemas/notification/*.json), \ + $(eval doc/notification-$(basename $(notdir $(s))).7.md: $(s))) + +$(foreach s,$(wildcard doc/schemas/hook/*.json), \ + $(eval doc/hook-$(basename $(notdir $(s))).7.md: $(s))) + ifeq ($(HAVE_SQLITE3),1) MARKDOWNPAGES += doc/listsqlschemas.7 doc/sql.7 endif @@ -188,7 +205,7 @@ doc/schemas/sql.json: doc/schemas/sql-template.json plugins/sql doc-all: $(MANPAGES) doc/index.rst -SCHEMAS := $(wildcard doc/schemas/*.json) $(wildcard doc/schemas/notification/*.json) $(wildcard doc/schemas/hook/*.json) +SCHEMAS := $(wildcard doc/schemas/*.json) $(NOTIFICATION_SCHEMAS) $(HOOK_SCHEMAS) # Don't try to build sql.json tables with plugins/sql if we don't have sqlite3 ifeq ($(HAVE_SQLITE3),0) @@ -210,8 +227,29 @@ check-doc: check-config-docs check-manpages check-fmt-schemas LBRACKET=( RBRACKET=) -$(MARKDOWNPAGES_WITH_EXT): doc/%.7.md: doc/schemas/%.json tools/fromschema.py - @tools/fromschema.py --markdownfile=$@ $< > $@.tmp && mv $@.tmp $@ +doc/sql.7.md: doc/schemas/sql.json + +$(MARKDOWNPAGES_WITH_EXT): doc/%.7.md: tools/fromschema.py + @base="$*"; \ + json="doc/schemas/$$base.json"; \ + if [ ! -f "$$json" ]; then \ + case "$$base" in \ + notification-*) \ + name=$${base#notification-}; \ + json="doc/schemas/notification/$$name.json"; \ + ;; \ + hook-*) \ + name=$${base#hook-}; \ + json="doc/schemas/hook/$$name.json"; \ + ;; \ + esac; \ + fi; \ + if [ ! -f "$$json" ]; then \ + echo "No schema found for $@ (looked for $$json)"; \ + exit 1; \ + fi; \ + tools/fromschema.py --markdownfile=$@ $$json > $@.tmp && mv $@.tmp $@ + LOWDOWN := lowdown diff --git a/doc/developers-guide/plugin-development/event-notifications.md b/doc/developers-guide/plugin-development/event-notifications.md index 148719d60bae..ce16cd78f048 100644 --- a/doc/developers-guide/plugin-development/event-notifications.md +++ b/doc/developers-guide/plugin-development/event-notifications.md @@ -10,651 +10,10 @@ Event notifications allow a plugin to subscribe to events in `lightningd`. `ligh > > Notifications are not confirmable by definition, since they do not have a Response object to be returned. As such, the Client would not be aware of any errors (like e.g. "Invalid params","Internal error"). -Plugins subscribe by returning an array of subscriptions as part of the `getmanifest` response. The result for the `getmanifest` call above for example subscribes to the two topics `connect` and `disconnect`. The topics that are currently defined and the corresponding payloads are listed below. +Plugins subscribe by returning an array of subscriptions as part of the `getmanifest` response. The result for the `getmanifest` call above for example subscribes to the two topics `connect` and `disconnect`. > 📘 > > This is a way of specifying that you want to subscribe to all possible event notifications. It is not recommended, but is useful for plugins which want to provide generic infrastructure for others (in future, we may add the ability to dynamically subscribe/unsubscribe). -### `deprecated_oneshot` - -(Added in *v24.02*) - -This is a special notification, which the plugin will only receive it it set `deprecated_oneshot` to `true` in its getmanifest response. It indicates that the immeditately following command wants a different deprecation status than the global `allow-deprecated-apis` setting. - -This is possible because of the `deprecations` RPC command, where individual connections can change their deprecation settings. - -```json -{ - "deprecated_oneshot": { - "deprecated_ok": false - } -} -``` - -### `channel_opened` - -A notification for topic `channel_opened` is sent if a peer successfully funded a channel with us. It contains the peer id, the funding amount (in millisatoshis), the funding transaction id, and a boolean indicating if the funding transaction has been included into a block. - -```json -{ - "channel_opened": { - "id": "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f", - "funding_msat": 100000000, - "funding_txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", - "channel_ready": false - } -} -``` - -### `channel_open_failed` - -A notification to indicate that a channel open attempt has been unsuccessful. -Useful for cleaning up state for a v2 channel open attempt. See `plugins/funder.c` for an example of how to use this. - -```json -{ - "channel_open_failed": { - "channel_id": "a2d0851832f0e30a0cf...", - } -} -``` - -### `channel_state_changed` - -A notification for topic `channel_state_changed` is sent every time a channel changes its state. The notification includes the `peer_id` and `channel_id`, the old and new channel states, the type of `cause` and a `message`. - -```json -{ - "channel_state_changed": { - "peer_id": "03bc9337c7a28bb784d67742ebedd30a93bacdf7e4ca16436ef3798000242b2251", - "channel_id": "a2d0851832f0e30a0cf778a826d72f077ca86b69f72677e0267f23f63a0599b4", - "short_channel_id" : "561820x1020x1", - "timestamp":"2023-01-05T18:27:12.145Z", - "old_state": "CHANNELD_NORMAL", - "new_state": "CHANNELD_SHUTTING_DOWN", - "cause" : "remote", - "message" : "Peer closes channel" - } -} -``` - -A `cause` can have the following values: - -- "unknown" Anything other than the reasons below. Should not happen. -- "local" Unconscious internal reasons, e.g. dev fail of a channel. -- "user" The operator or a plugin opened or closed a channel by intention. -- "remote" The remote closed or funded a channel with us by intention. -- "protocol" We need to close a channel because of bad signatures and such. -- "onchain" A channel was closed onchain, while we were offline. - -Most state changes are caused subsequentially for a prior state change, e.g. "_CLOSINGD\_COMPLETE_" is followed by "_FUNDING\_SPEND\_SEEN_". Because of this, the `cause` reflects the last known reason in terms of local or remote user interaction, protocol reasons, etc. More specifically, a `new_state` "_FUNDING\_SPEND_SEEN_" will likely _not_ have "onchain" as a `cause` but some value such as "REMOTE" or "LOCAL" depending on who initiated the closing of a channel. - -Note: If the channel is not closed or being closed yet, the `cause` will reflect which side "remote" or "local" opened the channel. - -Note: If the cause is "onchain" this was very likely a conscious decision of the remote peer, but we have been offline. - -### `connect` - -A notification for topic `connect` is sent every time a new connection to a peer is established. `direction` is either `"in"` or `"out"`. - -```json -{ - "connect" : { - "address" : { - "address" : "127.0.0.1", - "port" : 38012, - "type" : "ipv4" - }, - "direction" : "in", - "id" : "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59" - } -} -``` - -### `disconnect` - -A notification for topic `disconnect` is sent every time a connection to a peer was lost. - -```json -{ - "disconnect": { - "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432" - } -} -``` - -### `custommsg` - -A notification for topic `custommsg` is sent when the node receives a `custommsg`. -```json -{ - "custommsg" : { - "peer_id" : "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432", - "payload" : "1337ffffffff" - } -} -``` - -This `payload` represents a `custommsg` that was send by the peer whose `node_id` matches -`peer_id`. The message has type `0x1337` and contents `ffffffff`. - -To avoid conflicts with internal state-tracking, unexpected disconnections and channel-closures -the messages are currently limited to odd-numbered messages that can be safely ignored by -other nodes (see ["it's ok to be odd" in the specification](https://github.com/lightning/bolts/blob/c74a3bbcf890799d343c62cb05fcbcdc952a1cf3/01-messaging.md#lightning-message-format) -for details). - -The plugin must implement the parsing of the message including the type prefix. - -### `invoice_payment` - -A notification for topic `invoice_payment` is sent every time an invoice is paid. - -```json -{ - "invoice_payment": { - "label": "unique-label-for-invoice", - "preimage": "0000000000000000000000000000000000000000000000000000000000000000", - "msat": 10000, - } -} - -``` - -Before version `23.11` the `msat` field was a string with msat-suffix, e.g: `"10000msat"`. - -Note that there will be a string member "outpoint" ("txid:outnum") if -the payment was onchain (possible with the *invoices-onchain-fallback* -config option). - -### `invoice_creation` - -A notification for topic `invoice_creation` is sent every time an invoice is created. - -```json -{ - "invoice_creation": { - "label": "unique-label-for-invoice", - "preimage": "0000000000000000000000000000000000000000000000000000000000000000", - "msat": 10000 - } -} -``` - -Before version `23.11` the `msat` field was a string with msat-suffix, e.g: `"10000msat"`. - -### `warning` - -A notification for topic `warning` is sent every time a new `BROKEN`/`UNUSUAL` level(in plugins, we use `error`/`warn`) log generated, which means an unusual/borken thing happens, such as channel failed, message resolving failed... - -```json -{ - "warning": { - "level": "warn", - "time": "1559743608.565342521", - "source": "lightningd(17652): 0821f80652fb840239df8dc99205792bba2e559a05469915804c08420230e23c7c chan #7854:", - "log": "Peer permanent failure in CHANNELD_NORMAL: lightning_channeld: sent ERROR bad reestablish dataloss msg" - } -} -``` - -1. `level` is `warn` or `error`: `warn` means something seems bad happened and it's under control, but we'd better check it; `error` means something extremely bad is out of control, and it may lead to crash; -2. `time` is the second since epoch; -3. `source` means where the event happened, it may have the following forms: - ` chan #:`,`lightningd():`, - `plugin-:`, `():`, `jsonrpc:`, - `jcon fd :`, `plugin-manager`; -4. `log` is the context of the original log entry. - -There is also a more general version of this notification called `log`, which has the same payload. This needs to be used with caution, but it is useful for plugins that report logs remotely. For example: using OpenTelemetry. - -### `forward_event` - -A notification for topic `forward_event` is sent every time the status of a forward payment is set. The json format is same as the API `listforwards`. - -```json -{ - "forward_event": { - "payment_hash": "f5a6a059a25d1e329d9b094aeeec8c2191ca037d3f5b0662e21ae850debe8ea2", - "in_channel": "103x2x1", - "out_channel": "103x1x1", - "in_msat": 100001001, - "out_msat": 100000000, - "fee_msat": 1001, - "status": "settled", - "received_time": 1560696342.368, - "resolved_time": 1560696342.556, - "preimage": "0000000000000000000000000000000000000000000000000000000000000000" - } -} -``` - -or - -```json -{ - "forward_event": { - "payment_hash": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "in_channel": "103x2x1", - "out_channel": "110x1x0", - "in_msat": 100001001, - "out_msat": 100000000, - "fee_msat": 1001, - "status": "local_failed", - "failcode": 16392, - "failreason": "WIRE_PERMANENT_CHANNEL_FAILURE", - "received_time": 1560696343.052 - } -} - -``` - -- The status includes `offered`, `settled`, `failed` and `local_failed`, and they are all string type in json. - - When the forward payment is valid for us, we'll set `offered` and send the forward payment to next hop to resolve; - - When the payment forwarded by us gets paid eventually, the forward payment will change the status from `offered` to `settled`; - - If payment fails locally(like failing to resolve locally) or the corresponding htlc with next hop fails(like htlc timeout), we will set the status as `local_failed`. `local_failed` may be set before setting `offered` or after setting `offered`. In fact, from the - time we receive the htlc of the previous hop, all we can know the cause of the failure is treated as `local_failed`. `local_failed` only occuors locally or happens in the htlc between us and next hop; - - If `local_failed` is set before `offered`, this means we just received htlc from the previous hop and haven't generate htlc for next hop. In this case, the json of `forward_event` sets the fields of `out_msatoshi`, `out_msat`,`fee` and `out_channel` as 0; - - Note: In fact, for this case we may be not sure if this incoming htlc represents a pay to us or a payment we need to forward. We just simply treat all incoming failed to resolve as `local_failed`. - - Only in `local_failed` case, json includes `failcode` and `failreason` fields; - - `failed` means the payment forwarded by us fails in the latter hops, and the failure isn't related to us, so we aren't accessed to the fail reason. `failed` must be set after - `offered`. - - `failed` case doesn't include `failcode` and `failreason` - fields; -- `received_time` means when we received the htlc of this payment from the previous peer. It will be contained into all status case; -- `resolved_time` means when the htlc of this payment between us and the next peer was resolved. The resolved result may success or fail, so only `settled` and `failed` case contain `resolved_time`; -- `preimage` is the 64-hex-char payment preimage revealed when the HTLC was fulfilled. Only present when `status` is `settled`; -- The `failcode` and `failreason` are defined in [BOLT 4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#failure-messages). - -### `sendpay_success` - -A notification for topic `sendpay_success` is sent every time a sendpay succeeds (with `complete` status). The json is the same as the return value of the commands `sendpay`/`waitsendpay` when these commands succeed. - -```json -{ - "sendpay_success": { - "id": 1, - "payment_hash": "5c85bf402b87d4860f4a728e2e58a2418bda92cd7aea0ce494f11670cfbfb206", - "destination": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", - "amount_msat": 100000000, - "amount_sent_msat": 100001001, - "created_at": 1561390572, - "status": "complete", - "payment_preimage": "9540d98095fd7f37687ebb7759e733934234d4f934e34433d4998a37de3733ee" - } -} -``` - -`sendpay` doesn't wait for the result of sendpay and `waitsendpay` returns the result of sendpay in specified time or timeout, but `sendpay_success` will always return the result anytime when sendpay successes if is was subscribed. - -### `sendpay_failure` - -A notification for topic `sendpay_failure` is sent every time a sendpay completes with `failed` status. The JSON is same as the return value of the commands `sendpay`/`waitsendpay` when these commands fail. - -```json -{ - "sendpay_failure": { - "code": 204, - "message": "failed: WIRE_UNKNOWN_NEXT_PEER (reply from remote)", - "data": { - "id": 2, - "payment_hash": "9036e3bdbd2515f1e653cb9f22f8e4c49b73aa2c36e937c926f43e33b8db8851", - "destination": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", - "amount_msat": 100000000, - "amount_sent_msat": 100001001, - "created_at": 1561395134, - "status": "failed", - "erring_index": 1, - "failcode": 16394, - "failcodename": "WIRE_UNKNOWN_NEXT_PEER", - "erring_node": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", - "erring_channel": "103x2x1", - "erring_direction": 0 - } - } -} -``` - -`sendpay` doesn't wait for the result of sendpay and `waitsendpay` returns the result of sendpay in specified time or timeout, but `sendpay_failure` will always return the result anytime when sendpay fails if is was subscribed. - -### `coin_movement` - -A notification for topic `coin_movement` is sent to record the movement of coins. It is only triggered by finalized ledger updates, i.e. only definitively resolved HTLCs or confirmed bitcoin transactions. - -```json -{ - "coin_movement": { - "version":2, - "node_id":"03a7103a2322b811f7369cbb27fb213d30bbc0b012082fed3cad7e4498da2dc56b", - "type":"chain_mvt", - "account_id":"wallet", - "originating_account": "wallet", // (`chain_mvt` only, optional) - "txid":"0159693d8f3876b4def468b208712c630309381e9d106a9836fa0a9571a28722", // (`chain_mvt` only, optional) - "utxo_txid":"0159693d8f3876b4def468b208712c630309381e9d106a9836fa0a9571a28722", // (`chain_mvt` only) - "vout":1, // (`chain_mvt` only) - "payment_hash": "xxx", // (either type, optional on both) - "part_id": 0, // (`channel_mvt` only, optional) - "group_id": 0, // (`channel_mvt` only, optional) - "credit_msat":2000000000, - "debit_msat":0, - "output_msat": 2000000000, // ('chain_mvt' only) - "output_count": 2, // ('chain_mvt' only, typically only channel closes) - "fees_msat": 382, // ('channel_mvt' only) - "primary_tag": "deposit", - "extra_tags": [], - "blockheight":102, // 'chain_mvt' only - "timestamp":1585948198, - "coin_type":"bc" - } -} -``` - -`version` indicates which version of the coin movement data struct this notification adheres to. - -`node_id` specifies the node issuing the coin movement. - -`type` marks the underlying mechanism which moved these coins. There are two 'types' of `coin_movements`: - -- `channel_mvt`s, which occur as a result of htlcs being resolved and, -- `chain_mvt`s, which occur as a result of bitcoin txs being mined. - -`account_id` is the name of this account. The node's wallet is named 'wallet', all channel funds' account are the channel id. - -`originating_account` is the account that this movement originated from. -_Only_ tagged on external events (deposits/withdrawals to an external party). - -`txid` is the transaction id of the bitcoin transaction that triggered this ledger event. `utxo_txid` and `vout` identify the bitcoin output which triggered this notification. (`chain_mvt` only). Notifications tagged `journal_entry` do not have a `utxo_txid` as they're not represented in the utxo set. - -`payment_hash` is the hash of the preimage used to move this payment. Only present for HTLC mediated moves (both `chain_mvt` and `channel_mvt`) A `chain_mvt` will have a `payment_hash` iff it's recording an htlc that was fulfilled onchain. - -`part_id` and `group_id` are identifiers for parts of a multi-part payment. useful for aggregating payments for an invoice or to indicate why a payment hash appears multiple times. `channel_mvt` only - -`credit` and `debit` are millisatoshi denominated amounts of the fund movement. A -'credit' is funds deposited into an account; a `debit` is funds withdrawn. - -`output_value` is the total value of the on-chain UTXO. Note that for channel opens/closes the total output value will not necessarily correspond to the amount that's credited/debited. - -`output_count` is the total outputs to expect for a channel close. Useful for figuring out when every onchain output for a close has been resolved. - -`fees` is an HTLC annotation for the amount of fees either paid or earned. For "invoice" tagged events, the fees are the total fees paid to send that payment. The end amount can be found by subtracting the total fees from the `debited` amount. For "routed" tagged events, both the debit/credit contain fees. Technically routed debits are the 'fee generating' event, however we include them on routed credits as well. - -`primary_tag` is a movement descriptor. Current primary tags are as follows: - -- `deposit`: funds deposited -- `withdrawal`: funds withdrawn -- `penalty`: funds paid or gained from a penalty tx. -- `invoice`: funds paid to or received from an invoice. -- `routed`: funds routed through this node. -- `pushed`: funds pushed to peer. -- `channel_open` : channel is opened, initial channel balance -- `channel_close`: channel is closed, final channel balance -- `delayed_to_us`: on-chain output to us, spent back into our wallet -- `htlc_timeout`: on-chain htlc timeout output -- `htlc_fulfill`: on-chian htlc fulfill output -- `htlc_tx`: on-chain htlc tx has happened -- `to_wallet`: output being spent into our wallet -- `anchor`: an anchor output -- `to_them`: output intended to peer's wallet -- `penalized`: output we've 'lost' due to a penalty (failed cheat attempt) -- `stolen`: output we've 'lost' due to peer's cheat -- `to_miner`: output we've burned to miner (OP_RETURN) -- `lease_fee`: amount paid as lease fee -- `channel_proposed`: a zero-conf channel - -`extra_tags` is zero or more additional tags. Current extra tags are as follows: - -- `ignored`: output is being ignored -- `opener`: tags `channel_open` or `channel_proposed`, we are the channel opener -- `stealable`: funds can be taken by the other party -- `leased`: tags `channel_open` or `channel_proposed`, channel contains leased funds -- `splice`: a channel close due to splice operation. - -`blockheight` is the block the txid is included in. `channel_mvt`s will be null, so will the blockheight for withdrawals to external parties (we issue these events when we send the tx containing them, before they're included in the chain). - -The `timestamp` is seconds since Unix epoch of the node's machine time at the time lightningd broadcasts the notification. - -`coin_type` is the BIP173 name for the coin which moved. - -### `balance_snapshot` - -Emitted after we've caught up to the chain head on first start. Lists all current accounts (`account_id` matches the `account_id` emitted from `coin_movement`). Useful for checkpointing account balances. - -```json -{ - "balance_snapshot": [ - { - 'node_id': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d', - 'blockheight': 101, - 'timestamp': 1639076327, - 'accounts': [ - { - 'account_id': 'wallet', - 'balance': '0msat', - 'coin_type': 'bcrt' - } - ] - }, - { - 'node_id': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d', - 'blockheight': 110, - 'timestamp': 1639076343, - 'accounts': [ - { - 'account_id': 'wallet', - 'balance': '995433000msat', - 'coin_type': 'bcrt' - }, { - 'account_id': '5b65c199ee862f49758603a5a29081912c8816a7c0243d1667489d244d3d055f', - 'balance': '500000000msat', - 'coin_type': 'bcrt' - } - ] - } - ] -} -``` - -### `block_added` - -Emitted after each block is received from bitcoind, either during the initial sync or throughout the node's life as new blocks appear. - -```json -{ - "block_added": { - "hash": "000000000000000000034bdb3c01652a0aa8f63d32f949313d55af2509f9d245", - "height": 753304 - } -} -``` - -### `openchannel_peer_sigs` - -When opening a channel with a peer using the collaborative transaction protocol `opt_dual_fund`), this notification is fired when the peer sends us their funding transaction signatures, `tx_signatures`. We update the in-progress PSBT and return it here, with the peer's signatures attached. - -```json -{ - "openchannel_peer_sigs": { - "channel_id": "252d1b0a1e5789...", - "signed_psbt": "cHNidP8BAKgCAAAAAQ+y+61AQAAAAD9////AzbkHAAAAAAAFgAUwsyrFxwqW+natS7EG4JYYwJMVGZQwwAAAAAAACIAIKYE2s4YZ+RON6BB5lYQESHR9cA7hDm6/maYtTzSLA0hUMMAAAAAAAAiACBbjNO5FM9nzdj6YnPJMDU902R2c0+9liECwt9TuQiAzWYAAAAAAQDfAgAAAAABARtaSZufCbC+P+/G23XVaQ8mDwZQFW1vlCsCYhLbmVrpAAAAAAD+////AvJs5ykBAAAAFgAUT6ORgb3CgFsbwSOzNLzF7jQS5s+AhB4AAAAAABepFNi369DMyAJmqX2agouvGHcDKsZkhwJHMEQCIHELIyqrqlwRjyzquEPvqiorzL2hrvdu9EBxsqppeIKiAiBykC6De/PDElnqWw49y2vTqauSJIVBgGtSc+vq5BQd+gEhAg0f8WITWvA8o4grxNKfgdrNDncqreMLeRFiteUlne+GZQAAAAEBIICEHgAAAAAAF6kU2Lfr0MzIAmapfZqCi68YdwMqxmSHAQcXFgAUAfrZCrzWZpfiWSFkci3kqV6+4WUBCGsCRzBEAiBF31wbNWECsJ0DrPel2inWla2hYpCgaxeVgPAvFEOT2AIgWiFWN0hvUaK6kEnXhED50wQ2fBqnobsRhoy1iDDKXE0BIQPXRURck2JmXyLg2W6edm8nPzJg3qOcina/oF3SaE3czwz8CWxpZ2h0bmluZwEIexhVcpJl8ugM/AlsaWdodG5pbmcCAgABAAz8CWxpZ2h0bmluZwEIR7FutlQgkSoADPwJbGlnaHRuaW5nAQhYT+HjxFBqeAAM/AlsaWdodG5pbmcBCOpQ5iiTTNQEAA==" - } -} -``` - -### `onionmessage_forward_fail` - -When we receive an onion message from a peer (and it's not ratelimited), and we cannot forward it for some reason. There are three reasons why this can be called: - -1. The onion message cannot be parsed. In this case, `outgoing` and `next_node_id`/`next_short_channel_id_dir` fields are missing. -2. The forward was by short_channel_id, but we don't know that id. In this case, `next_node_id` is missing, but `next_short_channel_id_dir` is present. -3. The next peer wasn't connected. In this case, only `next_short_channel_id_dir` is missing. - -Example 1: Failure because next node wasn't connected: - -```json -{ - "onionmessage_forward_fail": { - "source": "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", - "incoming": "0002d32df088bbe2723c619b0bb88bd0969843320f961744816cbcf30ad92d8f8db567687640ffdf492971729befd7016443514bed786fbcde7be8935f09b624868c912674abd3764099f082da36c8431a847cb486f19f4888a34ee19850b6977b2b0019b8570f9a194f952a451711a42cc9b7b26b1f0f099a43f94c2946a0e3b6425abff66f002b50ab16939d0239496309198870fbb91cf2c9e67b6092a843e827e01d44898c28d4e31d1278daef2e6d7dd4ffb7d170d102a198451c46974d93a1e86e1a752db64cd067089e42ae90be27a86dbee3462850fca616bf9aac4cfe704bcf82a4d90c9cab2f107f93c9d96a400f09fd3520d55262bd99880f82525560b4d605dfe40b87ea7a606f7a12fc86b6be45bbfb4fe10686a040523f5270a40dc125466ff2f470ee82f07cf0f55f826e669e265bba2ef4649aaeec91d3e82e02b64bd93e8d3eb3f84bc4734fe36649859d6a573a7ce32ee49ecf419892d24aa0cdf778b48bb60476c29c398b2faa2ad095b76f508e69fb1fc3b26c3495c38b5e01741557bd4f22c5e752209fd7f3bbac53bed7d43c97f59294df67ec3489ae28deafbc6a24675d0d33ec59ed698932ab39d132aea90a0c8a1577dc149769c28d1e709d37ce945e1a1a3587df288725075a55cc881a821abd8179e48183482d909371fc6132cb6eb588d1e1f99a4da625da4b1bf54365ec4426e52ea0bcc8da5b7768f0dd5cd3d16116987d24f9e99e0f1c16e7564bec502b29ff3d1dde44f438bda52d716965751e173458318dfef1bb441ae55a77cd8a3a018c21770581d65edcb50146e4c06a4a545c1629fbcbf9985ab0de8c2d7b16ce67ac97ee4475d9b890a96481bf53960350194404c84ad8ddf78c956b3d5538741dc21030f7d4407ec55a5ec41e142b3613d14955f0b19232a7e2c403aa76b5289c714697d61e2ba6ad33f9e1c68fdb0b0d3dba91170eeb2647eca097b6aed5a86a8af41c026768a03f8f0225e7f7e025152a2fd9238c54a53e95ae3c8d867b41f014ab799365f5f12c214b91b7df04ad7055930fc652b24ba4bdaa509002dee61a49b80323e5a8b576beefa50149adc9ea55d00799cdf97efb0c60c9c05e812d203034bd0c3c3405d53e22e15b9c543f7655a327ddb9879ba7959215f1562d974447ecd5ea08fbc8665619f5aee259ebf6f2dd3f851bda06861817d7751126c48beba46b63f87aacba344be60ba437b677fd6ca997848c00a79377425f2c70ea4097e29a06028bdf8d34eeda515682e148832af2ee8efa326997a7f834609363114e1015115c37c8a59b2fd18554e59a6cd049acf95ead7023d2f4654fd938f821324d6cc87161b202dfc5b69803d4b3b0f8dcd5d2eb9058973027966ea48f1b63766074fceb5827d7da4fcd50d554f0a971fdfb7760b65cf413e5653065b1b728c09f1c75aaf635a6f350a04163af02e51031642439486c623f71e78ab9141c09afcc9963808ec063bbc393163e91e21dea1d6543da8c27dcc37bd68d90fb5bff3912caf29f5c9c0398f8a4384a3bc75213cac334e0f078034fbaf0ae541fbe20da77404759c72d036750f30247cd2b9317e71dea7907047457b010acfdc17ae4671c7fcc7800031a4473f924fcc9483deaa912a838c90eae30a96355cc34303f7cd4146fcefb2cc81359adcfa60b5f5a67ee203bb21d1a6a75a7315fe25fd53b729c9e32b17eef2fda0e4e00e357a55bb4c97e82f39cf386e3c40b8a1e6aae62654ad0d050e23030061ea4baf5d3fa3395d146072e30c48ff7f7ad36199774baa8c26f0e17d26c340f294c64cdbd001929a46bd0b58d472d630bba53b848eddcec0a4e3ca098e3350c022011b2ca57719e9ba10a185e2fe0959bb4796f8806642d01700c1a5c617ae68f3ec9447a40b8751bb43b4eb1052fa0f35d", - "path_key": "036fb5acc4ddcd66bebbc00831e856720f92255017ae200bfafaa2f5fb23aa74e2", - "outgoing": "02010221795ac7fd20c3905ced2317c9455adcdb4166be10fd0b10b9408373c8db813c05560002da9320b96766a2b754923854bf99aa9cfe96263e24ead7d0f027b4941702fc6fdf2878caab06852f5f20857699a81c421e784a744d4d0d3706d328a8ff6c61a6d07e4f4496c6ace9b34d860c325cd0676fa7251f9fddf572fb454f0738ee3d16cb88045f325e88ba804936789539a7250584a6611a5b51d3d4c41ad4ca9d1988cdb0c32adae4261c78da204ea6123a0c3afa7c9b6891c7132fedf07f7cedfb0faa685f0fc91be657169983403a0e9d62558e0eb28456ca3f26a272cf447c2c417e34346a3a175abac1af534fa7c1d5427e2ad9343266f7edbb48f9bcb0ee4afca808572606a5a23cda7e54936ea0691e49f065b02cac3dfdb84e248ff7c69b8bd31345b295c1f58b572f72b8453bc434dc1744c8abf22d3bbda741be411fbbb7ec51fb66f229deacd56f180f92c12bd62cad53fc695aa41305b2a5751f449c361061e417a6d00a12d27d9fd0a043a40d60fd6e28f37096cb9f9f5000b088cba346a2d6d6d9db1d8f5144a625b5dd7204392f0ff4c5a2e92e8e787d336a6090c94d7f60668807429dcce5af39b8688d8cc48d1618de9b48219d3ddfa0ad4e5712966267a4bd41d8d1135e594b1d5b4de4050e46b1bc10cde4f0a401e0b14edd74b675b56f0177f713c89ec963cc97896c7aa918339104ae7eec6a16f9c08950f2d6f7f54bb8da2700e88825fead9d463b47bb9f45c11bdfeda92b5afb12942d162392ebc8e403b1c89838c772d4f6e737ff5e0eb03887a996b2f5591fec34da4eb2330e0b09b763f1165f098b204b590250f5013edbdc51fe04cd3ac9c412b0f6f7af9f88ddde58ae17e21466f3a71ab55fd557b7d52e8da8d62800313d13447ff92c557f19b52acaab60223cb7fb36ebc4b5279f097c0710fa86385e8ff4544515feb53fa0a6385f47f57e3b690e198ffc77be73ef25ef00676fdbb8750fecbc2bfdc081a0a3a2340dae8e3810f9fe7f6c365ec1903f2d4f48017b6d591e87ef148da5e41f80c02a1d4747b0e69934abf3ed57af48918b2d2facda94ce8759c2d98663e33ac1a5e293479332389d85b25cd69484d25a1e52d93cde5812bc5b69439e03339b595c4ee0035195c1a73d152a1763b7df77a48f36781c719c8c482fce687792c9fc5b2a9b51f679f82c4327b6478922ee47ee6524cb4aa63121222fa4762fa7bb6798444522030aa2c27b75cbf6f20d802e321d9b648d7f556a0d3be3e61d06a02f800c927fc15027a44d0132cf277083de6118ac163fa47d662b3274a00f0b561248e350313fbd446eb495ab9503b749ca0126b5690755ca43372db968ac7a2c41aa7f019184c3208b40e3ebd2b5d38e33cb0435b3ad2d5eec77101ae26b113c07c3044da335e57378c6cf1b2d3339d49244cb4d0f6982505ec06b85aedc91c241cfc429628fca8756b4c172f4af35e73ee57f650d0e049100d2664d016571e83ce06929ec37dc77bbd3bad59435ff2406084b24165b94704d8df16577b7100a41503a247f60f4f6a58e3fce6e789e19e5b04c64ca30e09207bb8b556db17dda1d00f7c47c391086247b63388275f2018f29d7bfd33dac7f73924f6c2e50e0d26a6f7f3ca19156e092a1f13d9205fec58d33f5e18360ab295c7798475229a95b56af4df9035e676a0bed91faa8df5b2e1131ba7d8b9155b12cb1358ae5d739893503bce95540dac5bb377660ef74bd0da5a2f655db5ecc785143cec2dba84a5208fa711cf680f027259efcfaad64e20daf8cc4ad4396296f9c8fa51e20dd457594d26fbe1f36278e5483401ad158363ea43bdae7595c434a4af3d47f25d61fee9a996bde1a018f544dfe7cb4b986c55f5d5d6783efc9078e423f7855be7415764a8b5a5fe350032f16a3b4f18db2062a5ae6446dffbb346f5429a30d9a13c7736af009ef0b9c64defca7d17bbabac9", - "next_node_id": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d" - } -} -``` - -Example 2: failed because we don't know short-channel `1x2x3`: - -```json -{ - "onionmessage_forward_fail": { - "source": "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", - "incoming": "0002d32df088bbe2723c619b0bb88bd0969843320f961744816cbcf30ad92d8f8db567687640ffdf492971729befd7016443514bed786fbcde7be8935f09b624868c912674abd3764099f082da36c8431a847cb486f19f4888a34ee19850b6977b2b0019b8570f9a194f952a451711a42cc9b7b26b1f0f099a43f94c2946a0e3b6425abff66f002b50ab16939d0239496309198870fbb91cf2c9e67b6092a843e827e01d44898c28d4e31d1278daef2e6d7dd4ffb7d170d102a198451c46974d93a1e86e1a752db64cd067089e42ae90be27a86dbee3462850fca616bf9aac4cfe704bcf82a4d90c9cab2f107f93c9d96a400f09fd3520d55262bd99880f82525560b4d605dfe40b87ea7a606f7a12fc86b6be45bbfb4fe10686a040523f5270a40dc125466ff2f470ee82f07cf0f55f826e669e265bba2ef4649aaeec91d3e82e02b64bd93e8d3eb3f84bc4734fe36649859d6a573a7ce32ee49ecf419892d24aa0cdf778b48bb60476c29c398b2faa2ad095b76f508e69fb1fc3b26c3495c38b5e01741557bd4f22c5e752209fd7f3bbac53bed7d43c97f59294df67ec3489ae28deafbc6a24675d0d33ec59ed698932ab39d132aea90a0c8a1577dc149769c28d1e709d37ce945e1a1a3587df288725075a55cc881a821abd8179e48183482d909371fc6132cb6eb588d1e1f99a4da625da4b1bf54365ec4426e52ea0bcc8da5b7768f0dd5cd3d16116987d24f9e99e0f1c16e7564bec502b29ff3d1dde44f438bda52d716965751e173458318dfef1bb441ae55a77cd8a3a018c21770581d65edcb50146e4c06a4a545c1629fbcbf9985ab0de8c2d7b16ce67ac97ee4475d9b890a96481bf53960350194404c84ad8ddf78c956b3d5538741dc21030f7d4407ec55a5ec41e142b3613d14955f0b19232a7e2c403aa76b5289c714697d61e2ba6ad33f9e1c68fdb0b0d3dba91170eeb2647eca097b6aed5a86a8af41c026768a03f8f0225e7f7e025152a2fd9238c54a53e95ae3c8d867b41f014ab799365f5f12c214b91b7df04ad7055930fc652b24ba4bdaa509002dee61a49b80323e5a8b576beefa50149adc9ea55d00799cdf97efb0c60c9c05e812d203034bd0c3c3405d53e22e15b9c543f7655a327ddb9879ba7959215f1562d974447ecd5ea08fbc8665619f5aee259ebf6f2dd3f851bda06861817d7751126c48beba46b63f87aacba344be60ba437b677fd6ca997848c00a79377425f2c70ea4097e29a06028bdf8d34eeda515682e148832af2ee8efa326997a7f834609363114e1015115c37c8a59b2fd18554e59a6cd049acf95ead7023d2f4654fd938f821324d6cc87161b202dfc5b69803d4b3b0f8dcd5d2eb9058973027966ea48f1b63766074fceb5827d7da4fcd50d554f0a971fdfb7760b65cf413e5653065b1b728c09f1c75aaf635a6f350a04163af02e51031642439486c623f71e78ab9141c09afcc9963808ec063bbc393163e91e21dea1d6543da8c27dcc37bd68d90fb5bff3912caf29f5c9c0398f8a4384a3bc75213cac334e0f078034fbaf0ae541fbe20da77404759c72d036750f30247cd2b9317e71dea7907047457b010acfdc17ae4671c7fcc7800031a4473f924fcc9483deaa912a838c90eae30a96355cc34303f7cd4146fcefb2cc81359adcfa60b5f5a67ee203bb21d1a6a75a7315fe25fd53b729c9e32b17eef2fda0e4e00e357a55bb4c97e82f39cf386e3c40b8a1e6aae62654ad0d050e23030061ea4baf5d3fa3395d146072e30c48ff7f7ad36199774baa8c26f0e17d26c340f294c64cdbd001929a46bd0b58d472d630bba53b848eddcec0a4e3ca098e3350c022011b2ca57719e9ba10a185e2fe0959bb4796f8806642d01700c1a5c617ae68f3ec9447a40b8751bb43b4eb1052fa0f35d", - "path_key": "036fb5acc4ddcd66bebbc00831e856720f92255017ae200bfafaa2f5fb23aa74e2", - "outgoing": "02010221795ac7fd20c3905ced2317c9455adcdb4166be10fd0b10b9408373c8db813c05560002da9320b96766a2b754923854bf99aa9cfe96263e24ead7d0f027b4941702fc6fdf2878caab06852f5f20857699a81c421e784a744d4d0d3706d328a8ff6c61a6d07e4f4496c6ace9b34d860c325cd0676fa7251f9fddf572fb454f0738ee3d16cb88045f325e88ba804936789539a7250584a6611a5b51d3d4c41ad4ca9d1988cdb0c32adae4261c78da204ea6123a0c3afa7c9b6891c7132fedf07f7cedfb0faa685f0fc91be657169983403a0e9d62558e0eb28456ca3f26a272cf447c2c417e34346a3a175abac1af534fa7c1d5427e2ad9343266f7edbb48f9bcb0ee4afca808572606a5a23cda7e54936ea0691e49f065b02cac3dfdb84e248ff7c69b8bd31345b295c1f58b572f72b8453bc434dc1744c8abf22d3bbda741be411fbbb7ec51fb66f229deacd56f180f92c12bd62cad53fc695aa41305b2a5751f449c361061e417a6d00a12d27d9fd0a043a40d60fd6e28f37096cb9f9f5000b088cba346a2d6d6d9db1d8f5144a625b5dd7204392f0ff4c5a2e92e8e787d336a6090c94d7f60668807429dcce5af39b8688d8cc48d1618de9b48219d3ddfa0ad4e5712966267a4bd41d8d1135e594b1d5b4de4050e46b1bc10cde4f0a401e0b14edd74b675b56f0177f713c89ec963cc97896c7aa918339104ae7eec6a16f9c08950f2d6f7f54bb8da2700e88825fead9d463b47bb9f45c11bdfeda92b5afb12942d162392ebc8e403b1c89838c772d4f6e737ff5e0eb03887a996b2f5591fec34da4eb2330e0b09b763f1165f098b204b590250f5013edbdc51fe04cd3ac9c412b0f6f7af9f88ddde58ae17e21466f3a71ab55fd557b7d52e8da8d62800313d13447ff92c557f19b52acaab60223cb7fb36ebc4b5279f097c0710fa86385e8ff4544515feb53fa0a6385f47f57e3b690e198ffc77be73ef25ef00676fdbb8750fecbc2bfdc081a0a3a2340dae8e3810f9fe7f6c365ec1903f2d4f48017b6d591e87ef148da5e41f80c02a1d4747b0e69934abf3ed57af48918b2d2facda94ce8759c2d98663e33ac1a5e293479332389d85b25cd69484d25a1e52d93cde5812bc5b69439e03339b595c4ee0035195c1a73d152a1763b7df77a48f36781c719c8c482fce687792c9fc5b2a9b51f679f82c4327b6478922ee47ee6524cb4aa63121222fa4762fa7bb6798444522030aa2c27b75cbf6f20d802e321d9b648d7f556a0d3be3e61d06a02f800c927fc15027a44d0132cf277083de6118ac163fa47d662b3274a00f0b561248e350313fbd446eb495ab9503b749ca0126b5690755ca43372db968ac7a2c41aa7f019184c3208b40e3ebd2b5d38e33cb0435b3ad2d5eec77101ae26b113c07c3044da335e57378c6cf1b2d3339d49244cb4d0f6982505ec06b85aedc91c241cfc429628fca8756b4c172f4af35e73ee57f650d0e049100d2664d016571e83ce06929ec37dc77bbd3bad59435ff2406084b24165b94704d8df16577b7100a41503a247f60f4f6a58e3fce6e789e19e5b04c64ca30e09207bb8b556db17dda1d00f7c47c391086247b63388275f2018f29d7bfd33dac7f73924f6c2e50e0d26a6f7f3ca19156e092a1f13d9205fec58d33f5e18360ab295c7798475229a95b56af4df9035e676a0bed91faa8df5b2e1131ba7d8b9155b12cb1358ae5d739893503bce95540dac5bb377660ef74bd0da5a2f655db5ecc785143cec2dba84a5208fa711cf680f027259efcfaad64e20daf8cc4ad4396296f9c8fa51e20dd457594d26fbe1f36278e5483401ad158363ea43bdae7595c434a4af3d47f25d61fee9a996bde1a018f544dfe7cb4b986c55f5d5d6783efc9078e423f7855be7415764a8b5a5fe350032f16a3b4f18db2062a5ae6446dffbb346f5429a30d9a13c7736af009ef0b9c64defca7d17bbabac9", - "next_short_channel_id_dir": "1x2x3/1" - } -} - -``` -### `shutdown` - -Send in two situations: lightningd is (almost completely) shutdown, or the plugin `stop` command has been called for this plugin. In both cases the plugin has 30 seconds to exit itself, otherwise it's killed. - -In the shutdown case, plugins should not interact with lightnind except via (id-less) logging or notifications. New rpc calls will fail with error code -5 and (plugin's) responses will be ignored. Because lightningd can crash or be killed, a plugin cannot rely on the shutdown notification always been send. - -```json -{ - "shutdown": { - } -} -``` - -### `plugin_started` (v25.02 onward) - -Emitted when a plugin has completed startup. - -```json -{ - "plugin_started": { - "plugin_name": "example_plugin", - "plugin_path": "/path/to/example_plugin.py", - "methods": [ - "example_method1", - "example_method2", - "example_method3" - ] - } -} -``` - -Where: - -- `plugin_name`: The short name of the plugin. -- `plugin_path`: The full file path to the plugin executable. -- `methods`: An array of RPC method names that the plugin registered. - -### `plugin_stopped` (v25.02 onward) - -Emitted when a plugin has been stopped or has exited. - -```json -{ - "plugin_stopped": { - "plugin_name": "example_plugin", - "plugin_path": "/path/to/example_plugin.py", - "methods": [ - "example_method1", - "example_method2", - "example_method3" - ] - } -} -``` - -Where: - -- `plugin_name`: The short name of the plugin. -- `plugin_path`: The full file path to the plugin executable. -- `methods`: An array of RPC method names that the plugin registered. - - -### `pay_part_start` (v25.09 onward) - -Emitted by `xpay` when part of a payment begins. `payment_hash` and -`groupid` uniquely identify this xpay invocation, and `partid` then identifies -this particular attempt to pay part of that. - -`total_payment_msat` is the total amount (usually the invoice amount), -which will be the same across all parts, adn `attempt_msat` is the -amount being delivered to the destination by this part. - -Each element in `hops` shows the amount going into the node (i.e. with -fees, `channel_in_msat`) and the amount we're telling it to send -to the other end (`channel_out_msat`). The `channel_out_msat` will -be equal to the next `channel_in_msat. The final -`channel_out_msat` will be equal to the `attempt_msat`. - -The example shows a payment from this node via 103x1x0 (direction 1) to 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59, then via 103x2x0 (direction 0) to 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d. - -```json -{ - "jsonrpc": "2.0", - "method": "pay_part_start", - "params": { - "origin": "cln-xpay", - "payment_hash": "651b28004d41cf0dc8e39a0b3d905651a7b012d03d81199fde09314700cb5a62", - "groupid": 5793910575598463611, - "partid": 1, - "total_payment_msat": 5000000, - "attempt_msat": 5000000, - "hops": [ - { - "next_node": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", - "short_channel_id": "103x1x0", - "direction": 1, - "channel_in_msat": 5000051, - "channel_out_msat": 5000051 - }, - { - "next_node": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", - "short_channel_id": "103x2x0", - "direction": 0, - "channel_in_msat": 5000051, - "channel_out_msat": 5000000 - } - ] - } -} -``` - -### `pay_part_end` (v25.09 onward) - -Emitted by `xpay` when part of a payment ends. `payment_hash`, `groupid` and `partid` -will match a previous `pay_part_start`. - -`status` will be "success" or "failure". `duration` will be a number of seconds, with 9 decimal places. This is the time between `xpay` telling lightningd to send the onion, to when `xpay` processes the response. - -If `status` is "failure", there will always be an `error_message`: the other fields below -will be missing in the unusual case where the error onion is corrupted. - -`failed_node_id`: If it's a non-local error, the source of the error. -`failed_short_channel_id`: if it's not the final node, the channel it's complaining about. -`failed_direction`: if it's not the final node, the channel direction. -`failed_msg`: the decrypted onion message, in hex, if it was valid. -`error_code`: the error code returned (present unless onion was corrupted). -`error_message`: always present: if `failed_node_id` is present it's just the name of the `error_code`, but otherwise it can be a more informative error from our own node. - -```json -{ - "jsonrpc": "2.0", - "method": "pay_part_end", - "params": { - "origin": "cln-xpay", - "status": "success", - "duration": 0.220209189, - "payment_hash": "651b28004d41cf0dc8e39a0b3d905651a7b012d03d81199fde09314700cb5a62", - "groupid": 5793910575598463611, - "partid": 1 - } -} -``` +Lookup the **[Notification APIs](ref:notification-balance_snapshot)** for details on each notification and their payload. diff --git a/doc/developers-guide/plugin-development/hooks.md b/doc/developers-guide/plugin-development/hooks.md index 8f5bc7df759e..626d9a6f2eb7 100644 --- a/doc/developers-guide/plugin-development/hooks.md +++ b/doc/developers-guide/plugin-development/hooks.md @@ -28,526 +28,4 @@ Hooks are considered to be an advanced feature due to the fact that `lightningd` As a convention, for all hooks, returning the object `{ "result" : "continue" }` results in `lightningd` behaving exactly as if no plugin is registered on the hook. -### `peer_connected` - -This hook is called whenever a peer has connected and successfully completed the cryptographic handshake. The parameters have the following structure: -```json -{ - "peer": { - "id": "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f", - "direction": "in", - "addr": "34.239.230.56:9735", - "features": "" - } -} -``` - -The hook is sparse on information, since the plugin can use the JSON-RPC `listpeers` command to get additional details should they be required. `direction` is either `"in"` or `"out"`. The `addr` field shows the address that we are connected to ourselves, not the gossiped list of known addresses. In particular this means that the port for incoming connections is an ephemeral port, that may not be available for reconnections. - -The returned result must contain a `result` member which is either the string `disconnect` or `continue`. If `disconnect` and there's a member `error_message`, that member is sent to the peer before disconnection. - -Note that `peer_connected` is a chained hook. The first plugin that decides to `disconnect` with or without an `error_message` will lead to the subsequent plugins not being called anymore. - -### `recover` - -This hook is called whenever the node is started using the --recovery flag. So basically whenever a user wants to recover their node with a codex32 secret, they can use --recover="codex32secret" to use that secret as their HSM Secret. - -The payload consists of the following information: -```json -{ - "codex32": "cl10leetsllhdmn9m42vcsamx24zrxgs3qrl7ahwvhw4fnzrhve25gvezzyqqjdsjnzedu43ns" -} -``` - -This hook is intended to be used for recovering the node and funds by connecting to some known peers who keep your peer storage backups with them. - -### `commitment_revocation` - -This hook is called whenever a channel state is updated, and the old state was revoked. State updates in Lightning consist of the following steps: - -1. Proposal of a new state commitment in the form of a commitment transaction -2. Exchange of signatures for the agreed upon commitment transaction -3. Verification that the signatures match the commitment transaction -4. Exchange of revocation secrets that could be used to penalize an eventual misbehaving party - -The `commitment_revocation` hook is used to inform the plugin about the state transition being completed, and deliver the penalty transaction. The penalty transaction could then be sent to a watchtower that automatically reacts in case one party attempts to settle using a revoked commitment. - -The payload consists of the following information: -```json -{ - "commitment_txid": "58eea2cf538cfed79f4d6b809b920b40bb6b35962c4bb4cc81f5550a7728ab05", - "penalty_tx": "02000000000101...ac00000000", - "channel_id": "fb16398de93e8690c665873715ef590c038dfac5dd6c49a9d4b61dccfcedc2fb", - "commitnum": 21 -} -``` - -Notice that the `commitment_txid` could also be extracted from the sole input of the `penalty_tx`, however it is enclosed so plugins don't have to include the logic to parse transactions. - -Not included are the `htlc_success` and `htlc_failure` transactions that may also be spending `commitment_tx` outputs. This is because these transactions are much more dynamic and have a predictable timeout, allowing wallets to ensure a quick checkin when the CLTV of the HTLC is about to expire. - -The `commitment_revocation` hook is a chained hook, i.e., multiple plugins can register it, and they will be called in the order they were registered in. Plugins should always return `{"result": "continue"}`, otherwise subsequent hook subscribers would not get called. - -### `db_write` - -This hook is called whenever a change is about to be committed to the database, if you are using a SQLITE3 database (the default). This hook will be useless (the `"writes"` field will always be empty) if you are using a PostgreSQL database. - -It is currently extremely restricted: - -1. a plugin registering for this hook should not perform anything that may cause a db operation in response (pretty much, anything but logging). -2. a plugin registering for this hook should not register for other hooks or commands, as these may become intermingled and break rule #1. -3. the hook will be called before your plugin is initialized! - -This hook, unlike all the other hooks, is also strongly synchronous: `lightningd` will stop almost all the other processing until this hook responds. -```json -{ - "data_version": 42, - "writes": [ - "PRAGMA foreign_keys = ON" - ] -} -``` - -This hook is intended for creating continuous backups. The intent is that your backup plugin maintains three pieces of information (possibly in separate files): - -1. a snapshot of the database -2. a log of database queries that will bring that snapshot up-to-date -3. the previous `data_version` - -`data_version` is an unsigned 32-bit number that will always increment by 1 each time `db_write` is called. Note that this will wrap around on the limit of 32-bit numbers. - -`writes` is an array of strings, each string being a database query that modifies the database. If the `data_version` above is validated correctly, then you can simply append this to the log of database queries. - -Your plugin **MUST** validate the `data_version`. It **MUST** keep track of the previous `data_version` it got, and: - -1. If the new `data_version` is **_exactly_** one higher than the previous, then this is the ideal case and nothing bad happened and we should save this and continue. -2. If the new `data_version` is **_exactly_** the same value as the previous, then the previous set of queries was not committed. Your plugin **MAY** overwrite the previous set of queries with the current set, or it **MAY** overwrite its entire backup with a new snapshot of the database and the current `writes` array (treating this case as if `data_version` were two or more higher than the previous). -3. If the new `data_version` is **_less than_** the previous, your plugin **MUST** halt and catch fire, and have the operator inspect what exactly happened here. -4. Otherwise, some queries were lost and your plugin **SHOULD** recover by creating a new snapshot of the database: copy the database file, back up the given `writes` array, then delete (or atomically `rename` if in a POSIX filesystem) the previous backups of the database and SQL statements, or you **MAY** fail the hook to abort `lightningd`. - -The "rolling up" of the database could be done periodically as well if the log of SQL statements has grown large. - -Any response other than `{"result": "continue"}` will cause lightningd to error without committing to the database! This is the expected way to halt and catch fire. - -`db_write` is a parallel-chained hook, i.e., multiple plugins can register it, and all of them will be invoked simultaneously without regard for order of registration. The hook is considered handled if all registered plugins return `{"result": "continue"}`. If any plugin returns anything else, `lightningd` will error without committing to the database. - -### `invoice_payment` - -This hook is called whenever a valid payment for an unpaid invoice has arrived. -```json -{ - "payment": { - "label": "unique-label-for-invoice", - "preimage": "0000000000000000000000000000000000000000000000000000000000000000", - "msat": 10000 - } -} -``` - -Before version `23.11` the `msat` field was a string with msat-suffix, e.g: `"10000msat"`. - -The hook is deliberately sparse, since the plugin can use the JSON-RPC `listinvoices` command to get additional details about this invoice. It can return a `failure_message` field as defined for final nodes in [BOLT 4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#failure-messages), a `result` field with the string `reject` to fail it with `incorrect_or_unknown_payment_details`, or a `result` field with the string `continue` to accept the payment. - -### `openchannel` - -This hook is called whenever a remote peer tries to fund a channel to us using the v1 protocol, and it has passed basic sanity checks: -```json -{ - "openchannel": { - "id": "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f", - "funding_msat": 100000000, - "push_msat": 0, - "dust_limit_msat": 546000, - "max_htlc_value_in_flight_msat": 18446744073709551615, - "channel_reserve_msat": 1000000, - "htlc_minimum_msat": 0, - "feerate_per_kw": 7500, - "to_self_delay": 5, - "max_accepted_htlcs": 483, - "channel_flags": 1 - } -} -``` - -There may be additional fields, including `shutdown_scriptpubkey` and a hex-string. You can see the definitions of these fields in [BOLT 2's description of the open_channel message](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message). - -The returned result must contain a `result` member which is either the string `reject` or `continue`. If `reject` and there's a member `error_message`, that member is sent to the peer before disconnection. - -For a 'continue'd result, you can also include a `close_to` address, which will be used as the output address for a mutual close transaction. - -e.g. -```json -{ - "result": "continue", - "close_to": "bc1qlq8srqnz64wgklmqvurv7qnr4rvtq2u96hhfg2", - "mindepth": 0, - "reserve": "1234sat" -} -``` - -Note that `close_to` must be a valid address for the current chain, an invalid address will cause the node to exit with an error. - -- `mindepth` is the number of confirmations to require before making the channel usable. Notice that setting this to 0 (`zeroconf`) or some other low value might expose you to double-spending issues, so only lower this value from the default if you trust the peer not to double-spend, or you reject incoming payments, including forwards, until the funding is confirmed. - -- `reserve` is an absolute value for the amount in the channel that the peer must keep on their side. This ensures that they always have something to lose, so only lower this below the 1% of funding amount if you trust the peer. The protocol requires this to be larger than the dust limit, hence it will be adjusted to be the dust limit if the specified value is below. - -Note that `openchannel` is a chained hook. Therefore `close_to`, `reserve` will only be evaluated for the first plugin that sets it. If more than one plugin tries to set a `close_to` address an error will be logged. - -### `openchannel2` - -This hook is called whenever a remote peer tries to fund a channel to us using the v2 protocol, and it has passed basic sanity checks: -```json -{ - "openchannel2": { - "id": "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f", - "channel_id": "252d1b0a1e57895e84137f28cf19ab2c35847e284c112fefdecc7afeaa5c1de7", - "their_funding_msat": 100000000, - "dust_limit_msat": 546000, - "max_htlc_value_in_flight_msat": 18446744073709551615, - "htlc_minimum_msat": 0, - "funding_feerate_per_kw": 7500, - "commitment_feerate_per_kw": 7500, - "feerate_our_max": 10000, - "feerate_our_min": 253, - "to_self_delay": 5, - "max_accepted_htlcs": 483, - "channel_flags": 1, - "channel_type": {'bits': [12, 22], 'names': ['static_remotekey/even', 'anchors/even']}, - "locktime": 2453, - "channel_max_msat": 16777215000, - "requested_lease_msat": 100000000, - "lease_blockheight_start": 683990, - "node_blockheight": 683990 - } -} -``` - -There may be additional fields, such as `shutdown_scriptpubkey`. You can see the definitions of these fields in [BOLT 2's description of the open_channel message](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message). - -`requested_lease_msat`, `lease_blockheight_start`, and `node_blockheight` are only present if the opening peer has requested a funding lease, per `option_will_fund`. - -The returned result must contain a `result` member which is either the string `reject` or `continue`. If `reject` and there's a member `error_message`, that member is sent to the peer before disconnection. - -For a 'continue'd result, you can also include a `close_to` address, which will be used as the output address for a mutual close transaction; you can include a `psbt` and an `our_funding_msat` to contribute funds, inputs and outputs to this channel open. - -Note that, like `openchannel_init` RPC call, the `our_funding_msat` amount must NOT be accounted for in any supplied output. Change, however, should be included and should use the `funding_feerate_per_kw` to calculate. - -See `plugins/funder.c` for an example of how to use this hook to contribute funds to a channel open. - -e.g. -```json -{ - "result": "continue", - "close_to": "bc1qlq8srqnz64wgklmqvurv7qnr4rvtq2u96hhfg2", - "psbt": "cHNidP8BADMCAAAAAQ+yBipSVZrrw28Oed52hTw3N7t0HbIyZhFdcZRH3+61AQAAAAD9////AGYAAAAAAQDfAgAAAAABARtaSZufCbC+P+/G23XVaQ8mDwZQFW1vlCsCYhLbmVrpAAAAAAD+////AvJs5ykBAAAAFgAUT6ORgb3CgFsbwSOzNLzF7jQS5s+AhB4AAAAAABepFNi369DMyAJmqX2agouvGHcDKsZkhwJHMEQCIHELIyqrqlwRjyzquEPvqiorzL2hrvdu9EBxsqppeIKiAiBykC6De/PDElnqWw49y2vTqauSJIVBgGtSc+vq5BQd+gEhAg0f8WITWvA8o4grxNKfgdrNDncqreMLeRFiteUlne+GZQAAAAEBIICEHgAAAAAAF6kU2Lfr0MzIAmapfZqCi68YdwMqxmSHAQQWABQB+tkKvNZml+JZIWRyLeSpXr7hZQz8CWxpZ2h0bmluZwEIexhVcpJl8ugM/AlsaWdodG5pbmcCAgABAA==", - "our_funding_msat": 39999000 -} -``` - -Note that `close_to` must be a valid address for the current chain, an invalid address will cause the node to exit with an error. - -Note that `openchannel` is a chained hook. Therefore `close_to` will only be evaluated for the first plugin that sets it. If more than one plugin tries to set a `close_to` address an error will be logged. - -### `openchannel2_changed` - -This hook is called when we received updates to the funding transaction from the peer. -```json -{ - "openchannel2_changed": { - "channel_id": "252d1b0a1e57895e841...", - "psbt": "cHNidP8BADMCAAAAAQ+yBipSVZr..." - } -} -``` - -In return, we expect a `result` indicated to `continue` and an updated `psbt`. If we have no updates to contribute, return the passed in PSBT. Once no changes to the PSBT are made on either side, the transaction construction negotiation will end and commitment transactions will be exchanged. - -#### Expected Return -```json -{ - "result": "continue", - "psbt": "cHNidP8BADMCAAAAAQ+yBipSVZr..." -} -``` - -See `plugins/funder.c` for an example of how to use this hook to continue a v2 channel open. - -### `openchannel2_sign` - -This hook is called after we've gotten the commitment transactions for a channel open. It expects psbt to be returned which contains signatures for our inputs to the funding transaction. -```json -{ - "openchannel2_sign": { - "channel_id": "252d1b0a1e57895e841...", - "psbt": "cHNidP8BADMCAAAAAQ+yBipSVZr..." - } -} -``` - -In return, we expect a `result` indicated to `continue` and an partially signed `psbt`. - -If we have no inputs to sign, return the passed in PSBT. Once we have also received the signatures from the peer, the funding transaction will be broadcast. - -#### Expected Return -```json -{ - "result": "continue", - "psbt": "cHNidP8BADMCAAAAAQ+yBipSVZr..." -} -``` - -See `plugins/funder.c` for an example of how to use this hook to sign a funding transaction. - -### `rbf_channel` - -Similar to `openchannel2`, the `rbf_channel` hook is called when a peer requests an RBF for a channel funding transaction. -```json -{ - "rbf_channel": { - "id": "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f", - "channel_id": "252d1b0a1e57895e84137f28cf19ab2c35847e284c112fefdecc7afeaa5c1de7", - "their_last_funding_msat": 100000000, - "their_funding_msat": 100000000, - "our_last_funding_msat": 100000000, - "funding_feerate_per_kw": 7500, - "feerate_our_max": 10000, - "feerate_our_min": 253, - "channel_max_msat": 16777215000, - "locktime": 2453, - "requested_lease_msat": 100000000 - } -} -``` - -The returned result must contain a `result` member which is either the string `reject` or `continue`. If `reject` and there's a member `error_message`, that member is sent to the peer before disconnection. - -For a 'continue'd result, you can include a `psbt` and an `our_funding_msat` to contribute funds, inputs and outputs to this channel open. - -Note that, like the `openchannel_init` RPC call, the `our_funding_msat` amount must NOT be accounted for in any supplied output. Change, however, should be included and should use the `funding_feerate_per_kw` to calculate. - -#### Return -```json -{ - "result": "continue", - "psbt": "cHNidP8BADMCAAAAAQ+yBipSVZrrw28Oed52hTw3N7t0HbIyZhFdcZRH3+61AQAAAAD9////AGYAAAAAAQDfAgAAAAABARtaSZufCbC+P+/G23XVaQ8mDwZQFW1vlCsCYhLbmVrpAAAAAAD+////AvJs5ykBAAAAFgAUT6ORgb3CgFsbwSOzNLzF7jQS5s+AhB4AAAAAABepFNi369DMyAJmqX2agouvGHcDKsZkhwJHMEQCIHELIyqrqlwRjyzquEPvqiorzL2hrvdu9EBxsqppeIKiAiBykC6De/PDElnqWw49y2vTqauSJIVBgGtSc+vq5BQd+gEhAg0f8WITWvA8o4grxNKfgdrNDncqreMLeRFiteUlne+GZQAAAAEBIICEHgAAAAAAF6kU2Lfr0MzIAmapfZqCi68YdwMqxmSHAQQWABQB+tkKvNZml+JZIWRyLeSpXr7hZQz8CWxpZ2h0bmluZwEIexhVcpJl8ugM/AlsaWdodG5pbmcCAgABAA==", - "our_funding_msat": 39999000 -} -``` - -### `htlc_accepted` - -The `htlc_accepted` hook is called whenever an incoming HTLC is accepted, and its result determines how `lightningd` should treat that HTLC. - -The payload of the hook call has the following format: -```json -{ - "peer_id": "02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f", - "onion": { - "payload": "", - "short_channel_id": "1x2x3", - "forward_msat": 42, - "outgoing_cltv_value": 500014, - "shared_secret": "0000000000000000000000000000000000000000000000000000000000000000", - "next_onion": "[1365bytes of serialized onion]" - }, - "htlc": { - "short_channel_id": "4x5x6", - "id": 27, - "amount_msat": 43, - "cltv_expiry": 500028, - "cltv_expiry_relative": 10, - "payment_hash": "0000000000000000000000000000000000000000000000000000000000000000", - "extra_tlvs": "fdffff012afe00010001020539" - }, - "forward_to": "0000000000000000000000000000000000000000000000000000000000000000" -} -``` - -For detailed information about each field please refer to [BOLT 04 of the specification](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), the following is just a brief summary: - -- `peer_id`: is the id of the peer that offered us this htlc. -- `onion`: - - `payload` contains the unparsed payload that was sent to us from the sender of the payment. - - `short_channel_id` determines the channel that the sender is hinting should be used next. Not present if we're the final destination. - - `forward_amount` is the amount we should be forwarding to the next hop, and should match the incoming funds in case we are the recipient. - - `outgoing_cltv_value` determines what the CLTV value for the HTLC that we forward to the next hop should be. - - `total_msat` specifies the total amount to pay, if present. - - `payment_secret` specifies the payment secret (which the payer should have obtained from the invoice), if present. - - `next_onion` is the fully processed onion that we should be sending to the next hop as part of the outgoing HTLC. Processed in this case means that we took the incoming onion, decrypted it, extracted the payload destined for us, and serialised the resulting onion again. - - `shared_secret` is the shared secret we used to decrypt the incoming onion. It is shared with the sender that constructed the onion. -- `htlc`: - - `short_channel_id` is the channel this payment is coming from. - - `id` is the low-level sequential HTLC id integer as sent by the channel peer. - - `amount` is the amount that we received with the HTLC. This amount minus the `forward_amount` is the fee that will stay with us. - - `cltv_expiry` determines when the HTLC reverts back to the sender. `cltv_expiry` minus `outgoing_cltv_expiry` should be equal or larger than our `cltv_delta` setting. - - `cltv_expiry_relative` hints how much time we still have to claim the HTLC. It is the `cltv_expiry` minus the current `blockheight` and is passed along mainly to avoid the plugin having to look up the current blockheight. - - `payment_hash` is the hash whose `payment_preimage` will unlock the funds and allow us to claim the HTLC. - - `extra_tlvs` is an optional TLV-stream attached to the HTLC. -- `forward_to`: if set, the channel_id we intend to forward this to (will not be present if the short_channel_id was invalid or we were the final destination). - -The hook response must have one of the following formats: -```json -{ - "result": "continue" -} -``` - -This means that the plugin does not want to do anything special and `lightningd` should continue processing it normally, i.e., resolve the payment if we're the recipient, or attempt to forward it otherwise. Notice that the usual checks such as sufficient fees and CLTV deltas are still enforced. - -It can also replace the `onion.payload` by specifying a `payload` in the response. Note that this is always a TLV-style payload, so unlike `onion.payload` there is no length prefix (and it must be at least 4 hex digits long). This will be re-parsed; it's useful for removing onion fields which a plugin doesn't want lightningd to consider. - -It can also specify `forward_to` in the response, replacing the destination. This usually only makes sense if it wants to choose an alternate channel to the same next peer, but is useful if the `payload` is also replaced. - -Also, it can specify `extra_tlvs` in the response. This will replace the TLV-stream `update_add_htlc_tlvs` in the `update_add_htlc` message for forwarded htlcs. - -If the node is the final destination, the plugin can also replace the amount of the invoice that belongs to the `payment_hash` by specifying `invoice_msat`. -```json -{ - "result": "fail", - "failure_message": "2002" -} -``` - -`fail` will tell `lightningd` to fail the HTLC with a given hex-encoded `failure_message` (please refer to the [spec](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for details: `incorrect_or_unknown_payment_details` is the most common). -```json -{ - "result": "fail", - "failure_onion": "[serialized error packet]" -} -``` - -Instead of `failure_message` the response can contain a hex-encoded `failure_onion` that will be used instead (please refer to the [spec](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for details). This can be used, for example, if you're writing a bridge between two Lightning Networks. Note that `lightningd` will apply the obfuscation step to the value returned here with its own shared secret (and key type `ammag`) before returning it to the previous hop. -```json -{ - "result": "resolve", - "payment_key": "0000000000000000000000000000000000000000000000000000000000000000" -} -``` - -`resolve` instructs `lightningd` to claim the HTLC by providing the preimage matching the `payment_hash` presented in the call. Notice that the plugin must ensure that the `payment_key` really matches the `payment_hash` since `lightningd` will not check and the wrong value could result in the channel being closed. - -> 🚧 -> -> `lightningd` will replay the HTLCs for which it doesn't have a final verdict during startup. This means that, if the plugin response wasn't processed before the HTLC was forwarded, failed, or resolved, then the plugin may see the same HTLC again during startup. It is therefore paramount that the plugin is idempotent if it talks to an external system. - -The `htlc_accepted` hook is a chained hook, i.e., multiple plugins can register it, and they will be called in the order they were registered in until the first plugin return a result that is not `{"result": "continue"}`, after which the event is considered to be handled. After the event has been handled the remaining plugins will be skipped. - -### `rpc_command` - -The `rpc_command` hook allows a plugin to take over any RPC command. It sends the received JSON-RPC request to the registered plugin. You can optionally specify a "filters" array, containing the command names you want to intercept: without this, all commands will be sent to this hook. -```json -{ - "rpc_command": { - "id": 3, - "method": "method_name", - "params": { - "param_1": [], - "param_2": {}, - "param_n": "", - } - } -} -``` -which can in turn: - -Let `lightningd` execute the command with -```json -{ - "result" : "continue" -} -``` - -Replace the request made to `lightningd`: -```json -{ - "replace": { - "id": 3, - "method": "method_name", - "params": { - "param_1": [], - "param_2": {}, - "param_n": "", - } - } -} -``` - -Return a custom response to the request sender: -```json -{ - "return": { - "result": { - } - } -} -``` - -Return a custom error to the request sender: -```json -{ - "return": { - "error": { - } - } -} -``` - -Note: The `rpc_command` hook is chainable. If two or more plugins try to replace/result/error the same `method`, only the first plugin in the chain will be respected. Others will be ignored and a warning will be logged. - -### `custommsg` - -The `custommsg` plugin hook is the receiving counterpart to the [`sendcustommsg`](ref:sendcustommsg) RPC method and allows plugins to handle messages that are not handled internally. The goal of these two components is to allow the implementation of custom protocols or prototypes on top of a Core Lightning node, without having to change the node's implementation itself. Note that if the hook registration specifies "filters" then that should be a JSON array of message numbers, and the hook will only be called for those. Otherwise, the hook is called for all messages not handled internally. - -The payload for a call follows this format: -```json -{ - "peer_id": "02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f", - "payload": "1337ffffffff" -} -``` - -This payload would have been sent by the peer with the `node_id` matching `peer_id`, and the message has type `0x1337` and contents `ffffffff`. Notice that the messages are currently limited to odd-numbered types and must not match a type that is handled internally by Core Lightning. These limitations are in place in order to avoid conflicts with the internal state tracking, and avoiding disconnections or channel closures, since odd-numbered message can be ignored by nodes (see ["it's ok to be odd" in the specification](https://github.com/lightning/bolts/blob/c74a3bbcf890799d343c62cb05fcbcdc952a1cf3/01-messaging.md#lightning-message-format) for details). The plugin must implement the parsing of the message, including the type prefix, since Core Lightning does not know how to parse the message. - -Because this is a chained hook, the daemon expects the result to be `{'result': 'continue'}`. It will fail if something else is returned. - -### `onion_message_recv` and `onion_message_recv_secret` - -These two hooks are almost identical, in that they are called when an onion message is received. - -`onion_message_recv` is used for unsolicited messages (where the source knows that it is sending to this node), and `onion_message_recv_secret` is used for messages which use a blinded path we supplied. The latter hook will have a `pathsecret` field, the former never will. - -These hooks are separate, because replies MUST be ignored unless they use the correct path (i.e. `onion_message_recv_secret`, with the expected `pathsecret`). This avoids the source trying to probe for responses without using the designated delivery path. - -The payload for a call follows this format: -```json -{ - "onion_message": { - "pathsecret": "0000000000000000000000000000000000000000000000000000000000000000", - "reply_blindedpath": { - "first_node_id": "02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f", - "first_scid": "100x200x300", - "first_scid_dir": 1, - "blinding": "02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f", - "hops": [ - { - "blinded_node_id": "02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f", - "encrypted_recipient_data": "0a020d0d" - } - ] - }, - "invoice_request": "0a020d0d", - "invoice": "0a020d0d", - "invoice_error": "0a020d0d", - "unknown_fields": [ - { - "number": 12345, - "value": "0a020d0d" - } - ] - } -} -``` - -All fields shown here are optional: in particular, only one of "first_node_id" or the pair "first_scid" and "first_scid_dir" is present. - -We suggest just returning `{"result": "continue"}`; any other result will cause the message not to be handed to any other hooks. +Lookup the **[Hook APIs](ref:hook-commitment_revocation)** for details on each hook's payload and how to respond to them. diff --git a/doc/index.rst b/doc/index.rst index f4fae7c6ca5a..6ecc0a945bdb 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -85,6 +85,21 @@ Core Lightning Documentation getroute getroutes help + hook-commitment_revocation + hook-custommsg + hook-db_write + hook-htlc_accepted + hook-invoice_payment + hook-onion_message_recv + hook-onion_message_recv_secret + hook-openchannel + hook-openchannel2 + hook-openchannel2_changed + hook-openchannel2_sign + hook-peer_connected + hook-rbf_channel + hook-recover + hook-rpc_command injectonionmessage injectpaymentonion invoice @@ -123,6 +138,30 @@ Core Lightning Documentation multifundchannel multiwithdraw newaddr + notification-balance_snapshot + notification-block_added + notification-channel_open_failed + notification-channel_opened + notification-channel_state_changed + notification-coin_movement + notification-connect + notification-custommsg + notification-deprecated_oneshot + notification-disconnect + notification-forward_event + notification-invoice_creation + notification-invoice_payment + notification-log + notification-onionmessage_forward_fail + notification-openchannel_peer_sigs + notification-plugin_started + notification-plugin_stopped + notification-sendpay_failure + notification-sendpay_success + notification-shutdown + notification-warning + notification-xpay_pay_part_end + notification-xpay_pay_part_start notifications offer openchannel_abort diff --git a/doc/schemas/bkpr-report.json b/doc/schemas/bkpr-report.json index 430d5019fdf7..3232247f5595 100644 --- a/doc/schemas/bkpr-report.json +++ b/doc/schemas/bkpr-report.json @@ -17,47 +17,47 @@ "type": "string", "description": [ "This format string is used for each income event (note that `lightning-cli` can get confused if the format begins and ends with `{` and `}`, so you may need to add a space). The following tags in braces are replaced:", - "{account}: account name (channel id, or 'wallet')", - "{tag}: event tag. This will be one of:", - " * `deposit`: an onchain send to the wallet by `outpoint`.", - " * `htlc_fulfill`: an onchain HTLC fulfill (due to unilaterally closed channel) at `outpoint`.", - " * `invoice`: either incoming (positive credit) or outgoing (positive debit) payment.", - " * `invoice_fee`: the routing fee paid to pay an outgoing invoice", - " * `journal_entry`: an accounting fixup, caused by loss of data (or, a node which predates bookkeeper)", - " * `lease_fee`: a fee paid or received to lease a channel via the experimental liquidity advertisement option", - " * `onchain_fee,`: a miner fee paid to open/close a channel, or make a bitcoin payment. The `txid` will correspond to a `withdrawal` `outpoint` for withdrawl", - " * `pushed`: an amount pushed to or from us on channel open.", - " * `rebalance_fee`: routing fee paid for sending a payment to ourselves.", - " * `routed`: credit gained from routing a payment", - " * `withdrawal`: debit from an onchain spend.", - "{description}: description as provided in the invoice, if present", - "{credit}: credit amount in BTC", - "{debit}: debit amount in BTC", - "{fees}: fee amount in BTC", - "{localtime}: event timestamp in local time as YYYY-MM-DD HH:MM:SS", - "{utctime}: event timestamp in UTC as YYYY-MM-DD HH:MM:SS", - "{outpoint}: outpoint, if present", - "{txid}: txid, if present", - "{payment_id}: payment hash, if present", - "{bkpr-currency}: value of bkpr-currency, if any", - "{currencyrate}: exchange rate for 1 BTC at that event time, if available", - "{creditdebit}: +credit or -debit (or 0) in BTC", - "{currencycredit}: credit amount converted into bkpr-currency", - "{currencydebit}: debit amount converted into bkpr-currency", - "{currencycreditdebit}: +credit or -debit (or 0) in bkpr-currency", + " * `{account}`: account name (channel id, or 'wallet')", + " * `{tag}`: event tag. This will be one of:", + " * `deposit`: an onchain send to the wallet by `outpoint`.", + " * `htlc_fulfill`: an onchain HTLC fulfill (due to unilaterally closed channel) at `outpoint`.", + " * `invoice`: either incoming (positive credit) or outgoing (positive debit) payment.", + " * `invoice_fee`: the routing fee paid to pay an outgoing invoice", + " * `journal_entry`: an accounting fixup, caused by loss of data (or, a node which predates bookkeeper)", + " * `lease_fee`: a fee paid or received to lease a channel via the experimental liquidity advertisement option", + " * `onchain_fee,`: a miner fee paid to open/close a channel, or make a bitcoin payment. The `txid` will correspond to a `withdrawal` `outpoint` for withdrawl", + " * `pushed`: an amount pushed to or from us on channel open.", + " * `rebalance_fee`: routing fee paid for sending a payment to ourselves.", + " * `routed`: credit gained from routing a payment", + " * `withdrawal`: debit from an onchain spend.", + " * `{description}`: description as provided in the invoice, if present", + " * `{credit}`: credit amount in BTC", + " * `{debit}`: debit amount in BTC", + " * `{fees}`: fee amount in BTC", + " * `{localtime}`: event timestamp in local time as YYYY-MM-DD HH:MM:SS", + " * `{utctime}`: event timestamp in UTC as YYYY-MM-DD HH:MM:SS", + " * `{outpoint}`: outpoint, if present", + " * `{txid}`: txid, if present", + " * `{payment_id}`: payment hash, if present", + " * `{bkpr-currency}`: value of bkpr-currency, if any", + " * `{currencyrate}`: exchange rate for 1 BTC at that event time, if available", + " * `{creditdebit}`: +credit or -debit (or 0) in BTC", + " * `{currencycredit}`: credit amount converted into bkpr-currency", + " * `{currencydebit}`: debit amount converted into bkpr-currency", + " * `{currencycreditdebit}`: +credit or -debit (or 0) in bkpr-currency", "", - "If a field is unavailable, it expands to an empty string (or 0 for credit, debit, fees and creditdebit).", + " If a field is unavailable, it expands to an empty string (or 0 for credit, debit, fees and creditdebit).", "", - "Tags support C-style conditional syntax: {tag[?if-set][:if-not-set]}", - " * if-set: text to use when the tag is present (and non-zero for credit, debit, fees and creditdebit). Default is the tag value itself.", - " * if-not-set: text to use when the tag is absent (or zero for amount fields). Default is empty string (or 0 for amount fields).", - "Either or both parts may be omitted, and each part can itself contain tags. For example:", - " * {outpoint:NONE}: the outpoint value, or 'NONE' if not available", - " * {credit:0.00}: the credit value, or '0.00' if zero", - " * {outpoint?[{outpoint}]:NONE}: '[]' if outpoint is available, or 'NONE' if not", - " * {payment_id:{txid:UNKNOWN}}: the payment_id, or the txid if no payment_id, or 'UNKNOWN' if neither", + " Tags support C-style conditional syntax: `{tag[?if-set][:if-not-set]}`", + " * if-set: text to use when the tag is present (and non-zero for credit, debit, fees and creditdebit). Default is the tag value itself.", + " * if-not-set: text to use when the tag is absent (or zero for amount fields). Default is empty string (or 0 for amount fields).", + " Either or both parts may be omitted, and each part can itself contain tags. For example:", + " * `{outpoint:NONE}`: the outpoint value, or 'NONE' if not available", + " * `{credit:0.00}`: the credit value, or '0.00' if zero", + " * `{outpoint?[{outpoint}]:NONE}`: `[]` if outpoint is available, or 'NONE' if not", + " * `{payment_id:{txid:UNKNOWN}}`: the payment_id, or the txid if no payment_id, or 'UNKNOWN' if neither", "", - "To include a literal {, write {{." + " To include a literal `{`, write `{{`." ] }, "headers": { diff --git a/doc/schemas/hook/commitment_revocation.json b/doc/schemas/hook/commitment_revocation.json index f655a076a36b..3766ebfefd7b 100644 --- a/doc/schemas/hook/commitment_revocation.json +++ b/doc/schemas/hook/commitment_revocation.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "commitment_revocation", + "hook": "commitment_revocation", "title": "Hook fired when a commitment transaction is revoked", "description": [ "The **commitment_revocation** hook is called whenever a channel state is updated, and the old state was revoked. State updates in Lightning consist of the following steps:", diff --git a/doc/schemas/hook/custommsg.json b/doc/schemas/hook/custommsg.json index b1077a1515ff..88b783da2efb 100644 --- a/doc/schemas/hook/custommsg.json +++ b/doc/schemas/hook/custommsg.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "custommsg", + "hook": "custommsg", "title": "Hook for handling custom peer messages", "description": [ "The **custommsg** hook is the receiving counterpart to the sendcustommsg RPC method and is called whenever a peer sends a custom message that is not handled internally by Core Lightning.", diff --git a/doc/schemas/hook/db_write.json b/doc/schemas/hook/db_write.json index 317faff7984c..d21d85ff3935 100644 --- a/doc/schemas/hook/db_write.json +++ b/doc/schemas/hook/db_write.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "db_write", + "hook": "db_write", "title": "Hook fired before database writes are committed", "description": [ "The **db_write** hook is called whenever a change is about to be committed to the database, if you are using a SQLITE3 database (the default).", diff --git a/doc/schemas/hook/htlc_accepted.json b/doc/schemas/hook/htlc_accepted.json index bbba2a6cc4d2..6a60cf3c1507 100644 --- a/doc/schemas/hook/htlc_accepted.json +++ b/doc/schemas/hook/htlc_accepted.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "htlc_accepted", + "hook": "htlc_accepted", "title": "Hook for handling incoming HTLCs", "description": [ "The **htlc_accepted** hook is called whenever an incoming HTLC is accepted.", diff --git a/doc/schemas/hook/invoice_payment.json b/doc/schemas/hook/invoice_payment.json index 3b9657cebab7..fb3bcf4a3519 100644 --- a/doc/schemas/hook/invoice_payment.json +++ b/doc/schemas/hook/invoice_payment.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "invoice_payment", + "hook": "invoice_payment", "title": "Hook fired when a payment for an invoice is received", "description": [ "The **invoice_payment** hook is called whenever a valid payment for an unpaid invoice has arrived.", @@ -10,8 +10,8 @@ "The hook is deliberately sparse. Plugins can use `listinvoices` to retrieve additional information.", "", "The plugin can:", - "- accept the payment by returning {\"result\": \"continue\"}", - "- reject the payment with a generic error using {\"result\": \"reject\"}", + "- accept the payment by returning `{\"result\": \"continue\"}`", + "- reject the payment with a generic error using `{\"result\": \"reject\"}`", "- reject the payment with a custom BOLT 4 failure message using the `failure_message` field", "", "If `failure_message` is provided, the payment will be failed with that message.", diff --git a/doc/schemas/hook/onion_message_recv.json b/doc/schemas/hook/onion_message_recv.json index c5c837370405..81515883bc6c 100644 --- a/doc/schemas/hook/onion_message_recv.json +++ b/doc/schemas/hook/onion_message_recv.json @@ -2,14 +2,14 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "onion_message_recv", + "hook": "onion_message_recv", "title": "Hook for receiving unsolicited onion messages", "description": [ "The **onion_message_recv** hook is used for unsolicited onion messages (where the source knows that it is sending to this node).", "", "Replies MUST be ignored unless they use the correct path (see onion_message_recv_secret).", "", - "Returning anything other than {\"result\": \"continue\"} prevents further hook processing." + "Returning anything other than `{\"result\": \"continue\"}` prevents further hook processing." ], "request": { "required": [ diff --git a/doc/schemas/hook/onion_message_recv_secret.json b/doc/schemas/hook/onion_message_recv_secret.json index 55ada6b4a45b..92e0b4665482 100644 --- a/doc/schemas/hook/onion_message_recv_secret.json +++ b/doc/schemas/hook/onion_message_recv_secret.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "onion_message_recv_secret", + "hook": "onion_message_recv_secret", "title": "Hook for receiving onion messages via blinded paths", "description": [ "The **onion_message_recv_secret** hook is used when an onion message is received via a blinded path previously provided by this node.", @@ -11,7 +11,7 @@ "", "Replies MUST only be sent when the `pathsecret` matches expectations.", "", - "Returning anything other than {\"result\": \"continue\"} prevents further hook processing." + "Returning anything other than `{\"result\": \"continue\"}` prevents further hook processing." ], "request": { "required": [ diff --git a/doc/schemas/hook/openchannel.json b/doc/schemas/hook/openchannel.json index 260614de7a99..51d368500754 100644 --- a/doc/schemas/hook/openchannel.json +++ b/doc/schemas/hook/openchannel.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel", + "hook": "openchannel", "title": "Hook fired when a peer proposes opening a channel using v1 protocol", "description": [ "The **openchannel** hook is called whenever a remote peer tries to fund a channel using the v1 protocol, after passing basic sanity checks.", diff --git a/doc/schemas/hook/openchannel2.json b/doc/schemas/hook/openchannel2.json index 4b551102bc56..51a10c6ae432 100644 --- a/doc/schemas/hook/openchannel2.json +++ b/doc/schemas/hook/openchannel2.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel2", + "hook": "openchannel2", "title": "Hook fired when a peer proposes opening a channel using v2 protocol", "description": [ "The **openchannel2** hook is called whenever a remote peer tries to fund a channel using the v2 (dual-funding) protocol, after passing basic sanity checks.", diff --git a/doc/schemas/hook/openchannel2_changed.json b/doc/schemas/hook/openchannel2_changed.json index 0d19729ca046..327e3b250985 100644 --- a/doc/schemas/hook/openchannel2_changed.json +++ b/doc/schemas/hook/openchannel2_changed.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel2_changed", + "hook": "openchannel2_changed", "title": "Hook for handling updates to the dual-funding PSBT", "description": [ "The **openchannel2_changed** hook is called when the peer sends an updated PSBT during dual-funding channel negotiation.", diff --git a/doc/schemas/hook/openchannel2_sign.json b/doc/schemas/hook/openchannel2_sign.json index 3917e8b38335..75cfb92d1553 100644 --- a/doc/schemas/hook/openchannel2_sign.json +++ b/doc/schemas/hook/openchannel2_sign.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "openchannel2_sign", + "hook": "openchannel2_sign", "title": "Hook for signing the dual-funding PSBT", "description": [ "The **openchannel2_sign** hook is called after commitment transactions have been received during dual-funding channel establishment.", @@ -71,7 +71,7 @@ } } }, - "example_notifications": [ + "example_hooks": [ { "method": "openchannel2_sign", "params": { diff --git a/doc/schemas/hook/peer_connected.json b/doc/schemas/hook/peer_connected.json index 78fd60c74611..9ac63327a64c 100644 --- a/doc/schemas/hook/peer_connected.json +++ b/doc/schemas/hook/peer_connected.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "peer_connected", + "hook": "peer_connected", "title": "Hook fired when a peer connects and completes handshake", "description": [ "The **peer_connected** hook is called whenever a peer has connected and successfully completed the cryptographic handshake.", diff --git a/doc/schemas/hook/rbf_channel.json b/doc/schemas/hook/rbf_channel.json index 6aed12464dd2..2a391de88120 100644 --- a/doc/schemas/hook/rbf_channel.json +++ b/doc/schemas/hook/rbf_channel.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "rbf_channel", + "hook": "rbf_channel", "title": "Hook for handling RBF channel funding requests", "description": [ "The **rbf_channel** hook is called when a peer proposes replacing the funding transaction of an existing channel using Replace-By-Fee (RBF).", diff --git a/doc/schemas/hook/recover.json b/doc/schemas/hook/recover.json index f9f246c7bb0f..e1a49bbdb5fc 100644 --- a/doc/schemas/hook/recover.json +++ b/doc/schemas/hook/recover.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "v23.08", "type": "object", - "notification": "recover", + "hook": "recover", "title": "Hook fired when node starts in recovery mode", "description": [ "The **recover** hook is called whenever the node is started using the --recovery flag.", diff --git a/doc/schemas/hook/rpc_command.json b/doc/schemas/hook/rpc_command.json index 4bbf8ec3dffc..26327f6ba9f8 100644 --- a/doc/schemas/hook/rpc_command.json +++ b/doc/schemas/hook/rpc_command.json @@ -2,7 +2,7 @@ "$schema": "../rpc-schema-draft.json", "added": "pre-v0.10.1", "type": "object", - "notification": "rpc_command", + "hook": "rpc_command", "title": "Hook for intercepting and modifying RPC commands", "description": [ "The **rpc_command** hook allows a plugin to take over any RPC command.", diff --git a/doc/schemas/notification/balance_snapshot.json b/doc/schemas/notification/balance_snapshot.json index b2458ecaf3e8..da52436f3bda 100644 --- a/doc/schemas/notification/balance_snapshot.json +++ b/doc/schemas/notification/balance_snapshot.json @@ -8,11 +8,8 @@ "The **balance_snapshot** notification informs whenever lightningd emits a balance snapshot for bookkeeping." ], "added": "v24.11", - "request": { - "added": "v24.11" - }, + "request": {}, "response": { - "added": "v24.11", "required": [ "node_id", "blockheight", @@ -24,32 +21,27 @@ "type": "pubkey", "description": [ "The node id the snapshot was taken for." - ], - "added": "v24.11" + ] }, "blockheight": { "type": "u32", "description": [ "The blockheight at which the snapshot was taken." - ], - "added": "v24.11" + ] }, "timestamp": { "type": "u32", "description": [ "The snapshot time as seconds since epoch." - ], - "added": "v24.11" + ] }, "accounts": { "type": "array", "description": [ "The balances for each tracked account at the snapshot time." ], - "added": "v24.11", "items": { "type": "object", - "added": "v24.11", "additionalProperties": false, "required": [ "account_id", @@ -61,22 +53,19 @@ "type": "string", "description": [ "The account identifier for the balance." - ], - "added": "v24.11" + ] }, "balance_msat": { "type": "msat", "description": [ "The account balance in millisatoshis." - ], - "added": "v24.11" + ] }, "coin_type": { "type": "string", "description": [ "The BIP173 coin type name for the balance." - ], - "added": "v24.11" + ] } } } diff --git a/doc/schemas/notification/block_added.json b/doc/schemas/notification/block_added.json index 4bde510860cb..182decb2e3cb 100644 --- a/doc/schemas/notification/block_added.json +++ b/doc/schemas/notification/block_added.json @@ -19,15 +19,13 @@ "type": "hash", "description": [ "The hash of the block." - ], - "added": "v22.11" + ] }, "height": { "type": "u32", "description": [ "The total block height." - ], - "added": "v22.11" + ] } } } diff --git a/doc/schemas/notification/channel_open_failed.json b/doc/schemas/notification/channel_open_failed.json index 91e1a28ba1a6..809f0a873570 100644 --- a/doc/schemas/notification/channel_open_failed.json +++ b/doc/schemas/notification/channel_open_failed.json @@ -18,8 +18,7 @@ "type": "hash", "description": [ "The channel id of the channel." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/channel_opened.json b/doc/schemas/notification/channel_opened.json index 50ce4e5546ba..a59f7e5f9729 100644 --- a/doc/schemas/notification/channel_opened.json +++ b/doc/schemas/notification/channel_opened.json @@ -21,29 +21,25 @@ "type": "pubkey", "description": [ "The id of the peer which opened the channel" - ], - "added": "pre-v0.10.1" + ] }, "funding_msat": { "type": "msat", "description": [ "The amount of the funding transaction" - ], - "added": "pre-v0.10.1" + ] }, "funding_txid": { "type": "txid", "description": [ "The transaction id of the funding transaction" - ], - "added": "pre-v0.10.1" + ] }, "channel_ready": { "type": "boolean", "description": [ "true if the channel is ready" - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/channel_state_changed.json b/doc/schemas/notification/channel_state_changed.json index d8eea70c6689..d31d6a324fe3 100644 --- a/doc/schemas/notification/channel_state_changed.json +++ b/doc/schemas/notification/channel_state_changed.json @@ -5,7 +5,7 @@ "notification": "channel_state_changed", "title": "Notification for channel state change", "description": [ - "The **channel_state_changed** informs whenever the state of the channel has been updated." + "The **channel_state_changed** notification informs whenever the state of the channel has been updated." ], "added": "pre-v0.10.1", "request": {}, @@ -22,29 +22,25 @@ "type": "pubkey", "description": [ "The peer id of the channel." - ], - "added": "pre-v0.10.1" + ] }, "channel_id": { "type": "hash", "description": [ "The channel id of the channel." - ], - "added": "pre-v0.10.1" + ] }, "short_channel_id": { "type": "short_channel_id", "description": [ "The short channel id of the channel. If the channel is not yet confirmed, this field will be null." - ], - "added": "pre-v0.10.1" + ] }, "timestamp": { "type": "string", "description": [ "The timestamp of the state change." - ], - "added": "pre-v0.10.1" + ] }, "old_state": { "type": "string", @@ -67,8 +63,7 @@ "description": [ "The channel state, in particular \"CHANNELD_NORMAL\" and \"CHANNELD_AWAITING_SPLICE\" mean the channel can be used normally.", "The deprecated value 'unknown' is also present for new channels: after v26.04 this field will be omitted instead." - ], - "added": "pre-v0.10.1" + ] }, "new_state": { "type": "string", @@ -90,10 +85,9 @@ "CLOSED" ], "description": [ - "The channel state, in particular \"CHANNELD_NORMAL\" and \"CHANNELD_AWAITING_SPLICE\" mean the channel can be used normally", + "The channel state, in particular \"CHANNELD_NORMAL\" and \"CHANNELD_AWAITING_SPLICE\" mean the channel can be used normally.", "Note: *CLOSED* state was only added in v25.12." - ], - "added": "pre-v0.10.1" + ] }, "cause": { "type": "string", @@ -107,15 +101,13 @@ ], "description": [ "The cause of the state change." - ], - "added": "pre-v0.10.1" + ] }, "message": { "type": "string", "description": [ "The state change message." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/coin_movement.json b/doc/schemas/notification/coin_movement.json index ab526c6e24f6..2fa85f7de6f2 100644 --- a/doc/schemas/notification/coin_movement.json +++ b/doc/schemas/notification/coin_movement.json @@ -8,11 +8,8 @@ "The **coin_movement** notification informs whenever lightningd records a finalized ledger movement." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "version", "coin_type", @@ -30,22 +27,19 @@ "type": "u32", "description": [ "The coin movement schema version." - ], - "added": "pre-v0.10.1" + ] }, "coin_type": { "type": "string", "description": [ "The BIP173 coin type name." - ], - "added": "pre-v0.10.1" + ] }, "node_id": { "type": "pubkey", "description": [ "The node id that emitted the notification." - ], - "added": "pre-v0.10.1" + ] }, "type": { "type": "string", @@ -55,8 +49,7 @@ ], "description": [ "Whether this is a channel or chain movement." - ], - "added": "pre-v0.10.1" + ] }, "created_index": { "type": "u64", @@ -69,43 +62,37 @@ "type": "string", "description": [ "The account identifier for the movement." - ], - "added": "pre-v0.10.1" + ] }, "credit_msat": { "type": "msat", "description": [ "Amount credited to the account." - ], - "added": "pre-v0.10.1" + ] }, "debit_msat": { "type": "msat", "description": [ "Amount debited from the account." - ], - "added": "pre-v0.10.1" + ] }, "timestamp": { "type": "u64", "description": [ "The UNIX timestamp when the movement was recorded." - ], - "added": "pre-v0.10.1" + ] }, "tags": { "type": "array", "description": [ "Deprecated legacy combined tag array, emitted only for deprecated output compatibility." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" ], "items": { "type": "string", - "added": "pre-v0.10.1", "description": [ "A legacy movement tag." ] @@ -151,7 +138,6 @@ "added": "v25.09", "items": { "type": "string", - "added": "v25.09", "description": [ "An additional movement tag." ] @@ -161,29 +147,25 @@ "type": "hash", "description": [ "The payment hash associated with the movement, if any." - ], - "added": "pre-v0.10.1" + ] }, "part_id": { "type": "u64", "description": [ "The part id for a multi-part channel payment." - ], - "added": "pre-v0.10.1" + ] }, "group_id": { "type": "u64", "description": [ "The group id for a multi-part channel payment." - ], - "added": "pre-v0.10.1" + ] }, "fees_msat": { "type": "msat", "description": [ "The fees associated with a channel movement." - ], - "added": "pre-v0.10.1" + ] }, "utxo": { "type": "outpoint", @@ -196,22 +178,19 @@ "type": "pubkey", "description": [ "The peer associated with a chain movement, if any." - ], - "added": "pre-v0.10.1" + ] }, "originating_account": { "type": "string", "description": [ "The originating account for an external chain movement, if any." - ], - "added": "pre-v0.10.1" + ] }, "txid": { "type": "txid", "description": [ "Deprecated legacy field for the spending transaction id." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" @@ -229,7 +208,6 @@ "description": [ "Deprecated legacy field for the outpoint transaction id." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" @@ -240,7 +218,6 @@ "description": [ "Deprecated legacy field for the outpoint output index." ], - "added": "pre-v0.10.1", "deprecated": [ "v25.09", "v26.09" @@ -250,22 +227,19 @@ "type": "msat", "description": [ "The output amount for a chain movement." - ], - "added": "pre-v0.10.1" + ] }, "output_count": { "type": "u32", "description": [ "The number of outputs in the spending transaction, if known." - ], - "added": "pre-v0.10.1" + ] }, "blockheight": { "type": "u32", "description": [ "The blockheight for a chain movement." - ], - "added": "pre-v0.10.1" + ] } }, "allOf": [ diff --git a/doc/schemas/notification/connect.json b/doc/schemas/notification/connect.json index 1fbe9310f81a..ca1cfd145378 100644 --- a/doc/schemas/notification/connect.json +++ b/doc/schemas/notification/connect.json @@ -4,7 +4,7 @@ "notification": "connect", "title": "Notification for connection with a peer", "description": [ - "The **connect** informs whenever the node is connected to a peer." + "The **connect** notification informs whenever the node is connected to a peer." ], "additionalProperties": false, "added": "pre-v0.10.1", @@ -20,8 +20,7 @@ "type": "pubkey", "description": [ "The id of the peer which sent the custom message" - ], - "added": "pre-v0.10.1" + ] }, "direction": { "type": "string", @@ -31,15 +30,13 @@ ], "description": [ "Direction of the connection" - ], - "added": "pre-v0.10.1" + ] }, "address": { "type": "object", "description": [ "Address information (mainly useful if **direction** is *out*)" ], - "added": "pre-v0.10.1", "additionalProperties": true, "required": [ "type" @@ -47,7 +44,6 @@ "properties": { "type": { "type": "string", - "added": "pre-v0.10.1", "enum": [ "local socket", "ipv4", @@ -82,7 +78,6 @@ "type": {}, "socket": { "type": "string", - "added": "pre-v0.10.1", "description": [ "Socket filename" ] @@ -114,14 +109,12 @@ "type": {}, "address": { "type": "string", - "added": "pre-v0.10.1", "description": [ "Address in expected format for **type**" ] }, "port": { "type": "u16", - "added": "pre-v0.10.1", "description": [ "Port number" ] diff --git a/doc/schemas/notification/custommsg.json b/doc/schemas/notification/custommsg.json index 61f6447de334..b099b7e73f39 100644 --- a/doc/schemas/notification/custommsg.json +++ b/doc/schemas/notification/custommsg.json @@ -19,15 +19,13 @@ "type": "pubkey", "description": [ "The id of the peer which sent the custom message" - ], - "added": "v24.02" + ] }, "payload": { "type": "hex", "description": [ "The hex-encoded payload. The first 2 bytes represent the BOLT-8 message type followed by the message content" - ], - "added": "v24.02" + ] } } } diff --git a/doc/schemas/notification/deprecated_oneshot.json b/doc/schemas/notification/deprecated_oneshot.json index 63c44e2ec621..e0edc00c90fa 100644 --- a/doc/schemas/notification/deprecated_oneshot.json +++ b/doc/schemas/notification/deprecated_oneshot.json @@ -8,11 +8,8 @@ "The **deprecated_oneshot** notification informs a plugin that the immediately following command uses different deprecation handling than the global setting." ], "added": "v24.02", - "request": { - "added": "v24.02" - }, + "request": {}, "response": { - "added": "v24.02", "required": [ "deprecated_ok" ], @@ -21,8 +18,7 @@ "type": "boolean", "description": [ "Whether deprecated APIs are allowed for the immediately following command." - ], - "added": "v24.02" + ] } } } diff --git a/doc/schemas/notification/disconnect.json b/doc/schemas/notification/disconnect.json index 3cf079e49244..63351ef205fd 100644 --- a/doc/schemas/notification/disconnect.json +++ b/doc/schemas/notification/disconnect.json @@ -8,11 +8,8 @@ "The **disconnect** notification informs whenever the node disconnects from a peer." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "id" ], @@ -21,8 +18,7 @@ "type": "pubkey", "description": [ "The id of the peer that disconnected." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/forward_event.json b/doc/schemas/notification/forward_event.json index 0b59ef827eba..920941bc3ac0 100644 --- a/doc/schemas/notification/forward_event.json +++ b/doc/schemas/notification/forward_event.json @@ -8,11 +8,8 @@ "The **forward_event** notification informs whenever the status of a forwarded HTLC changes." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "payment_hash", "in_channel", @@ -25,43 +22,37 @@ "type": "hash", "description": [ "The payment hash for the forwarded HTLC." - ], - "added": "pre-v0.10.1" + ] }, "in_channel": { "type": "short_channel_id", "description": [ "The inbound channel that received the HTLC." - ], - "added": "pre-v0.10.1" + ] }, "out_channel": { "type": "short_channel_id", "description": [ "The outbound channel used for the forward, if one was selected." - ], - "added": "pre-v0.10.1" + ] }, "in_msat": { "type": "msat", "description": [ "The amount of the incoming HTLC." - ], - "added": "pre-v0.10.1" + ] }, "out_msat": { "type": "msat", "description": [ "The amount forwarded to the outbound channel, if known." - ], - "added": "pre-v0.10.1" + ] }, "fee_msat": { "type": "msat", "description": [ "The fee earned on the forward, if an outbound amount is known." - ], - "added": "pre-v0.10.1" + ] }, "status": { "type": "string", @@ -73,22 +64,19 @@ ], "description": [ "The current forwarding status." - ], - "added": "pre-v0.10.1" + ] }, "failcode": { "type": "u32", "description": [ "The BOLT 4 failcode when the forward failed locally." - ], - "added": "pre-v0.10.1" + ] }, "failreason": { "type": "string", "description": [ "The symbolic failcode name when the forward failed locally." - ], - "added": "pre-v0.10.1" + ] }, "style": { "type": "string", @@ -105,15 +93,13 @@ "type": "number", "description": [ "The UNIX timestamp when the HTLC was received." - ], - "added": "pre-v0.10.1" + ] }, "resolved_time": { "type": "number", "description": [ "The UNIX timestamp when the HTLC was resolved, if it has been resolved." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/invoice_creation.json b/doc/schemas/notification/invoice_creation.json index 735f46fa9898..b39c6d74cb57 100644 --- a/doc/schemas/notification/invoice_creation.json +++ b/doc/schemas/notification/invoice_creation.json @@ -8,11 +8,8 @@ "The **invoice_creation** notification informs whenever a new invoice is created." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "preimage", "label" @@ -22,22 +19,19 @@ "type": "msat", "description": [ "The invoice amount, if the invoice amount was specified at creation time." - ], - "added": "pre-v0.10.1" + ] }, "preimage": { "type": "secret", "description": [ "The payment preimage for the created invoice." - ], - "added": "pre-v0.10.1" + ] }, "label": { "type": "string", "description": [ "The label of the created invoice." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/invoice_payment.json b/doc/schemas/notification/invoice_payment.json index 2feb86f5db8a..4f0261ab4e0d 100644 --- a/doc/schemas/notification/invoice_payment.json +++ b/doc/schemas/notification/invoice_payment.json @@ -8,11 +8,8 @@ "The **invoice_payment** notification informs whenever an invoice is paid." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "msat", "preimage", @@ -23,15 +20,13 @@ "type": "msat", "description": [ "The amount paid for the invoice." - ], - "added": "pre-v0.10.1" + ] }, "preimage": { "type": "secret", "description": [ "The payment preimage for the invoice." - ], - "added": "pre-v0.10.1" + ] }, "outpoint": { "type": "outpoint", @@ -44,8 +39,7 @@ "type": "string", "description": [ "The label of the paid invoice." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/log.json b/doc/schemas/notification/log.json index 34c343be0ee5..1617e3bbf8a9 100644 --- a/doc/schemas/notification/log.json +++ b/doc/schemas/notification/log.json @@ -8,11 +8,8 @@ "The **log** notification informs whenever lightningd emits a log message and exposes the same payload shape as **warning**." ], "added": "v24.02", - "request": { - "added": "v24.02" - }, + "request": {}, "response": { - "added": "v24.02", "required": [ "level", "time", @@ -33,36 +30,31 @@ ], "description": [ "The log level of the emitted message." - ], - "added": "v24.02" + ] }, "time": { "type": "string", "description": [ "The event time as seconds since epoch with subsecond precision." - ], - "added": "v24.02" + ] }, "timestamp": { "type": "string", "description": [ "The event time in ISO 8601 format." - ], - "added": "v24.02" + ] }, "source": { "type": "string", "description": [ "The source component that emitted the log entry." - ], - "added": "v24.02" + ] }, "log": { "type": "string", "description": [ "The original log message." - ], - "added": "v24.02" + ] } } } diff --git a/doc/schemas/notification/onionmessage_forward_fail.json b/doc/schemas/notification/onionmessage_forward_fail.json index d7d01a8e59e9..ba04a465c92f 100644 --- a/doc/schemas/notification/onionmessage_forward_fail.json +++ b/doc/schemas/notification/onionmessage_forward_fail.json @@ -8,11 +8,8 @@ "The **onionmessage_forward_fail** notification informs whenever lightningd cannot forward an onion message." ], "added": "v24.11", - "request": { - "added": "v24.11" - }, + "request": {}, "response": { - "added": "v24.11", "required": [ "source", "incoming", @@ -23,43 +20,37 @@ "type": "pubkey", "description": [ "The node that sent the incoming onion message." - ], - "added": "v24.11" + ] }, "incoming": { "type": "hex", "description": [ "The incoming onion message payload." - ], - "added": "v24.11" + ] }, "path_key": { "type": "pubkey", "description": [ "The path key used for the attempted forward." - ], - "added": "v24.11" + ] }, "outgoing": { "type": "hex", "description": [ "The outgoing onion message payload if a next hop had already been selected." - ], - "added": "v24.11" + ] }, "next_node_id": { "type": "pubkey", "description": [ "The next node id for the attempted forward when the next hop is a node." - ], - "added": "v24.11" + ] }, "next_short_channel_id_dir": { "type": "short_channel_id_dir", "description": [ "The next short_channel_id_dir for the attempted forward when the next hop is a channel." - ], - "added": "v24.11" + ] } } } diff --git a/doc/schemas/notification/openchannel_peer_sigs.json b/doc/schemas/notification/openchannel_peer_sigs.json index 0793bda0a180..8f3f3ed7ac32 100644 --- a/doc/schemas/notification/openchannel_peer_sigs.json +++ b/doc/schemas/notification/openchannel_peer_sigs.json @@ -8,11 +8,8 @@ "The **openchannel_peer_sigs** notification informs whenever a peer provides signatures for an in-progress channel open." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "channel_id", "signed_psbt" @@ -22,15 +19,13 @@ "type": "hash", "description": [ "The channel id for the channel open attempt." - ], - "added": "pre-v0.10.1" + ] }, "signed_psbt": { "type": "string", "description": [ "The signed PSBT from the peer." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/plugin_started.json b/doc/schemas/notification/plugin_started.json index 63720e5740d1..7cd2c6e9f93e 100644 --- a/doc/schemas/notification/plugin_started.json +++ b/doc/schemas/notification/plugin_started.json @@ -8,11 +8,8 @@ "The **plugin_started** notification informs whenever a plugin has started and registered its methods." ], "added": "v25.02", - "request": { - "added": "v25.02" - }, + "request": {}, "response": { - "added": "v25.02", "required": [ "plugin_name", "plugin_path", @@ -23,28 +20,24 @@ "type": "string", "description": [ "The short name of the plugin." - ], - "added": "v25.02" + ] }, "plugin_path": { "type": "string", "description": [ "The executable path of the plugin." - ], - "added": "v25.02" + ] }, "methods": { "type": "array", "description": [ "The RPC methods registered by the plugin." ], - "added": "v25.02", "items": { "type": "string", "description": [ "A method registered by the plugin." - ], - "added": "v25.02" + ] } } } diff --git a/doc/schemas/notification/plugin_stopped.json b/doc/schemas/notification/plugin_stopped.json index 90c6cd634ed0..ab6a7e034dd8 100644 --- a/doc/schemas/notification/plugin_stopped.json +++ b/doc/schemas/notification/plugin_stopped.json @@ -8,11 +8,8 @@ "The **plugin_stopped** notification informs whenever a plugin stops and exposes the same payload shape as **plugin_started**." ], "added": "v25.02", - "request": { - "added": "v25.02" - }, + "request": {}, "response": { - "added": "v25.02", "required": [ "plugin_name", "plugin_path", @@ -23,28 +20,24 @@ "type": "string", "description": [ "The short name of the plugin." - ], - "added": "v25.02" + ] }, "plugin_path": { "type": "string", "description": [ "The executable path of the plugin." - ], - "added": "v25.02" + ] }, "methods": { "type": "array", "description": [ "The RPC methods registered by the plugin." ], - "added": "v25.02", "items": { "type": "string", "description": [ "A method registered by the plugin." - ], - "added": "v25.02" + ] } } } diff --git a/doc/schemas/notification/sendpay_failure.json b/doc/schemas/notification/sendpay_failure.json index fc7af72e7311..02e47b1c3bdd 100644 --- a/doc/schemas/notification/sendpay_failure.json +++ b/doc/schemas/notification/sendpay_failure.json @@ -8,11 +8,8 @@ "The **sendpay_failure** notification informs whenever a payment attempt completes with failed status." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "code", "message", @@ -23,15 +20,13 @@ "type": "integer", "description": [ "The JSON-RPC error code for the payment failure." - ], - "added": "pre-v0.10.1" + ] }, "message": { "type": "string", "description": [ "The human-readable payment failure message." - ], - "added": "pre-v0.10.1" + ] }, "data": { "type": "object", @@ -39,7 +34,6 @@ "description": [ "The structured payment failure details." ], - "added": "pre-v0.10.1", "properties": { "created_index": { "type": "u64", @@ -52,22 +46,19 @@ "type": "u64", "description": [ "Old synonym for created_index." - ], - "added": "pre-v0.10.1" + ] }, "payment_hash": { "type": "hash", "description": [ "The hash of the payment preimage." - ], - "added": "pre-v0.10.1" + ] }, "groupid": { "type": "u64", "description": [ "Grouping key for multiple attempts on the same payment." - ], - "added": "pre-v0.10.1" + ] }, "updated_index": { "type": "u64", @@ -80,43 +71,37 @@ "type": "u64", "description": [ "Part number for a multi-part payment." - ], - "added": "pre-v0.10.1" + ] }, "destination": { "type": "pubkey", "description": [ "The final destination of the payment, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_msat": { "type": "msat", "description": [ "The amount intended for the destination, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_sent_msat": { "type": "msat", "description": [ "The total amount sent including fees." - ], - "added": "pre-v0.10.1" + ] }, "created_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment was initiated." - ], - "added": "pre-v0.10.1" + ] }, "completed_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment completed." - ], - "added": "pre-v0.10.1" + ] }, "status": { "type": "string", @@ -127,29 +112,25 @@ ], "description": [ "The terminal status for a failed sendpay notification." - ], - "added": "pre-v0.10.1" + ] }, "payment_preimage": { "type": "secret", "description": [ "The payment preimage, if the payment later completed through another path." - ], - "added": "pre-v0.10.1" + ] }, "label": { "type": "string", "description": [ "The optional label associated with the payment." - ], - "added": "pre-v0.10.1" + ] }, "bolt11": { "type": "string", "description": [ "The bolt11 invoice string, if present." - ], - "added": "pre-v0.10.1" + ] }, "bolt12": { "type": "string", @@ -162,71 +143,61 @@ "type": "string", "description": [ "The description associated with the payment, if present." - ], - "added": "pre-v0.10.1" + ] }, "erroronion": { "type": "hex", "description": [ "The raw error onion if one was retained for the payment." - ], - "added": "pre-v0.10.1" + ] }, "onionreply": { "type": "hex", "description": [ "The onion reply for an unparseable onion failure." - ], - "added": "pre-v0.10.1" + ] }, "erring_index": { "type": "u32", "description": [ "The position in the route where the failure occurred." - ], - "added": "pre-v0.10.1" + ] }, "failcode": { "type": "u32", "description": [ "The BOLT 4 failcode." - ], - "added": "pre-v0.10.1" + ] }, "failcodename": { "type": "string", "description": [ "The symbolic name for the failcode, if known." - ], - "added": "pre-v0.10.1" + ] }, "erring_node": { "type": "pubkey", "description": [ "The node that produced the failure, if known." - ], - "added": "pre-v0.10.1" + ] }, "erring_channel": { "type": "short_channel_id", "description": [ "The channel that produced the failure, if known." - ], - "added": "pre-v0.10.1" + ] }, "erring_direction": { "type": "u32", "description": [ "The direction within the erring channel." - ], - "added": "pre-v0.10.1" + ] }, "raw_message": { "type": "hex", "description": [ "The raw failure message payload, if present." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/sendpay_success.json b/doc/schemas/notification/sendpay_success.json index 7827725491a1..a434b191efa1 100644 --- a/doc/schemas/notification/sendpay_success.json +++ b/doc/schemas/notification/sendpay_success.json @@ -8,11 +8,8 @@ "The **sendpay_success** notification informs whenever a payment attempt completes successfully." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "created_index", "id", @@ -34,22 +31,19 @@ "type": "u64", "description": [ "Old synonym for created_index." - ], - "added": "pre-v0.10.1" + ] }, "payment_hash": { "type": "hash", "description": [ "The hash of the payment preimage." - ], - "added": "pre-v0.10.1" + ] }, "groupid": { "type": "u64", "description": [ "Grouping key for multiple attempts on the same payment." - ], - "added": "pre-v0.10.1" + ] }, "updated_index": { "type": "u64", @@ -62,43 +56,37 @@ "type": "u64", "description": [ "Part number for a multi-part payment." - ], - "added": "pre-v0.10.1" + ] }, "destination": { "type": "pubkey", "description": [ "The final destination of the payment, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_msat": { "type": "msat", "description": [ "The amount delivered to the destination, if known." - ], - "added": "pre-v0.10.1" + ] }, "amount_sent_msat": { "type": "msat", "description": [ "The total amount sent including fees." - ], - "added": "pre-v0.10.1" + ] }, "created_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment was initiated." - ], - "added": "pre-v0.10.1" + ] }, "completed_at": { "type": "u64", "description": [ "The UNIX timestamp when this payment completed." - ], - "added": "pre-v0.10.1" + ] }, "status": { "type": "string", @@ -107,29 +95,25 @@ ], "description": [ "The terminal status for a successful sendpay notification." - ], - "added": "pre-v0.10.1" + ] }, "payment_preimage": { "type": "secret", "description": [ "The payment preimage proving success." - ], - "added": "pre-v0.10.1" + ] }, "label": { "type": "string", "description": [ "The optional label associated with the payment." - ], - "added": "pre-v0.10.1" + ] }, "bolt11": { "type": "string", "description": [ "The bolt11 invoice string, if present." - ], - "added": "pre-v0.10.1" + ] }, "bolt12": { "type": "string", @@ -142,15 +126,13 @@ "type": "string", "description": [ "The description associated with the payment, if present." - ], - "added": "pre-v0.10.1" + ] }, "erroronion": { "type": "hex", "description": [ "The raw error onion if one was retained for the payment." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/shutdown.json b/doc/schemas/notification/shutdown.json index d165ef8147d3..5e9d84a08abc 100644 --- a/doc/schemas/notification/shutdown.json +++ b/doc/schemas/notification/shutdown.json @@ -5,14 +5,14 @@ "notification": "shutdown", "title": "Notification for plugin shutdown", "description": [ - "The **shutdown** notification informs a plugin that lightningd is shutting down." + "The **shutdown** notification informs a plugin that lightningd is shutting down.", + "", + "It is expected that the plugin terminates it's own process when subscribing to this notification.", + "If it does not do so, lightningd will kill the plugin's process after a timeout." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "properties": {} } } diff --git a/doc/schemas/notification/warning.json b/doc/schemas/notification/warning.json index 6d1df00f15c7..5d54b0f79743 100644 --- a/doc/schemas/notification/warning.json +++ b/doc/schemas/notification/warning.json @@ -8,11 +8,8 @@ "The **warning** notification informs whenever lightningd emits a warning or error level event that should be surfaced to plugins." ], "added": "pre-v0.10.1", - "request": { - "added": "pre-v0.10.1" - }, + "request": {}, "response": { - "added": "pre-v0.10.1", "required": [ "level", "time", @@ -29,15 +26,13 @@ ], "description": [ "The log level of the warning notification." - ], - "added": "pre-v0.10.1" + ] }, "time": { "type": "string", "description": [ "The event time as seconds since epoch with subsecond precision." - ], - "added": "pre-v0.10.1" + ] }, "timestamp": { "type": "string", @@ -50,15 +45,13 @@ "type": "string", "description": [ "The source component that emitted the log entry." - ], - "added": "pre-v0.10.1" + ] }, "log": { "type": "string", "description": [ "The original log message." - ], - "added": "pre-v0.10.1" + ] } } } diff --git a/doc/schemas/notification/xpay_pay_part_end.json b/doc/schemas/notification/xpay_pay_part_end.json index 814c02b1efce..bbfc6c8e940c 100644 --- a/doc/schemas/notification/xpay_pay_part_end.json +++ b/doc/schemas/notification/xpay_pay_part_end.json @@ -8,11 +8,8 @@ "The **pay_part_end** notification is emitted by the xpay plugin when a payment part completes." ], "added": "v25.09", - "request": { - "added": "v25.09" - }, + "request": {}, "response": { - "added": "v25.09", "required": [ "status", "duration", @@ -29,78 +26,67 @@ ], "description": [ "Whether the payment part succeeded or failed." - ], - "added": "v25.09" + ] }, "duration": { "type": "number", "description": [ "The time in seconds from send to result." - ], - "added": "v25.09" + ] }, "payment_hash": { "type": "hash", "description": [ "The payment hash for the xpay invocation." - ], - "added": "v25.09" + ] }, "groupid": { "type": "u64", "description": [ "The xpay group identifier for the payment attempt." - ], - "added": "v25.09" + ] }, "partid": { "type": "u64", "description": [ "The identifier for this payment part." - ], - "added": "v25.09" + ] }, "failed_msg": { "type": "hex", "description": [ "The decrypted onion error message, if available." - ], - "added": "v25.09" + ] }, "failed_node_id": { "type": "pubkey", "description": [ "The node that generated the failure, if known." - ], - "added": "v25.09" + ] }, "failed_short_channel_id": { "type": "short_channel_id", "description": [ "The short channel id complained about, if known." - ], - "added": "v25.09" + ] }, "failed_direction": { "type": "u32", "description": [ "The direction within the failed short channel id, if known." - ], - "added": "v25.09" + ] }, "error_code": { "type": "u32", "description": [ "The xpay error code, if known." - ], - "added": "v25.09" + ] }, "error_message": { "type": "string", "description": [ "The human-readable xpay error message." - ], - "added": "v25.09" + ] } } } diff --git a/doc/schemas/notification/xpay_pay_part_start.json b/doc/schemas/notification/xpay_pay_part_start.json index e3f2a7fd2331..ccc73ce0c33b 100644 --- a/doc/schemas/notification/xpay_pay_part_start.json +++ b/doc/schemas/notification/xpay_pay_part_start.json @@ -8,11 +8,8 @@ "The **pay_part_start** notification is emitted by the xpay plugin when a payment part begins." ], "added": "v25.09", - "request": { - "added": "v25.09" - }, + "request": {}, "response": { - "added": "v25.09", "required": [ "payment_hash", "groupid", @@ -26,46 +23,39 @@ "type": "hash", "description": [ "The payment hash for the xpay invocation." - ], - "added": "v25.09" + ] }, "groupid": { "type": "u64", "description": [ "The xpay group identifier for the payment attempt." - ], - "added": "v25.09" + ] }, "partid": { "type": "u64", "description": [ "The identifier for this payment part." - ], - "added": "v25.09" + ] }, "total_payment_msat": { "type": "msat", "description": [ "The total payment amount for the xpay invocation." - ], - "added": "v25.09" + ] }, "attempt_msat": { "type": "msat", "description": [ "The amount this payment part attempts to deliver." - ], - "added": "v25.09" + ] }, "hops": { "type": "array", "description": [ "The route hops for this payment part." ], - "added": "v25.09", "items": { "type": "object", - "added": "v25.09", "additionalProperties": false, "required": [ "next_node", @@ -79,36 +69,31 @@ "type": "pubkey", "description": [ "The next node for this hop." - ], - "added": "v25.09" + ] }, "short_channel_id": { "type": "short_channel_id", "description": [ "The short channel id used for this hop." - ], - "added": "v25.09" + ] }, "direction": { "type": "u32", "description": [ "The direction within the short channel id." - ], - "added": "v25.09" + ] }, "channel_in_msat": { "type": "msat", "description": [ "The amount entering the hop." - ], - "added": "v25.09" + ] }, "channel_out_msat": { "type": "msat", "description": [ "The amount leaving the hop." - ], - "added": "v25.09" + ] } } } diff --git a/tools/fromschema.py b/tools/fromschema.py index dc20aaa03b1f..69237a19e5f1 100755 --- a/tools/fromschema.py +++ b/tools/fromschema.py @@ -5,6 +5,7 @@ from argparse import ArgumentParser import json import re +import os # To maintain the sequence of the before return value (body) and after return value (footer) sections in the markdown file BODY_KEY_SEQUENCE = ['reliability', 'restriction_format', 'permitted_sqlite3_functions', 'treatment_of_types', 'tables', 'notes', 'notifications', 'sharing_runes', 'riskfactor_effect_on_routing', 'recommended_riskfactor_values', 'optimality', 'randomization'] @@ -87,7 +88,7 @@ def output_conditional_params(conditional_sub_array, condition): def output_type(properties, is_optional): """Add types for request and reponse parameters""" - typename = 'one of' if 'oneOf' in properties else esc_underscores(properties['type']) + typename = 'one of' if 'oneOf' in properties else esc_underscores(properties.get('type', 'any')) if typename == 'array': if 'items' in properties and 'type' in properties['items']: typename += ' of {}s'.format(esc_underscores(properties['items']['type'])) @@ -152,6 +153,9 @@ def output_member(propname, properties, is_optional, indent, print_type=True, pr if 'hidden' in properties and properties['hidden']: return + if ('type' not in properties and 'properties' not in properties and 'oneOf' not in properties and 'untyped' not in properties): + return + if prefix is None: prefix = '- ' + fmt_propname(propname) if propname is not None else '-' output(indent + prefix) @@ -174,16 +178,16 @@ def output_member(propname, properties, is_optional, indent, print_type=True, pr if 'deprecated' in properties: output(' **deprecated in {}, removed after {}**'.format(properties['deprecated'][0], properties['deprecated'][1] if len(properties['deprecated']) > 1 else deprecated_to_deleted(properties['deprecated'][0]))) - if 'added' in properties: + if 'added' in properties and properties['added'] != 'pre-v0.10.1': output(' *(added {})*'.format(properties['added'])) if 'oneOf' in properties and isinstance(properties['oneOf'], list): output(':\n') output_members(properties, indent + ' ') - elif not is_untyped and properties['type'] == 'object': + elif not is_untyped and properties.get('type') == 'object': output(':\n') output_members(properties, indent + ' ') - elif not is_untyped and properties['type'] == 'array': + elif not is_untyped and properties.get('type') == 'array': output(':\n') output_array(properties['items'], indent + ' ') else: @@ -192,11 +196,15 @@ def output_member(propname, properties, is_optional, indent, print_type=True, pr def output_array(items, indent): """We've already said it's an array of {type}""" + if not isinstance(items, dict) or items == {}: + output(indent + '- (any type)\n') + return + if 'oneOf' in items and isinstance(items['oneOf'], list): output_members(items, indent + ' ') - elif items['type'] == 'object': + elif items.get('type') == 'object': output_members(items, indent) - elif items['type'] == 'array': + elif items.get('type') == 'array': output(indent + '-') output_type(items, False) output(': {}\n'.format(esc_underscores('\n'.join(items['description']))) if 'description' in items and len(items['description']) > 0 else '\n') @@ -205,10 +213,15 @@ def output_array(items, indent): else: if 'type' in items: output_member(None, items, True, indent) + else: + output(indent + '- (any type)\n') def has_members(sub): """Does this sub have any properties to print?""" + if 'properties' not in sub: + return False + for p in list(sub['properties'].keys()): if len(sub['properties'][p]) == 0: continue @@ -248,10 +261,21 @@ def output_members(sub, indent=''): if 'oneOf' in sub: for oneOfItem in sub['oneOf']: - if 'type' in oneOfItem and oneOfItem['type'] == 'array': + if 'properties' not in oneOfItem and 'type' not in oneOfItem: + continue + + if oneOfItem.get('type') == 'array': output_array(oneOfItem, indent) + elif 'properties' in oneOfItem: + output_members(oneOfItem, indent) else: - output_member(None, oneOfItem, False, indent, False if 'enum' in oneOfItem else True) + output_member( + None, + oneOfItem, + False, + indent, + False if 'enum' in oneOfItem else True + ) # If we have multiple ifs, we have to wrap them in allOf. if 'allOf' in sub: @@ -323,76 +347,92 @@ def create_shell_command(rpc, example): output('```\n') -def generate_header(schema): +def generate_header(schema, name): """Generate lines for rpc title and synopsis with request parameters""" - output_title(esc_underscores(''.join([schema['rpc'], ' -- ', schema['title']])), '=', 0, 1) - output_title('SYNOPSIS') - # Add command level warning if exists - if 'warning' in schema: - output('**(WARNING: {})**\n\n'.format(esc_underscores(schema['warning']))) - # generate the rpc command details with request parameters - request = schema['request'] - properties = request['properties'] - toplevels = list(request['properties'].keys()) - output('{} '.format(fmt_propname(schema['rpc']))) - i = 0 - while i < len(toplevels): - # Skip hidden properties - if 'hidden' in properties[toplevels[i]] and properties[toplevels[i]]['hidden']: - i += 1 - continue - # Search for the parameter in 'dependentUpon' array - dependent_upon_obj = request['dependentUpon'] if 'dependentUpon' in request else [] - if toplevels[i] in dependent_upon_obj: - # Output parameters with appropriate separator - output('{}*{}* '.format('' if 'required' in request and toplevels[i] in request['required'] else '[', esc_underscores(toplevels[i]))) - output_conditional_params(dependent_upon_obj[toplevels[i]], 'dependentUpon') - toplevels = [key for key in toplevels if key not in dependent_upon_obj[toplevels[i]]] - output('{}'.format('' if 'required' in request and toplevels[i] in request['required'] else '] ')) - else: - # Search for the parameter in any conditional sub-arrays (oneOfMany, pairedWith) - condition, foundinsubarray = search_key_in_conditional_array(request, toplevels[i]) - # If param found in the conditional sub-array - if condition != '' and foundinsubarray is not None: + output_title(esc_underscores(''.join([name, ' -- ', schema['title']])), '=', 0, 1) + if schema.get('rpc'): + output_title('SYNOPSIS') + # Add command level warning if exists + if 'warning' in schema: + output('**(WARNING: {})**\n\n'.format(esc_underscores(schema['warning']))) + # generate the rpc command details with request parameters + request = schema.get('request', {}) + properties = request.get('properties', {}) + toplevels = list(properties.keys()) + output('{} '.format(fmt_propname(name))) + i = 0 + while i < len(toplevels): + # Skip hidden properties + if 'hidden' in properties[toplevels[i]] and properties[toplevels[i]]['hidden']: + i += 1 + continue + # Search for the parameter in 'dependentUpon' array + dependent_upon_obj = request['dependentUpon'] if 'dependentUpon' in request else [] + if toplevels[i] in dependent_upon_obj: # Output parameters with appropriate separator - output_conditional_params(foundinsubarray, condition) - # Remove found keys from toplevels array - toplevels = [key for key in toplevels if key not in foundinsubarray] - # Reset the cursor to the previous index - i = i - 1 + output('{}*{}* '.format('' if 'required' in request and toplevels[i] in request['required'] else '[', esc_underscores(toplevels[i]))) + output_conditional_params(dependent_upon_obj[toplevels[i]], 'dependentUpon') + toplevels = [key for key in toplevels if key not in dependent_upon_obj[toplevels[i]]] + output('{}'.format('' if 'required' in request and toplevels[i] in request['required'] else '] ')) else: - # Print the key as it is if it doesn't exist in conditional array - output('{}'.format(fmt_paramname(toplevels[i], False if 'required' in request and toplevels[i] in request['required'] else True))) - i += 1 - # plugin.json is an exception where all parameters cannot be printed deu to their dependency on different subcommands - # So, add ... at the end for plugin schema - if schema['rpc'] == 'plugin': - output('...') + # Search for the parameter in any conditional sub-arrays (oneOfMany, pairedWith) + condition, foundinsubarray = search_key_in_conditional_array(request, toplevels[i]) + # If param found in the conditional sub-array + if condition != '' and foundinsubarray is not None: + # Output parameters with appropriate separator + output_conditional_params(foundinsubarray, condition) + # Remove found keys from toplevels array + toplevels = [key for key in toplevels if key not in foundinsubarray] + # Reset the cursor to the previous index + i = i - 1 + else: + # Print the key as it is if it doesn't exist in conditional array + output('{}'.format(fmt_paramname(toplevels[i], False if 'required' in request and toplevels[i] in request['required'] else True))) + i += 1 + # plugin.json is an exception where all parameters cannot be printed deu to their dependency on different subcommands + # So, add ... at the end for plugin schema + if schema.get('rpc') == 'plugin': + output('...') output('\n') def generate_description(schema): """Generate rpc description with request parameter descriptions""" - request = schema['request'] + schema_type = get_schema_type(schema, True) + request = schema.get('request', {}) + properties = request.get('properties', {}) output_title('DESCRIPTION') # Add deprecated and removal information for the command if 'deprecated' in schema: - output('Command **deprecated in {}, removed after {}**.\n\n'.format(schema['deprecated'][0], schema['deprecated'][1] if len(schema['deprecated']) > 1 else deprecated_to_deleted(schema['deprecated'][0]))) + output('{} **deprecated in {}, removed after {}**.\n\n'.format(schema_type, schema['deprecated'][0], schema['deprecated'][1] if len(schema['deprecated']) > 1 else deprecated_to_deleted(schema['deprecated'][0]))) # Version when the command was added - if 'added' in schema: - output('Command *added* in {}.\n\n'.format(schema['added'])) + if 'added' in schema and schema['added'] != 'pre-v0.10.1': + output('{} *added* in {}.\n\n'.format(schema_type, schema['added'])) # Command's detailed description outputs(schema['description'], '\n') # Request parameter's detailed description - output('{}'.format('\n\n' if len(request['properties']) > 0 else '\n')) - output_members(request) + output('{}'.format('\n\n' if len(properties) > 0 else '\n')) + + if properties: + if schema.get('hook'): + output_title('HOOK PAYLOAD') + output_members(request) def generate_return_value(schema): """This is not general, but works for us""" - output_title('RETURN VALUE') - - response = schema['response'] + schema_type = get_schema_type(schema) + if schema.get('rpc'): + output_title('RETURN VALUE') + elif schema.get('notification'): + output_title('NOTIFICATION PAYLOAD') + elif schema.get('hook'): + output_title('HOOK RETURN') + + response = schema.get('response') + if response is None: + output(f'This {schema_type} does not have a response.\n\n') + return if 'pre_return_value_notes' in response: outputs(response['pre_return_value_notes'], '\n') @@ -416,20 +456,24 @@ def generate_return_value(schema): # Use pre/post_return_value_notes with empty properties when dynamic generation of the return value section is not required. # But to add a custom return value section instead. Example: `commando` commands. if "pre_return_value_notes" not in response and "post_return_value_notes" not in response: - output('On success, an empty object is returned.\n') + if schema.get('rpc'): + output('On success, an empty object is returned.\n') sub = schema elif len(toplevels) == 1 and props[toplevels[0]]['type'] == 'object': - output('On success, an object containing {} is returned. It is an object containing:\n\n'.format(fmt_propname(toplevels[0]))) + if schema.get('rpc'): + output('On success, an object containing {} is returned. It is an object containing:\n\n'.format(fmt_propname(toplevels[0]))) # Don't have a description field here, it's not used. assert 'description' not in toplevels[0] sub = props[toplevels[0]] elif len(toplevels) == 1 and props[toplevels[0]]['type'] == 'array' and props[toplevels[0]]['items']['type'] == 'object': - output('On success, an object containing {} is returned. It is an array of objects, where each object contains:\n\n'.format(fmt_propname(toplevels[0]))) + if schema.get('rpc'): + output('On success, an object containing {} is returned. It is an array of objects, where each object contains:\n\n'.format(fmt_propname(toplevels[0]))) # Don't have a description field here, it's not used. assert 'description' not in toplevels[0] sub = props[toplevels[0]]['items'] else: - output('On success, an object is returned, containing:\n\n') + if schema.get('rpc'): + output('On success, an object is returned, containing:\n\n') sub = response output_members(sub) @@ -463,7 +507,7 @@ def generate_body(schema): output('\n') -def generate_footer(schema): +def generate_footer(schema, name): """Output sections which should be printed after return value""" for key in FOOTER_KEY_SEQUENCE: if key not in schema: @@ -484,7 +528,7 @@ def generate_footer(schema): for i, example in enumerate(schema.get('examples', [])): output('\n{}**Example {}**: {}\n'.format('' if i == 0 else '\n', i + 1, '\n'.join(example.get('description', '')))) output('\nRequest:\n') - create_shell_command(schema['rpc'], example) + create_shell_command(name, example) output('```json\n') output(json.dumps(example['request'], indent=2).strip() + '\n') output('```\n') @@ -498,11 +542,28 @@ def generate_footer(schema): output('\n') +def get_schema_type(schema, capitalize=False): + if 'rpc' in schema: + result = 'command' + elif 'notification' in schema: + result = 'notification' + elif 'hook' in schema: + result = 'hook' + else: + raise ValueError('Unknown schema type') + + return result.capitalize() if capitalize else result + + def main(schemafile, markdownfile): with open(schemafile, 'r') as f: schema = json.load(f) + + name = schema.get('rpc') or schema.get('notification') or schema.get('hook') + if name is None: + name = os.path.basename(schemafile).replace('.json', '') # Outputs rpc title and synopsis with request parameters - generate_header(schema) + generate_header(schema, name) # Outputs command description with request parameter descriptions generate_description(schema) # Outputs other remaining sections before return value section @@ -510,7 +571,7 @@ def main(schemafile, markdownfile): # Outputs command response with response parameter descriptions generate_return_value(schema) # Outputs other remaining sections after return value section - generate_footer(schema) + generate_footer(schema, name) if markdownfile is None: return