《精通比特幣》英文版批註導讀第12章 區塊鏈應用(1)

as we saw in [transactions]. Just as the higher-level concepts of accounts, balances, and payments can be derived from these basic primitives, so can many other complex applications. Thus,, in conjunction with external data stores that associate the metadata to specific assets.1-of-N multisig

"type":"Other",

"divisibility":0,

"link_to_website":false,

"icon_url":,

"image_url":,

"version":"1.0"

}

Counterparty

Counterparty is a protocol layer builton top of bitcoin. The Counterparty protocol, similar to colored coins, offers the ability to create and trade virtual assets and tokens. In addition,Counterparty offers a decentralized exchange for assets.Counterparty is also implementing smart contracts, based on the Ethereum Virtual Machine (EVM).

對等方也是基於比特幣的協議層,提供資產的交換機制。採用了的以太坊的EVM,實現智能合約。對等方也同樣使用OP_RETURN操作碼,或者1-N簽名技術。

Like the colored coins protocols,Counterparty embeds metadata in bitcoin transactions,using the OP_RETURN opcode or 1-of-N multisignature addresses that encode metadata in the place of public keys. Using these mechanisms,Counterparty implements a protocol layer encoded in bitcoin transactions. The additional protocol layer can be interpreted by applications that are Counterparty-aware, such as wallets and blockchain explorers, or any application built using the Counterparty libraries.

Counterparty can be used as a platform for other applications and services, in turn. For example, Tokenly is a platform built on top of Counterparty that allows content creators, artists,and companies to issue tokens that express digital ownership and can be used torent, access, trade, or shop for content, products, and services. Other applications leveraging Counterparty include games (Spells of Genesis) and grid computing projects (Folding Coin).

More details about Counterparty can befound at https://counterparty.io. The open source project can be found at https://github.com/CounterpartyXCP.

Payment Channels and State Channels

Payment channelsare a trustless mechanism for exchanging bitcoin transactions between two parties,outside of the bitcoin blockchain. These transactions, which would be valid if settled on the bitcoin blockchain, are held off-chain instead, acting aspromissory notesfor eventual batch settlement. Because the transactions are not settled, they can be exchanged without the usual settlement latency, allowing extremely high transaction throughput, low (submillisecond) latency, and fine(satoshi-level) granularity.

Actually, the term channelis a metaphor.State channels are virtual constructs represented by the exchange of state between two parties, outside of the blockchain.There are no "channels" per se and the underlying data transport mechanism is not the channel. We use the term channel to represent the relationship and shared state between two parties, outside of the blockchain.

狀態管道是一種隱喻,是虛擬構建,由雙方在區塊鏈之外交換狀態。

To further explain this concept, think of a TCP stream. From the perspective of higher-level protocols it is a"socket" connecting two applications across the internet. But if you look at the network traffic, a TCP stream is just a virtual channel over IP packets. Each endpoint of the TCP stream sequences and assembles IP packets to create the illusion of a stream of bytes. Underneath, it’s all disconnected packets. Similarly, a payment channel is just a series of transactions. If properly sequenced and connected, they create redeemable obligations that you can trust even though you don’t trust the other side of the channel.

In this section we will look at various forms of payment channels. First, we will examine the mechanisms used to construct a one-way (unidirectional) payment channel for a metered micropaymentservice, such as streaming video. Then, we will expand on this mechanism and introduce bidirectional payment channels. Finally, we will look at how bidirectional channels can be connected end-to-end to form multihop channels in a routed network, first proposed under the name Lightning Network.

Payment channels are part of the broader concept of a state channel, which represents an off-chain alteration of state, secured by eventual settlement ina blockchain.A payment channel is a state channel where the state being altered is the balance of a virtual currency.

支付管道是更廣義的狀態管道,用於表徵區塊鏈狀態的改變,用區塊鏈的最終結算來確保安全。

State Channels—Basic Concepts and Terminology

