scoin.ln

package scoin.ln

Types, utils and wire codecs related to the BOLT specification (the Lightning Network).

Type members

Classlikes

case class AcceptChannel(temporaryChannelId: ByteVector32, dustLimitSatoshis: Satoshi, maxHtlcValueInFlightMsat: UInt64, channelReserveSatoshis: Satoshi, htlcMinimumMsat: MilliSatoshi, minimumDepth: Long, toSelfDelay: CltvExpiryDelta, maxAcceptedHtlcs: Int, fundingPubkey: PublicKey, revocationBasepoint: PublicKey, paymentBasepoint: PublicKey, delayedPaymentBasepoint: PublicKey, htlcBasepoint: PublicKey, firstPerCommitmentPoint: PublicKey, tlvStream: TlvStream[AcceptChannelTlv]) extends ChannelMessage with HasTemporaryChannelId
sealed trait AcceptChannelTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class AmountBelowMinimum(amount: MilliSatoshi, update: ChannelUpdate) extends Update
case class AnnouncementSignatures(channelId: ByteVector32, shortChannelId: ShortChannelId, nodeSignature: ByteVector64, bitcoinSignature: ByteVector64, tlvStream: TlvStream[AnnouncementSignaturesTlv]) extends RoutingMessage with HasChannelId
sealed trait AnnouncementSignaturesTlv extends Tlv
Companion:
object
Source:
Tlv.scala
sealed trait BadOnion extends FailureMessage
case class Bolt11Invoice(prefix: String, amountOpt: Option[MilliSatoshi], createdAt: TimestampSecond, nodeId: PublicKey, tags: List[TaggedField], signature: ByteVector)

Lightning Bolt 11 invoice see https://github.com/lightning/bolts/blob/master/11-payment-encoding.md

Value parameters:
amountOpt

amount to pay (empty string means no amount is specified)

createdAt

invoice timestamp (UNIX format)

nodeId

id of the node emitting the invoice

prefix

currency prefix; lnbc for bitcoin, lntb for bitcoin testnet

signature

invoice signature that will be checked against node id

tags

payment tags; must include a single PaymentHash tag and a single PaymentSecret tag.

Companion:
object
Source:
Bolt11Invoice.scala
case class ChannelAnnouncement(nodeSignature1: ByteVector64, nodeSignature2: ByteVector64, bitcoinSignature1: ByteVector64, bitcoinSignature2: ByteVector64, features: Features[Feature], chainHash: ByteVector32, shortChannelId: ShortChannelId, nodeId1: PublicKey, nodeId2: PublicKey, bitcoinKey1: PublicKey, bitcoinKey2: PublicKey, tlvStream: TlvStream[ChannelAnnouncementTlv]) extends RoutingMessage with AnnouncementMessage with HasChainHash
sealed trait ChannelAnnouncementTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class ChannelDisabled(messageFlags: Byte, channelFlags: ChannelFlags, update: ChannelUpdate) extends Update
case class ChannelReestablish(channelId: ByteVector32, nextLocalCommitmentNumber: Long, nextRemoteRevocationNumber: Long, yourLastPerCommitmentSecret: PrivateKey, myCurrentPerCommitmentPoint: PublicKey, tlvStream: TlvStream[ChannelReestablishTlv]) extends ChannelMessage with HasChannelId
sealed trait ChannelReestablishTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
object ChannelTlv
Source:
Tlv.scala

Permanent channel feature negotiated in the channel type. Those features take precedence over permanent channel features negotiated in init messages. For example, if the channel type is option_static_remotekey, then even if the option_anchor_outputs feature is supported by both peers, it won't apply to the channel.

Permanent channel feature negotiated in the channel type. Those features take precedence over permanent channel features negotiated in init messages. For example, if the channel type is option_static_remotekey, then even if the option_anchor_outputs feature is supported by both peers, it won't apply to the channel.

