闪电网络
闪电网络,即Lightning Network,是工作在区块链上(主要面向比特币)的第二层支付协议。其设计目的是实现交易双方的即时交易,闪电网络的主要思路——将大量交易放到比特币区块链之外进行,只把关键环节放到链上进行确认。该设计最早于 2015 年 2 月在论文《The Bitcoin Lightning Network: Scalable Off-Chain Instant Payments》中提出。闪电网络主要通过引入智能合约的思想来完善链下的交易渠道。核心的概念主要有两个:RSMC(Recoverable Sequence Maturity Contract)和 HTLC(Hashed Timelock Contract)。前者解决了链下交易的确认问题,后者解决了支付通道的问题。
RSMC,Recoverable Sequence Maturity Contract,即“可撤销的顺序成熟度合同”。主要原理类似资金池机制。首先假定交易双方之间存在一个“微支付通道”(资金池)。交易双方先预存一部分资金到“微支付通道”里,初始情况下双方的分配方案等于预存的金额。每次发生交易,需要对交易后产生资金分配结果共同进行确认,同时签字把旧版本的分配方案作废掉。任何一方需要提现时,可以将他手里双方签署过的交易结果写到区块链网络中,从而被确认。从这个过程中可以可以看到,只有在提现时候才需要通过区块链。
HTLC,微支付通道是通过 Hashed Timelock Contract 来实现的,中文意思是“哈希的带时钟的合约”。这个其实就是限时转账。理解起来也很简单,通过智能合约,双方约定转账方先冻结一笔钱,并提供一个哈希值,如果在一定时间内有人能提出一个字符串,使得它哈希后的值跟已知值匹配(实际上意味着转账方授权了接收方来提现),则这笔钱转给接收方。
RSMC 保障了两个人之间的直接交易可以在链下完成,HTLC 保障了任意两个人之间的转账都可以通过一条“支付”通道来完成。闪电网络整合这两种机制,就可以实现任意两个人之间的交易都在链下完成了。
在整个交易中,智能合约起到了中介的重要角色,而区块链网络则确保最终的交易结果被确认。
© 2024 OKX. This article may be reproduced or distributed in its entirety, or excerpts of 100 words or less of this article may be used, provided such use is non-commercial. Any reproduction or distribution of the entire article must also prominently state: “This article is © 2024 OKX and is used with permission.” Permitted excerpts must cite to the name of the article and include attribution, for example “Article Name, [author name if applicable], © 2024 OKX.” No derivative works or other uses of this article are permitted.
Information about: digital currency exchange services is prepared by OKX Australia Pty Ltd (ABN 22 636 269 040); derivatives and margin by OKX Australia Financial Pty Ltd (ABN 14 145 724 509, AFSL 379035) and is only intended for wholesale clients (within the meaning of the Corporations Act 2001 (Cth)); and other products and services by the relevant OKX entities which offer them (see Terms of Service). Information is general in nature and should not be taken as investment advice, personal recommendation or an offer of (or solicitation to) buy any crypto or related products. You should do your own research and obtain professional advice, including to ensure you understand the risks associated with these products, before you make a decision about them. Past performance is not indicative of future performance - never risk more than you are prepared to lose. Read our Terms of ServiceTerms of Serviceand Risk Disclosure Statement for more information.