A state channel is established between two parties,through a transaction thatlocks a shared state on the blockchain.This is called thefunding transactionoranchor transaction. This single transaction must be transmitted to the network and mined to establish the channel. In the example of a payment channel, the locked state is the initial balance (incurrency) of the channel.一個狀態管道在兩方建立,需要通過一筆交易鎖定雙方的共同狀態。在整個交易狀態中,最後只需要向區塊鏈提交兩筆交易,支付交易和清算交易。這個技術相當於,利用區塊鏈的交易,構建了一個虛擬的對話層,在這個對話層上面,交易可以先不用在區塊鏈上最終確認,但是到最後結束的時候,只要把清算清楚的交易,最終上鍊即可。

The two parties then exchange signed transactions, called commitment transactions

, that alter the initial state. These transactions are valid transactions in that theycouldbe submitted for settlement by either party, but instead are held off-chain byeach party pending the channel closure. State updates can be created as fast as each party can create, sign, and transmit a transaction to the other party. In practice this means that thousands of transactions per second can be exchanged.

When exchanging commitment transactions the two parties also invalidate the previous states, so that the most up-to-date commitment transaction is always the only one that can be redeemed. This prevents either party from cheating by unilaterally closing the channel with an expired prior state that is more favorable to them than the current state. We will examine the various mechanisms that can be used to invalidate prior state in the rest of this chapter.

Finally, the channel can be closed either cooperatively, by submitting a final settlement transactionto the blockchain, or unilaterally, by either party submitting the last commitment transaction to the blockchain. A unilateral close option is needed in case one of the parties unexpectedly disconnects. The settlement transaction represents the final state of the channel and is settled on the blockchain.

In the entire lifetime of the channel, only two transactions need to be submitted for mining on the blockchain: the funding and settlement transactions.In between these two states, the two parties can exchange any number of commitment transactions that are never seen by anyone else, nor submitted to the block chain.

A payment channel between Bob and Alice, showing the funding, commitment, and settlement transactions illustrates a payment channel between Bob and Alice, showing the funding, commitment, and settlement transactions.

《精通比特币》英文版批注导读第12章 区块链应用(1)

Figure 4. A payment channel between Bob and Alice, showing the funding, commitment, and settlement transactions

Simple Payment Channel Example

To explain state channels, we start with a very simple example. We demonstrate a one-way channel, meaning that value is flowing in one direction only. We will also start with the naive assumption that no one is trying to cheat, to keep things simple. Once we have the basic channel idea explained, we will then look at what it takes to make it trustless so that neither party cancheat, even if they are trying to.

For this example we will assume two participants: Emma and Fabian. Fabian offers a video streaming service that is billed by the second using a micropayment channel. Fabian charges 0.01 millibit(0.00001 BTC) per second of video, equivalent to 36 millibits (0.036 BTC) per hour of video. Emma is a user who purchases this streaming video service from Fabian. Emma purchases streaming video from Fabian with a payment channel, paying for each second of video shows Emma buying the video streaming service from Fabian using a payment channel.

《精通比特币》英文版批注导读第12章 区块链应用(1)

Figure 5. Emma purchases streaming video from Fabian with a payment channel, paying for each second of video

In this example, Fabian and Emma are using special software that handles both the payment channel and the video streaming. Emma is running the software in her browser, Fabian is running it on a server. The software includes basic bitcoin wallet functionality and can create and sign bitcoin transactions. Both the concept and the term "payment channel" are completely hidden from the users.What they see is video that is paid for by the second.

視頻按秒結算,一旦支付交易確認,就可以開始傳送媒體流。

To set up the payment channel, Emma and Fabian establish a 2-of-2 multisignature address, with each of them holding one of the keys. From Emma’s perspective, the software in her browser presents a QRcode with a P2SH address (starting with "3"), and asks her to submita "deposit" for up to 1 hour of video. The address is then funded by Emma. Emma’s transaction, paying to the multisignature address, is the funding or anchor transaction for the payment channel.