Source:
Features.scala
case class ChannelUpdate(signature: ByteVector64, chainHash: ByteVector32, shortChannelId: ShortChannelId, timestamp: TimestampSecond, channelFlags: ChannelFlags, cltvExpiryDelta: CltvExpiryDelta, htlcMinimumMsat: MilliSatoshi, feeBaseMsat: MilliSatoshi, feeProportionalMillionths: Long, htlcMaximumMsat: MilliSatoshi, tlvStream: TlvStream[ChannelUpdateTlv]) extends RoutingMessage with AnnouncementMessage with HasTimestamp with HasChainHash
sealed trait ChannelUpdateTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class ClosingSigned(channelId: ByteVector32, feeSatoshis: Satoshi, signature: ByteVector64, tlvStream: TlvStream[ClosingSignedTlv]) extends ChannelMessage with HasChannelId
sealed trait ClosingSignedTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class Color(r: Byte, g: Byte, b: Byte)
case class CommitSig(channelId: ByteVector32, signature: ByteVector64, htlcSignatures: List[ByteVector64], tlvStream: TlvStream[CommitSigTlv]) extends HtlcMessage with HasChannelId
sealed trait CommitSigTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait EncodingType
case class Error(channelId: ByteVector32, data: ByteVector, tlvStream: TlvStream[ErrorTlv]) extends SetupMessage with HasChannelId
sealed trait ErrorTlv extends Tlv
Companion:
object
Source:
Tlv.scala
object ErrorTlv
Companion:
class
Source:
Tlv.scala
case class ExpiryTooSoon(update: ChannelUpdate) extends Update
trait Feature

Not a sealed trait, so it can be extended by plugins.

Not a sealed trait, so it can be extended by plugins.

Source:
Features.scala
sealed trait FeatureSupport
Companion:
object
Source:
Features.scala
Companion:
class
Source:
Features.scala
case class Features[T <: Feature](activated: Map[T, FeatureSupport], unknown: Set[UnknownFeature])
Companion:
object
Source:
Features.scala
object Features
Companion:
class
Source:
Features.scala
case class FeeInsufficient(amount: MilliSatoshi, update: ChannelUpdate) extends Update
case class FundingCreated(temporaryChannelId: ByteVector32, fundingTxid: ByteVector32, fundingOutputIndex: Int, signature: ByteVector64, tlvStream: TlvStream[FundingCreatedTlv]) extends ChannelMessage with HasTemporaryChannelId
sealed trait FundingCreatedTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class FundingLocked(channelId: ByteVector32, nextPerCommitmentPoint: PublicKey, tlvStream: TlvStream[FundingLockedTlv]) extends ChannelMessage with HasChannelId
sealed trait FundingLockedTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait FundingSignedTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class GenericTlv(tag: UInt64, value: ByteVector) extends Tlv

Generic tlv type we fallback to if we don't understand the incoming tlv.

Generic tlv type we fallback to if we don't understand the incoming tlv.

Value parameters:
tag

tlv tag.

value

tlv value (length is implicit, and encoded as a varint).

Source:
Tlv.scala
case class GossipTimestampFilter(chainHash: ByteVector32, firstTimestamp: TimestampSecond, timestampRange: Long, tlvStream: TlvStream[GossipTimestampFilterTlv]) extends RoutingMessage with HasChainHash
sealed trait GossipTimestampFilterTlv extends Tlv
Companion:
object
Source:
Tlv.scala
sealed trait IPAddress extends NodeAddress
case class IPv4(ipv4: Ipv4Address, port: Int) extends IPAddress
case class IPv6(ipv6: Ipv6Address, port: Int) extends IPAddress

Helpers to handle incoming payment packets.

Helpers to handle incoming payment packets.

Companion:
class
Source:
PaymentPacket.scala
case class IncorrectCltvExpiry(expiry: CltvExpiry, update: ChannelUpdate) extends Update
case class Init(features: Features[InitFeature], tlvStream: TlvStream[InitTlv]) extends SetupMessage
trait InitFeature extends Feature

Feature that should be advertised in init messages.

Feature that should be advertised in init messages.

Source:
Features.scala
sealed trait InitTlv extends Tlv

Tlv types used inside Init messages.

Tlv types used inside Init messages.

Companion:
object
Source:
Tlv.scala
object InitTlv
Companion:
class
Source:
Tlv.scala
case class InvalidOnionHmac(onionHash: ByteVector32) extends BadOnion with Perm
case class InvalidOnionKey(onionHash: ByteVector32) extends BadOnion with Perm
case class InvalidOnionPayload(tag: UInt64, offset: Int) extends Perm
case class InvalidOnionVersion(onionHash: ByteVector32) extends BadOnion with Perm
case object InvalidRealm extends Perm
trait InvoiceFeature extends Feature

Feature that should be advertised in invoices.

Feature that should be advertised in invoices.

Source:
Features.scala
trait LightningMessage extends Serializable
sealed trait Node extends FailureMessage
sealed trait NodeAddress
case class NodeAnnouncement(signature: ByteVector64, features: Features[Feature], timestamp: TimestampSecond, nodeId: PublicKey, rgbColor: Color, alias: String, addresses: List[NodeAddress], tlvStream: TlvStream[NodeAnnouncementTlv]) extends RoutingMessage with AnnouncementMessage with HasTimestamp
sealed trait NodeAnnouncementTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
trait NodeFeature extends Feature

