Scripts

object Scripts
class Object
trait Matchable
class Any
Scripts.type

Value members

Concrete methods

def anchor(fundingPubkey: PublicKey): Seq[ScriptElt]

Each participant has its own anchor output that locks to their funding key. This allows using CPFP carve-out (see https://github.com/bitcoin/bitcoin/pull/15681) to speed up confirmation of a commitment transaction.

Each participant has its own anchor output that locks to their funding key. This allows using CPFP carve-out (see https://github.com/bitcoin/bitcoin/pull/15681) to speed up confirmation of a commitment transaction.

Source:
Scripts.scala

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.

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.

Returns:

the block height before which this tx cannot be published.

Source:
Scripts.scala
Returns:

the number of confirmations of each parent before which the given transaction can be published.

Source:
Scripts.scala
def der(sig: ByteVector64, sighashType: Int): ByteVector

Convert a raw ECDSA signature (r,s) to a der-encoded signature that can be used in bitcoin scripts.

Convert a raw ECDSA signature (r,s) to a der-encoded signature that can be used in bitcoin scripts.

Value parameters:
sig

raw ECDSA signature (r,s)

sighashType

sighash flags

Source:
Scripts.scala

minimal encoding of a number into a script element:

minimal encoding of a number into a script element:

  • OP_0 to OP_16 if 0 <= n <= 16
  • OP_PUSHDATA(encodeNumber(n)) otherwise
Value parameters:
n

input number

Returns:

a script element that represents n

Source:
Scripts.scala

Extract the payment hash from a timed-out received htlc.

Extract the payment hash from a timed-out received htlc.

Source:
Scripts.scala

Extract the payment hash from a 2nd-stage HTLC Timeout transaction's witness script

Extract the payment hash from a 2nd-stage HTLC Timeout transaction's witness script

Source:
Scripts.scala

Extract the payment preimage from from a fulfilled offered htlc.

Extract the payment preimage from from a fulfilled offered htlc.

Source:
Scripts.scala

Extract the payment preimage from a 2nd-stage HTLC Success transaction's witness script

Extract the payment preimage from a 2nd-stage HTLC Success transaction's witness script

Source:
Scripts.scala
def htlcOffered(localHtlcPubkey: PublicKey, remoteHtlcPubkey: PublicKey, revocationPubKey: PublicKey, paymentHash: ByteVector, commitmentFormat: CommitmentFormat): Seq[ScriptElt]
def htlcReceived(localHtlcPubkey: PublicKey, remoteHtlcPubkey: PublicKey, revocationPubKey: PublicKey, paymentHash: ByteVector, lockTime: CltvExpiry, commitmentFormat: CommitmentFormat): Seq[ScriptElt]
def multiSig2of2(pubkey1: PublicKey, pubkey2: PublicKey): Seq[ScriptElt]
def toLocalDelayed(revocationPubkey: PublicKey, toSelfDelay: CltvExpiryDelta, localDelayedPaymentPubkey: PublicKey): Seq[ScriptElt]
def toRemoteDelayed(remotePaymentPubkey: PublicKey): Seq[ScriptElt]

With the anchor outputs format, the to_remote output is delayed with a CSV 1 to allow CPFP carve-out on anchors.

With the anchor outputs format, the to_remote output is delayed with a CSV 1 to allow CPFP carve-out on anchors.

Source:
Scripts.scala
def witness2of2(sig1: ByteVector64, sig2: ByteVector64, pubkey1: PublicKey, pubkey2: PublicKey): ScriptWitness
Returns:

a script witness that matches the msig 2-of-2 pubkey script for pubkey1 and pubkey2

Source:
Scripts.scala
def witnessAnchor(localSig: ByteVector64, anchorScript: ByteVector): ScriptWitness

This witness script spends a local anchor output using a local sig.

This witness script spends a local anchor output using a local sig.

Source:
Scripts.scala

This witness script spends either a local or remote anchor output after its CSV delay.

This witness script spends either a local or remote anchor output after its CSV delay.

Source:
Scripts.scala

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 remote->local htlc, then local uses this script to claim its funds using a payment preimage (consumes htlcOffered script from commit tx)

Source:
Scripts.scala

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)

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)

Source:
Scripts.scala

If remote publishes its commit tx where there was a to_remote delayed output (anchor outputs format), then local uses this script to claim its funds (consumes to_remote script from commit tx).

If remote publishes its commit tx where there was a to_remote delayed output (anchor outputs format), then local uses this script to claim its funds (consumes to_remote script from commit tx).

Source:
Scripts.scala
def witnessHtlcSuccess(localSig: ByteVector64, remoteSig: ByteVector64, paymentPreimage: ByteVector32, htlcOfferedScript: ByteVector, commitmentFormat: CommitmentFormat): ScriptWitness

This is the witness script of the 2nd-stage HTLC Success transaction (consumes htlcOffered script from commit tx)

This is the witness script of the 2nd-stage HTLC Success transaction (consumes htlcOffered script from commit tx)

Source:
Scripts.scala
def witnessHtlcTimeout(localSig: ByteVector64, remoteSig: ByteVector64, htlcOfferedScript: ByteVector, commitmentFormat: CommitmentFormat): ScriptWitness

This is the witness script of the 2nd-stage HTLC Timeout transaction (consumes htlcOffered script from commit tx)

This is the witness script of the 2nd-stage HTLC Timeout transaction (consumes htlcOffered script from commit tx)

Source:
Scripts.scala
def witnessHtlcWithRevocationSig(revocationSig: ByteVector64, revocationPubkey: PublicKey, htlcScript: ByteVector): ScriptWitness

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 (steals) a htlcOffered or htlcReceived output using a revocation key as a punishment for having published a revoked transaction

Source:
Scripts.scala

This witness script spends a toLocalDelayed output using a local sig after a delay

This witness script spends a toLocalDelayed output using a local sig after a delay

Source:
Scripts.scala

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 (steals) a toLocalDelayed output using a revocation key as a punishment for having published a revoked transaction

Source:
Scripts.scala