Wikipedia, die freie Enzyklopädie

BIP 199 HTLC initial stack state

Hey fellow bitcoiners and redditors

I'm trying to understand how HTLCs (Hashed Time-Locked Contracts) can be implemented in Bitcoin and BIP-199 turned out to be the best resource for that purpose.

Question answered!
  1. Does the stack need to feature the secret/image twice in the OP_IF case? => call the script with [pubKey, signature, 1]
  2. How can the OP_ELSE flow ever be executed successfully (since this requires the stack to be empty, but [pubKey, signature] are required for OP_CHECKSIG at the very end of the script )? => call the script with [pubKey, signature, 0]

Full story
This is the example HTLC script I copied from BIP-199:

IF-Case (seller can claim the buyers deposited BTCs)
TL;DR: detailed debug log of this path. Question: Can I avoid providing the preimage twice?

Before running this script, the preimage should be known and the stack should looks:

  • So since the stack is not empty, it will jump into the OP_IF clause.
    • the OP_IF will pop the top value => stack is now: [preimage, pubKey, signature]
  • [HASHOP] will hash the preimage
    • the preimage on the stack will, be replaced by the image => stack: [image, pubKey, signature]
  • digest (a synonym for image) will be pushed
    • => stack: [image, image pubKey, signature]
  • OP_EQUALVERIFY checks the two top items for equality: image == image => true
    • ...and removes them, if they are equal => stack: [pubKey, signature]
  • OP_DUP will duplicate the pubKey, => stack: [pubKey, pubKey, signature]
  • OP_HASH160 will double-hash the pubKey => stack: [p2pkhAddress, pubKey, signature]
  • represents the p2pkhAddress => stack: [p2pkhAddress, p2pkhAddress, pubKey, signature]
  • OP_EQUALVERIFY checks the two top items for equality: p2pkhAddress == p2pkhAddress => true
    • ...and removes them, if they are equal => stack: [pubKey, signature]
  • OP_CHECKSIG checks the signature
  • Done, all fine!
  • Question: This flow requires the secret to be on the stack twice before starting the script; Can I avoid that somehow?

ELSE-Case (buyer claims refund of his/her deposited BTCs)
Since the script runs an OP_CHECKSIG at the very end. This means the stack has to contain at least [pubKey, signature] before the execution pointer moves to OP_IF. However, OP_IF returns true "If the top stack value is not False". So how can the script possibly ever execute the OP_ELSE flow?

  • My mother tongue is not English, please forgive me any mistakes. :)
  • I'm just getting started with BTC scripting, please forgive me any noob mistakes.
  • I also searched the whole stackexchange/search engine/reddit/github universum for this issue, obivously without success.
PS - buy Bitcoin :)
submitted by redditeraya to Bitcoin [link] [comments]

Payjoin/P2EP - Uma nova era de Privacidade no Bitcoin The Best Shower Bluetooth Speaker - Unboxing & Review YouTube Delmenews - YouTube Chris Chan  Keep Sonic Original  BasedShaman Review guarantees daily payouts and no additional fees except the maintenance fee. The user is required to make a one-time payment that implies a 2-year contract. The company accepts credit cards, wire transfer and Bitcoin payments via Bitpay, BIPS and Coinbase. has an on-going discount system. In addition according to the company’s promotional scheme, the users can receive a ... I believe that most of us that own a bong could never stand our bong getting all those black or brown or tar-like goo stuck on the inside, another article on Puffing Bird Wiki had mentioned some formulas for cleaning your bong. Water bongs have percolators. Percolators help to sufficiently mix the smoke and the water so you can get a smooth hit. But except for beaker bongs, percolator bongs ... HeadShop Wiki RSS. Ash Catcher, Bong Bowl, Downstems, Glass Dropdown - June 9, 2020. Top 4 Bong Accessories You Need. When it comes to smoking dry herb, there is nothing that could compare to a good old bong rip! Although the dabbing game is catching on fast, the stoner community gradually adapted the dab rigs and quartz bangers and such to dab concentrate like wax, resin shatter, and more ... Morgan Stanley Investment Management's chief strategist and head of emerging markets has recommended bitcoin as an alternative investment to stocks amid central banks' massive money printing policies. Wikimedia Deutschland e. V. Über uns. Stellenangebote. Impressum & Kontakt. Mitwirken. Mitglied werden. Jetzt spenden. Mittelverwendung. Vereinskanäle. Unser Blog

[index] [4390] [48600] [5220] [11521] [31568] [41294] [38110] [16380] [4876] [35858]

Payjoin/P2EP - Uma nova era de Privacidade no Bitcoin

Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube. Chris Chan Keep Sonic Original BasedShaman Review - Chris Chan was a huge Sonic the Hedgehog fan and didn't want Sonic's arms to be changed in the Sonic Boom video game. This showed that Chris ... Shower Speaker: UK Shoppers: Filmed On Canon 60D: Lights Behind Me On TV: Entenda como funciona o Payjoin/P2EP, a forma de quebrar as heurísticas de análise da blockchain de maneira simples, fácil e econômica. Veja também como você... ist das lokale Nachrichtenportal für die Stadt Delmenhorst bei Bremen. Jeden Tag gibt es aktuelle Meldungen aus der kreisfreien Stadt. Der Delme...