Feature that should be advertised in node announcements.

Feature that should be advertised in node announcements.

Source:
Features.scala
sealed trait OnionPaymentPayloadTlv extends Tlv

Tlv types used inside a payment onion.

Tlv types used inside a payment onion.

Companion:
object
Source:
PaymentOnion.scala
case class OnionRoutingPacket(version: Int, publicKey: ByteVector, payload: ByteVector, hmac: ByteVector32)
case class OpenChannel(chainHash: ByteVector32, temporaryChannelId: ByteVector32, fundingSatoshis: Satoshi, pushMsat: MilliSatoshi, dustLimitSatoshis: Satoshi, maxHtlcValueInFlightMsat: UInt64, channelReserveSatoshis: Satoshi, htlcMinimumMsat: MilliSatoshi, feeratePerKw: FeeratePerKw, toSelfDelay: CltvExpiryDelta, maxAcceptedHtlcs: Int, fundingPubkey: PublicKey, revocationBasepoint: PublicKey, paymentBasepoint: PublicKey, delayedPaymentBasepoint: PublicKey, htlcBasepoint: PublicKey, firstPerCommitmentPoint: PublicKey, channelFlags: ChannelFlags, tlvStream: TlvStream[OpenChannelTlv]) extends ChannelMessage with HasTemporaryChannelId with HasChainHash
sealed trait OpenChannelTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait Perm extends FailureMessage

Feature negotiated when opening a channel that will apply for all of the channel's lifetime. This doesn't include features that can be safely activated/deactivated without impacting the channel's operation such as option_dataloss_protect or option_shutdown_anysegwit.

Feature negotiated when opening a channel that will apply for all of the channel's lifetime. This doesn't include features that can be safely activated/deactivated without impacting the channel's operation such as option_dataloss_protect or option_shutdown_anysegwit.

Source:
Features.scala
case object PermanentNodeFailure extends Perm with Node
case class Ping(pongLength: Int, data: ByteVector, tlvStream: TlvStream[PingTlv]) extends SetupMessage
sealed trait PingTlv extends Tlv
Companion:
object
Source:
Tlv.scala
object PingTlv
Companion:
class
Source:
Tlv.scala
case class Pong(data: ByteVector, tlvStream: TlvStream[PongTlv]) extends SetupMessage
sealed trait PongTlv extends Tlv
Companion:
object
Source:
Tlv.scala
object PongTlv
Companion:
class
Source:
Tlv.scala
case class QueryChannelRange(chainHash: ByteVector32, firstBlock: BlockHeight, numberOfBlocks: Long, tlvStream: TlvStream[QueryChannelRangeTlv]) extends RoutingMessage
sealed trait QueryChannelRangeTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait QueryShortChannelIdsTlv extends Tlv
Companion:
object
Source:
Tlv.scala
case class ReplyChannelRange(chainHash: ByteVector32, firstBlock: BlockHeight, numberOfBlocks: Long, syncComplete: Byte, shortChannelIds: EncodedShortChannelIds, tlvStream: TlvStream[ReplyChannelRangeTlv]) extends RoutingMessage
sealed trait ReplyChannelRangeTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait ReplyShortChannelIdsEndTlv extends Tlv
Companion:
object
Source:
Tlv.scala
case class RevokeAndAck(channelId: ByteVector32, perCommitmentSecret: PrivateKey, nextPerCommitmentPoint: PublicKey, tlvStream: TlvStream[RevokeAndAckTlv]) extends HtlcMessage with HasChannelId
sealed trait RevokeAndAckTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait RouteBlindingEncryptedDataTlv extends Tlv
Companion:
object
Source:
RouteBlinding.scala
object ShaChain

see https://github.com/rustyrussell/lightning-rfc/blob/master/early-drafts/shachain.txt

case class ShaChain(knownHashes: Map[Vector[Boolean], ByteVector32], lastIndex: Option[Long])

Structure used to intelligently store unguessable hashes.

Structure used to intelligently store unguessable hashes.

Value parameters:
knownHashes

know hashes

lastIndex

index of the last known hash. Hashes are supposed to be added in reverse order i.e. from 0xFFFFFFFFFFFFFFFF down to 0