For this example, let’s say that Emma funds the channel with 36 millibits (0.036 BTC). This will allow Emma to consume up to1 hour of streaming video. The funding transaction in this case sets the maximum amount that can be transmitted in this channel, setting thechannel capacity.

The funding transaction consumes one or more inputs from Emma’s wallet, sourcing the funds. It creates one output with a value of 36 millibits paid to the multisignature 2-of-2 address controlled jointly between Emma and Fabian. It may have additional outputs for change back to Emma’s wallet.

Once the funding transaction is confirmed, Emma can start streaming video.Emma’s software creates and signs a commitment transaction that changes the channel balance tocredit 0.01 millibit to Fabian’s address and refund 35.99 millibits back to Emma. The transaction signed by Emma consumes the 36 millibits output created by the funding transaction and creates two outputs: one for her refund, the other for Fabian’s payment. The transaction is only partially signed—it requires two signatures (2-of-2), but only has Emma’s signature. When Fabian’s server receives this transaction, it adds the second signature (for the 2-of-2 input) and returns it to Emma together with 1 second worth of video. Now both parties have a fully signed commitment transaction that either can redeem, representing the correct up-to-date balance of the channel. Neither party broadcasts this transaction to the network.

在這裡雙方是通過一手交錢一手交貨的方式,完成流媒體的付費直播。

In the next round, Emma’s software creates and signs another commitment transaction (commitment #2) that consumes the same2-of-2 output from the funding transaction. The second commitment transaction allocates one output of 0.02 millibits to Fabian’s address and one output of 35.98 millibits back to Emma’s address. This new transaction is payment for two cumulative seconds of video. Fabian’s software signs and returns the second commitment transaction, together with another second of video.

In this way, Emma’s software continues to send commitment transactions to Fabian’s server in exchange for streaming video. The balance of the channel gradually accumulates in favor of Fabian, as Emma consumes more seconds of video. Let’s say Emma watches 600 seconds (10minutes) of video, creating and signing 600 commitment transactions. The last commitment transaction (#600) will have two outputs, splitting the balance of the channel, 6 millibits to Fabian and 30 millibits to Emma.

Finally, Emma clicks "Stop" to stop streaming video. Either Fabian or Emma can now transmit the final state transaction for settlement. This last transaction is the settlement transactionand pays Fabian for all the video Emma consumed, refunding the remainder of the funding transaction to Emma.

Emma’s payment channel with Fabian, showing the commitment transactions that update the balance of the channel shows the channel between Emma and Fabian and the commitment transactions that update the balance of the channel.

In the end, only two transactions are recorded on the blockchain: the funding transaction that established the channel and a settlement transaction that allocated the finalbalance correctly between the two participants.

最後只有兩筆交易需要上鍊,第一筆支付的,和最後一筆結算的。這個模式有點像你和一家打印店簽了合約,以後你公司的員工去打印,只需要籤個字,你定期結算就好。於是平時每一次業務,就不需要走完整的支付流程,需要確認的就是在第一筆和最後一筆,完成此次整體交易的流程。

《精通比特币》英文版批注导读第12章 区块链应用(1)

Figure 6. Emma’spayment channel with Fabian, showing the commitment transactions that updatethe balance of the channel

《精通比特币》英文版批注导读第12章 区块链应用(1)
《精通比特币》英文版批注导读第12章 区块链应用(1)

持 續 力

★★★★★

ScalersTalk成長會是由Scalers發起的社群生態體系,專注1000天以上的“N階持續行動理論體系與能力構建”,以“從英語初階到同聲傳譯全棧解決方案”為特色,以“持續輸入輸出訓練實踐拓寬認知邊界”為導向。

新 浪 微 博 l

@Scalers

網 站 l ScalersTalk.com

開 放 社 群 l 100小時訓練QQ群 456036104

暢 銷 書 籍 l 《刻意學習》火熱銷售中

★★★★★

2018年成長會申請說明

本文原文:http://www.scalerstalk.com/1365-MasterBTC12


分享到:


相關文章: