Access blockchain data from Bitcoin smart contracts: Part 5

This post was first published on Medium.

Building upon the foundation laid out in previous parts of the series, we have demonstrated how to implement relative locktime in Bitcoin, without new opcode OP_CheckSequenceVerify.

Timelock

A timelock restricts the spending of some bitcoins until a specified future time or block height. There are two types of timelocks:

  1. Absolute: for example, one can provably lock up 1,100,000 bitcoins until block height 800,000, or until January 1st, 2025.
  2. Relative: for example, one can lock up 21 bitcoins that can only be spent after 100 blocks or 3 days.

To enable absolute and relative timelocks, new opcodes OP_CheckLockTimeVerify/OP_CLTV and OP_CheckSequenceVerify/OP_CSV were introduced in BIP65 and BIP68/112/113, respectively.

Relative locktime without OP_CSV

Restoring the original Bitcoin protocol, Bitcoin SV has reverted the aforementioned changes. It turns out OP_CSV can be implemented with the original protocol.

a screenshot of a flow diagram of Timelocked TX
Relative Transaction Timelocks

In Part 1, we have shown how to access the block containing a given contract UTXO. Combining this block header with the specified relative timelock, we can know the earliest block that the UTXO can be spent. We demand any block after the deadline to be available for unlocking the UTXO, essentially placing a relative timelock on it as OP_CSV does. The full code is listed below.

a screenshot of csv code
CheckSequenceVerify Contact

Line 11 shows unlocking based on unix time (e.g., in seconds). validateHelper() function at Line 33 verifies both the block containing the UTXO and a latest block are valid (Line 41–42). It also verifies the former block actually contains the UTXO (Line 34–38) using the same technique as in Part 1. Line 15 ensures required time has elapsed since the UTXO is mined.

Line 19 shows unlocking based on block height (e.g., number of blocks). Line 24–25 get heights of the two blocks as in Part 3. Line 27 checks specified number of blocks have been mined after the UTXO.

Summary

Besides OP_CSV, we have previously implemented OP_CLTV without any change to the original Bitcoin protocol. There are two implications:

  1. Both opcodes are not necessary to enabled UTXO-level timelocks, as previously thought.
  2. All use cases enabled by OP_CSV/CLTV, such as lightning networks, sidechains, and CLTV-style payment channels, can be directly built on the original Bitcoin, if desired.

Watch: CoinGeek New York panel, Bitcoin & Blockchain – Can Real Value Come from Real Utility?

New to Bitcoin? Check out CoinGeek’s Bitcoin for Beginners section, the ultimate resource guide to learn more about Bitcoin—as originally envisioned by Satoshi Nakamoto—and blockchain.

Note: This article have been indexed to our site. We do not claim legitimacy, ownership or copyright of any of the content above. To see the article at original source Click Here

Related Posts
Argentina Unemployment Rate (QoQ)	: 5.7% (3Q) vs previous 6.2% thumbnail

Argentina Unemployment Rate (QoQ) : 5.7% (3Q) vs previous 6.2%

Information on these pages contains forward-looking statements that involve risks and uncertainties. Markets and instruments profiled on this page are for informational purposes only and should not in any way come across as a recommendation to buy or sell in these assets. You should do your own thorough research before making any investment decisions. FXStreet
Read More

Parking on the sidewalk: Regardless

zeit.de mit Werbung Um der Nutzung mit Werbung zuzustimmen, muss JavaScript in Ihrem Browser aktiviert sein. zeit.de mit Werbung Besuchen Sie zeit.de wie gewohnt mit Werbung und Tracking. Details zum Tracking finden Sie in der Datenschutzerklärung und im Privacy Center. zeit.de Pur Nutzen Sie zeit.de mit weniger Werbung und ohne Werbetracking für 1,20 €/Woche (für…
Read More
Bitwise launching spot bitcoin ETF (BITB) thumbnail

Bitwise launching spot bitcoin ETF (BITB)

Bitwise Asset Management, the largest crypto index fund manager in America, announced today that the Bitwise Bitcoin ETF (BITB), the firm’s first spot bitcoin ETF, intends to begin trading today, January 11th. BITB will join Bitwise’s comprehensive suite of 18 crypto investment products, which currently includes five other crypto ETFs. “We expect significant demand for
Read More
AFR Android app: Download new app with additional features thumbnail

AFR Android app: Download new app with additional features

Apr 3, 2023 – 5.00amThe Australian Financial Review is making it easier for subscribers to stay up to date with all the news that matters with the launch of a new Android app for smartphones and tablets.The new app will give readers better access to the country’s best coverage of business, markets, politics and beyond
Read More
Vaccines, Hope: the third dose will be extended to other sections of the population, let's follow science thumbnail

Vaccines, Hope: the third dose will be extended to other sections of the population, let's follow science

(Teleborsa) – Il ministro della Salute, Roberto Speranza, ha dichiarato che la terza dose sarà allargata anche ad altre fasce della popolazione sulla base delle indicazioni della comunità scientifica. “La terza dose, dopo le categorie già indicate (ultraottantenni, personale Rsa, operatori sanitari) sarà allargata anche ad altri ambiti ma ci guiderà la comunità scientifica e…
Read More
Taylor Wimpey operating profit set to halve thumbnail

Taylor Wimpey operating profit set to halve

Taylor Wimpey expects to post an operating profit of about £470m this year, despite the slowdown in the housing market. A trading update from the company said its profit would be at the higher end of its previously predicted range, which it attributed to close cost control, including through “highly selective” land buying. The figure
Read More
Index Of News
Consider making some contribution to keep us going. We are donation based team who works to bring the best content to the readers. Every donation matters.
Donate Now

Subscription Form

Liking our Index Of News so far? Would you like to subscribe to receive news updates daily?

Total
0
Share