Companion:
object
Source:
ShaChain.scala
case class Shutdown(channelId: ByteVector32, scriptPubKey: ByteVector, tlvStream: TlvStream[ShutdownTlv]) extends ChannelMessage with HasChannelId
sealed trait ShutdownTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
object Sphinx
trait Tlv
Source:
Tlv.scala
object TlvCodecs
Source:
Tlv.scala
case class TlvStream[T <: Tlv](records: Iterable[T], unknown: Iterable[GenericTlv])

A tlv stream is a collection of tlv records. A tlv stream is constrained to a specific tlv namespace that dictates how to parse the tlv records. That namespace is provided by a trait extending the top-level tlv trait.

A tlv stream is a collection of tlv records. A tlv stream is constrained to a specific tlv namespace that dictates how to parse the tlv records. That namespace is provided by a trait extending the top-level tlv trait.

Type parameters:
T

the stream namespace is a trait extending the top-level tlv trait.

Value parameters:
records

known tlv records.

unknown

unknown tlv records.

Companion:
object
Source:
Tlv.scala
object TlvStream
Companion:
class
Source:
Tlv.scala
case class Tor2(tor2: String, port: Int) extends OnionAddress
case class Tor3(tor3: String, port: Int) extends OnionAddress

We allow remote nodes to send us unknown failure codes (e.g. deprecated failure codes). By reading the PERM and NODE bits we can still extract useful information for payment retry even without knowing how to decode the failure payload (but we can't extract a channel update or onion hash).

We allow remote nodes to send us unknown failure codes (e.g. deprecated failure codes). By reading the PERM and NODE bits we can still extract useful information for payment retry even without knowing how to decode the failure payload (but we can't extract a channel update or onion hash).

Source:
FailureMessage.scala
case class UnknownFeature(bitIndex: Int)
case class UnknownMessage(tag: Int, data: ByteVector) extends LightningMessage
case object UnknownNextPeer extends Perm
sealed trait Update extends FailureMessage
case class UpdateAddHtlc(channelId: ByteVector32, id: Long, amountMsat: MilliSatoshi, paymentHash: ByteVector32, cltvExpiry: CltvExpiry, onionRoutingPacket: OnionRoutingPacket, tlvStream: TlvStream[UpdateAddHtlcTlv]) extends HtlcMessage with UpdateMessage with HasChannelId
sealed trait UpdateAddHtlcTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait UpdateFailHtlcTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class UpdateFailMalformedHtlc(channelId: ByteVector32, id: Long, onionHash: ByteVector32, failureCode: Int, tlvStream: TlvStream[UpdateFailMalformedHtlcTlv]) extends HtlcMessage with UpdateMessage with HasChannelId with HtlcSettlementMessage
sealed trait UpdateFailMalformedHtlcTlv extends Tlv
Companion:
object
Source:
Tlv.scala
case class UpdateFee(channelId: ByteVector32, feeratePerKw: FeeratePerKw, tlvStream: TlvStream[UpdateFeeTlv]) extends ChannelMessage with UpdateMessage with HasChannelId
sealed trait UpdateFeeTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
sealed trait UpdateFulfillHtlcTlv extends Tlv
Companion:
object
Source:
Tlv.scala
Companion:
class
Source:
Tlv.scala
case class Warning(channelId: ByteVector32, data: ByteVector, tlvStream: TlvStream[WarningTlv]) extends SetupMessage with HasChannelId
sealed trait WarningTlv extends Tlv
Companion:
object
Source:
Tlv.scala
object WarningTlv
Companion:
class
Source:
Tlv.scala

Value members

Concrete methods

def addressToPublicKeyScript(address: String, chainHash: ByteVector32): Seq[ScriptElt]
Value parameters:
address

base58 of bech32 address

chainHash

hash of the chain we're on, which will be checked against the input address

Returns:

the public key script that matches the input address.

Source:
package.scala
def isAsciiPrintable(data: ByteVector): Boolean

Tests whether the binary data is composed solely of printable ASCII characters (see BOLT 1)

Tests whether the binary data is composed solely of printable ASCII characters (see BOLT 1)

Value parameters:
data

to check

Source:
package.scala
def nodeFee(baseFee: MilliSatoshi, proportionalFee: Long, paymentAmount: MilliSatoshi): MilliSatoshi
Value parameters:
baseFee

fixed fee

paymentAmount

payment amount in millisatoshi

proportionalFee

proportional fee (millionths)

Returns:

the fee that a node should be paid to forward an HTLC of 'paymentAmount' millisatoshis

Source:
package.scala
def toLongId(fundingTxHash: ByteVector32, fundingOutputIndex: Int): ByteVector32