lnbook-cn
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Ch6 闪电网络架构 在本书的第一部分,我们介绍了闪电网络的主要概念,详细地阐述了一个支付路由的综合示例并设置了我们可以用来进一步探索的工具。在本书的第二部分,我们将更加深入地探讨闪电网络的技术细节,刨析每个构建块。 在本节中,我们将更详细地概述闪电网络的组件,并提供一个“大局观”视角,以指导您阅读接下来的章节。 ## 闪电网络协议套件 闪电网络由一系列运行在互联网之上的复杂协议组成。我们可以广义地将这些协议分类为五个不同的层,它们构成了一个协议栈,其中每一层都建立在并使用下面一层的协议。此外,每个协议层抽象了底层,并“隐藏”了一些复杂性。 闪电网络协议套件中显示的架构图提供了这些层及其组件协议的概述。 ![图1. 闪电网络协议套件](https://raw.githubusercontent.com/lnbook/lnbook/develop/images/mtln_0601.png) 闪电网络的五个层,从下到上依次是: ### 网络连接层 包含直接与互联网核心协议(TCP/IP)、覆盖协议(Tor v2/v3)和互联网服务(DNS)交互的协议。此层还包含用于保护闪电消息的加密传输协议。 ### 消息传递层 包含节点用于协商功能、格式化消息和编码消息字段的协议。 ### 点对点(P2P)层 这是节点之间通信的主要协议层,包含节点之间交换的所有不同消息。 ### 路由层 包含用于在节点之间进行端到端和原子化支付路由的协议。这一层包含了闪电网络的核心功能:路由支付。 ### 支付层 网络的最高层,为应用程序提供可靠的支付接口。 ## 闪电网络详解 在接下来的10章中,我们将逐步解析协议套件并详细讨论闪电网络的每个组成部分。 我们花费了相当长的时间来决定呈现这些细节的最佳顺序。这并不容易,因为不同组件之间存在着如此多的相互依存关系:当你开始解释其中之一时,你会发现它会涉及到其他许多组件。我们最终选择了一条更为曲折的路径,从独特于闪电网络的最基本构建块-支付通道开始,并从那里向外扩展。但由于这条路径并不明显,我们将使用闪电协议套件作为地图。在每个章节中,我们将专注于一个或多个相关组件,并在协议套件中突出显示它们。有点像地图上的标记,告诉你“你在这里!” 以下是我们将要涵盖的内容: ### #支付通道 在本章中,我们将比之前的章节更深入地了解支付通道的工作原理。我们将详细研究资金和提交交易的结构和比特币脚本,以及节点在协议中协商每个步骤的过程。 ### #路由 接下来,我们将在网络中连接多个支付通道,并将支付从一个端点路由到另一个端点。在此过程中,我们将深入了解哈希时间锁合约(HTLC)智能合约和我们用于构建它的比特币脚本。 ### #通道操作 将简单支付通道的概念和使用HTLC进行路由支付结合起来,我们将会研究HTLC如何成为每个通道提交交易的一部分。我们还将研究添加、结算、失败以及从提交中移除HTLC的协议。 ### #洋葱路由 接下来,我们将研究HTLC信息如何在洋葱路由协议内在网络中传播。我们将研究分层加密和解密机制,这使得闪电网络具有一些隐私特征。 ### #对话协议 在这一章中,我们将探讨闪电网络节点如何相互发现并了解已公布通道的信息,以构建一个通道图,从而可以在网络中查找路径。 #### >#路径搜索 接下来,我们将了解每个节点如何利用对话协议中的信息来构建整个网络的“地图”,以便在网络中查找从一个点到另一个点的路径从而进行路由支付。我们还将介绍路径搜索中的创新,例如多部分支付。 ### wire-protocal 闪电网络的基础是节点之间用于交换有关网络和通道的消息的点对点协议。在本章中,我们将了解这些消息是如何构造的,并介绍通过功能位和类型-长度-值(TLV)编码在消息中构建的扩展功能。 ### #加密消息传输 向网络的较低级别移动,我们将查看确保节点之间所有通信的机密性和完整性的基础加密传输系统。 ### #发票 闪电网络的一个关键部分是付款请求,也称为闪电发票。在本章中,我们将剖析发票的结构和编码。 咱们开始吧!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully