Scripts
Created by PM on 02/12/2016.
Functions
This function interprets the locktime for the given transaction, and returns the block height before which this tx cannot be published. By convention in bitcoin, depending of the value of locktime it might be a number of blocks or a number of seconds since epoch. This function does not support the case when the locktime is a number of seconds that is not way in the past. NB: We use this property in lightning to store data in this field.
minimal encoding of a number into a script element:
Extract the payment hash from a timed-out received htlc.
Extract the payment hash from a 2nd-stage HTLC Timeout transaction's witness script
Extract the payment preimage from from a fulfilled offered htlc.
Extract the payment preimage from a 2nd-stage HTLC Success transaction's witness script
If remote publishes its commit tx where there was a remote->local htlc, then local uses this script to claim its funds using a payment preimage (consumes htlcOffered script from commit tx)
If remote publishes its commit tx where there was a local->remote htlc, then local uses this script to claim its funds after timeout (consumes htlcReceived script from commit tx)
This is the witness script of the 2nd-stage HTLC Success transaction (consumes htlcOffered script from commit tx) local signature is created with SIGHASH_ALL flag remote signature is created with SIGHASH_SINGLE || SIGHASH_ANYONECANPAY
This is the witness script of the 2nd-stage HTLC Timeout transaction (consumes htlcOffered script from commit tx) local signature is created with SIGHASH_ALL remote signature is created with SIGHASH_SINGLE || SIGHASH_ANYONECANPAY
This witness script spends (steals) a [htlcOffered] or [htlcReceived] output using a revocation key as a punishment for having published a revoked transaction
This witness script spends a [toLocalDelayed] output using a local sig after a delay
This witness script spends (steals) a [toLocalDelayed] output using a revocation key as a punishment for having published a revoked transaction
This witness script spends a [toLocalDelayed] output using a local sig after a delay