| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Lightning.Protocol.BOLT3
Description
Bitcoin transaction and script formats for the Lightning Network, per BOLT #3 (commitment, HTLC and closing transactions, their output scripts and witnesses, per-commitment key derivation, and per-commitment secret generation and storage).
Amounts, points, hashes and per-commitment secrets are the types of
ppad-bolt1's Lightning.Protocol.BOLT1; transactions convert to
ppad-tx's Bitcoin.Prim.Tx for txids, sighashes and serialization.
The option_static_remotekey and option_anchors commitment formats
are supported (CommitmentFormat).
Synopsis
- data CommitmentContext = CommitmentContext {
- cc_funding_outpoint :: !OutPoint
- cc_commitment_number :: !CommitmentNumber
- cc_local_payment_bp :: !PaymentBasepoint
- cc_remote_payment_bp :: !PaymentBasepoint
- cc_to_self_delay :: !ToSelfDelay
- cc_dust_limit :: !DustLimit
- cc_feerate :: !FeeratePerKw
- cc_format :: !CommitmentFormat
- cc_is_funder :: !Bool
- cc_to_local_msat :: !MilliSatoshi
- cc_to_remote_msat :: !MilliSatoshi
- cc_htlcs :: ![HTLC]
- cc_keys :: !CommitmentKeys
- data CommitmentFormat
- data CommitmentTx = CommitmentTx {}
- data CommitmentOutput = CommitmentOutput {}
- data OutputType
- build_commitment_tx :: CommitmentContext -> Maybe CommitmentTx
- data HTLC = HTLC {}
- data HTLCDirection
- data CommitmentNumber
- commitment_number :: Word64 -> Maybe CommitmentNumber
- un_commitment_number :: CommitmentNumber -> Word64
- next_commitment_number :: CommitmentNumber -> Maybe CommitmentNumber
- newtype ToSelfDelay = ToSelfDelay Word16
- newtype CltvExpiry = CltvExpiry Word32
- newtype DustLimit = DustLimit Satoshi
- newtype FeeratePerKw = FeeratePerKw Word32
- newtype Locktime = Locktime Word32
- newtype Sequence = Sequence Word32
- commitment_fee :: FeeratePerKw -> CommitmentFormat -> Word64 -> Satoshi
- htlc_timeout_fee :: FeeratePerKw -> CommitmentFormat -> Satoshi
- htlc_success_fee :: FeeratePerKw -> CommitmentFormat -> Satoshi
- htlc_trim_threshold :: DustLimit -> FeeratePerKw -> CommitmentFormat -> HTLCDirection -> Satoshi
- is_trimmed :: DustLimit -> FeeratePerKw -> CommitmentFormat -> HTLC -> Bool
- anchor_output_value :: Satoshi
- data HTLCContext = HTLCContext {}
- data HTLCTx = HTLCTx {}
- build_htlc_tx :: HTLCContext -> Maybe HTLCTx
- data ClosingTx = ClosingTx {}
- data ClosingOutput = ClosingOutput {
- clo_value :: !Satoshi
- clo_script :: !Script
- data ClosingContext = ClosingContext {}
- data ClosingOutputs
- build_closing_tx :: ClosingContext -> Maybe ClosingTx
- data LegacyClosingContext = LegacyClosingContext {}
- build_legacy_closing_tx :: LegacyClosingContext -> Maybe ClosingTx
- dust_p2pkh :: Satoshi
- dust_p2sh :: Satoshi
- dust_p2wpkh :: Satoshi
- dust_p2wsh :: Satoshi
- commitment_to_tx :: CommitmentTx -> Tx
- htlc_to_tx :: HTLCTx -> Tx
- closing_to_tx :: ClosingTx -> Tx
- encode_commitment_tx :: CommitmentTx -> ByteString
- encode_htlc_tx :: HTLCTx -> ByteString
- encode_closing_tx :: ClosingTx -> ByteString
- data Basepoints = Basepoints {}
- newtype RevocationBasepoint = RevocationBasepoint Point
- newtype PaymentBasepoint = PaymentBasepoint Point
- newtype DelayedPaymentBasepoint = DelayedPaymentBasepoint Point
- newtype HtlcBasepoint = HtlcBasepoint Point
- newtype PerCommitmentPoint = PerCommitmentPoint Point
- derive_per_commitment_point :: PerCommitmentSecret -> Maybe PerCommitmentPoint
- derive_per_commitment_point' :: Context -> PerCommitmentSecret -> Maybe PerCommitmentPoint
- data CommitmentKeys = CommitmentKeys {}
- derive_commitment_keys :: Basepoints -> FundingPubkey -> Basepoints -> FundingPubkey -> PerCommitmentPoint -> Maybe CommitmentKeys
- derive_commitment_keys' :: Context -> Basepoints -> FundingPubkey -> Basepoints -> FundingPubkey -> PerCommitmentPoint -> Maybe CommitmentKeys
- newtype RevocationPubkey = RevocationPubkey Point
- newtype LocalDelayedPubkey = LocalDelayedPubkey Point
- newtype LocalHtlcPubkey = LocalHtlcPubkey Point
- newtype RemoteHtlcPubkey = RemoteHtlcPubkey Point
- newtype RemotePubkey = RemotePubkey Point
- newtype FundingPubkey = FundingPubkey Point
- derive_pubkey :: Point -> PerCommitmentPoint -> Maybe Point
- derive_revocationpubkey :: RevocationBasepoint -> PerCommitmentPoint -> Maybe RevocationPubkey
- data Seckey
- seckey :: ByteString -> Maybe Seckey
- un_seckey :: Seckey -> ByteString
- derive_privkey :: Seckey -> PerCommitmentPoint -> Maybe Seckey
- derive_revocationprivkey :: Seckey -> PerCommitmentSecret -> Maybe Seckey
- data Seed
- seed :: ByteString -> Maybe Seed
- un_seed :: Seed -> ByteString
- data SecretIndex
- secret_index :: Word64 -> Maybe SecretIndex
- un_secret_index :: SecretIndex -> Word64
- commitment_secret_index :: CommitmentNumber -> SecretIndex
- generate_from_seed :: Seed -> SecretIndex -> PerCommitmentSecret
- data SecretStore
- empty_secret_store :: SecretStore
- insert_secret :: PerCommitmentSecret -> SecretIndex -> SecretStore -> Maybe SecretStore
- derive_old_secret :: SecretIndex -> SecretStore -> Maybe PerCommitmentSecret
- secret_store :: [(SecretIndex, PerCommitmentSecret)] -> Maybe SecretStore
- un_secret_store :: SecretStore -> [(SecretIndex, PerCommitmentSecret)]
- obscured_commitment_number :: PaymentBasepoint -> PaymentBasepoint -> CommitmentNumber -> Word64
- newtype Script = Script ByteString
- to_p2wsh :: Script -> Script
- funding_script :: FundingPubkey -> FundingPubkey -> Script
- funding_witness :: FundingPubkey -> ByteString -> FundingPubkey -> ByteString -> Witness
- to_local_script :: RevocationPubkey -> ToSelfDelay -> LocalDelayedPubkey -> Script
- to_local_witness_spend :: ByteString -> Script -> Witness
- to_local_witness_revoke :: ByteString -> Script -> Witness
- to_remote_witness_script :: RemotePubkey -> Script
- to_remote_script_pubkey :: RemotePubkey -> CommitmentFormat -> Script
- to_remote_witness :: ByteString -> RemotePubkey -> CommitmentFormat -> Witness
- anchor_script :: FundingPubkey -> Script
- anchor_witness_owner :: ByteString -> FundingPubkey -> Witness
- anchor_witness_anyone :: FundingPubkey -> Witness
- offered_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> CommitmentFormat -> Script
- offered_htlc_witness_preimage :: ByteString -> PaymentPreimage -> Script -> Witness
- offered_htlc_witness_revoke :: ByteString -> RevocationPubkey -> Script -> Witness
- received_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> CltvExpiry -> CommitmentFormat -> Script
- received_htlc_witness_timeout :: ByteString -> Script -> Witness
- received_htlc_witness_revoke :: ByteString -> RevocationPubkey -> Script -> Witness
- htlc_success_witness :: ByteString -> ByteString -> PaymentPreimage -> Script -> Witness
- htlc_timeout_witness :: ByteString -> ByteString -> Script -> Witness
- remote_htlc_sighash :: CommitmentFormat -> SighashType
Commitment transactions
data CommitmentContext Source #
The parameters of a commitment transaction, from the point of view of its owner (the "local" party, whose outputs are delayed).
Constructors
| CommitmentContext | |
Fields
| |
Instances
data CommitmentFormat Source #
The commitment format a channel uses, as fixed by its
channel_type.
Constructors
| StaticRemotekey |
|
| Anchors |
|
Instances
| NFData CommitmentFormat Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: CommitmentFormat -> () # | |||||
| Generic CommitmentFormat Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: CommitmentFormat -> Rep CommitmentFormat x # to :: Rep CommitmentFormat x -> CommitmentFormat # | |||||
| Show CommitmentFormat Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> CommitmentFormat -> ShowS # show :: CommitmentFormat -> String # showList :: [CommitmentFormat] -> ShowS # | |||||
| Eq CommitmentFormat Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: CommitmentFormat -> CommitmentFormat -> Bool # (/=) :: CommitmentFormat -> CommitmentFormat -> Bool # | |||||
| Ord CommitmentFormat Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: CommitmentFormat -> CommitmentFormat -> Ordering # (<) :: CommitmentFormat -> CommitmentFormat -> Bool # (<=) :: CommitmentFormat -> CommitmentFormat -> Bool # (>) :: CommitmentFormat -> CommitmentFormat -> Bool # (>=) :: CommitmentFormat -> CommitmentFormat -> Bool # max :: CommitmentFormat -> CommitmentFormat -> CommitmentFormat # min :: CommitmentFormat -> CommitmentFormat -> CommitmentFormat # | |||||
| type Rep CommitmentFormat Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
data CommitmentTx Source #
An unsigned commitment transaction.
Constructors
| CommitmentTx | |
Fields
| |
Instances
| NFData CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: CommitmentTx -> () # | |||||
| Generic CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> CommitmentTx -> ShowS # show :: CommitmentTx -> String # showList :: [CommitmentTx] -> ShowS # | |||||
| Eq CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| type Rep CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep CommitmentTx = D1 ('MetaData "CommitmentTx" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "CommitmentTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ctx_version") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "ctx_locktime") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Locktime) :*: S1 ('MetaSel ('Just "ctx_input_outpoint") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 OutPoint))) :*: (S1 ('MetaSel ('Just "ctx_input_sequence") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Sequence) :*: (S1 ('MetaSel ('Just "ctx_outputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty CommitmentOutput)) :*: S1 ('MetaSel ('Just "ctx_funding_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))))) | |||||
data CommitmentOutput Source #
A commitment transaction output.
Constructors
| CommitmentOutput | |
Instances
| NFData CommitmentOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: CommitmentOutput -> () # | |||||
| Generic CommitmentOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
Methods from :: CommitmentOutput -> Rep CommitmentOutput x # to :: Rep CommitmentOutput x -> CommitmentOutput # | |||||
| Show CommitmentOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> CommitmentOutput -> ShowS # show :: CommitmentOutput -> String # showList :: [CommitmentOutput] -> ShowS # | |||||
| Eq CommitmentOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: CommitmentOutput -> CommitmentOutput -> Bool # (/=) :: CommitmentOutput -> CommitmentOutput -> Bool # | |||||
| type Rep CommitmentOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep CommitmentOutput = D1 ('MetaData "CommitmentOutput" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "CommitmentOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "co_value") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: (S1 ('MetaSel ('Just "co_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script) :*: S1 ('MetaSel ('Just "co_type") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OutputType)))) | |||||
data OutputType Source #
What a commitment transaction output pays.
Constructors
| OutputToLocal | |
| OutputToRemote | |
| OutputLocalAnchor | |
| OutputRemoteAnchor | |
| OutputHTLC !HTLC | an offered or received HTLC (per its |
Instances
| NFData OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: OutputType -> () # | |||||
| Generic OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> OutputType -> ShowS # show :: OutputType -> String # showList :: [OutputType] -> ShowS # | |||||
| Eq OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| type Rep OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep OutputType = D1 ('MetaData "OutputType" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) ((C1 ('MetaCons "OutputToLocal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OutputToRemote" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OutputLocalAnchor" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OutputRemoteAnchor" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OutputHTLC" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLC))))) | |||||
build_commitment_tx :: CommitmentContext -> Maybe CommitmentTx Source #
Build a commitment transaction, per BOLT #3's "Commitment Transaction Construction":
- the locktime and input sequence encode the obscured commitment
number (the payment basepoints are ordered by
cc_is_funder); - HTLCs whose amount, less the HTLC transaction fee, is below the dust limit are trimmed;
- the base fee (and under
Anchors, both anchors) are taken from the funder's output, which is left at zero if it can't cover them; to_localandto_remoteoutputs below the dust limit are omitted, and underAnchorseach party's anchor is added if its output, or any HTLC output, exists;- outputs are sorted by value, scriptPubKey and CLTV expiry.
Fails if the transaction would have no outputs.
HTLCs
An HTLC committed to a commitment transaction.
Constructors
| HTLC | |
Fields | |
Instances
| NFData HTLC Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Generic HTLC Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show HTLC Source # | |||||
| Eq HTLC Source # | |||||
| type Rep HTLC Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep HTLC = D1 ('MetaData "HTLC" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "HTLC" 'PrefixI 'True) ((S1 ('MetaSel ('Just "htlc_direction") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLCDirection) :*: S1 ('MetaSel ('Just "htlc_amount_msat") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi)) :*: (S1 ('MetaSel ('Just "htlc_payment_hash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PaymentHash) :*: S1 ('MetaSel ('Just "htlc_cltv_expiry") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 CltvExpiry)))) | |||||
data HTLCDirection Source #
The direction of an HTLC, from the commitment owner's point of view.
Constructors
| HTLCOffered | offered by the owner |
| HTLCReceived | received by the owner |
Instances
| NFData HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: HTLCDirection -> () # | |||||
| Generic HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> HTLCDirection -> ShowS # show :: HTLCDirection -> String # showList :: [HTLCDirection] -> ShowS # | |||||
| Eq HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: HTLCDirection -> HTLCDirection -> Bool # (/=) :: HTLCDirection -> HTLCDirection -> Bool # | |||||
| Ord HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: HTLCDirection -> HTLCDirection -> Ordering # (<) :: HTLCDirection -> HTLCDirection -> Bool # (<=) :: HTLCDirection -> HTLCDirection -> Bool # (>) :: HTLCDirection -> HTLCDirection -> Bool # (>=) :: HTLCDirection -> HTLCDirection -> Bool # max :: HTLCDirection -> HTLCDirection -> HTLCDirection # min :: HTLCDirection -> HTLCDirection -> HTLCDirection # | |||||
| type Rep HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
Channel parameters
data CommitmentNumber Source #
A 48-bit commitment number.
Instances
| NFData CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: CommitmentNumber -> () # | |||||
| Generic CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: CommitmentNumber -> Rep CommitmentNumber x # to :: Rep CommitmentNumber x -> CommitmentNumber # | |||||
| Show CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> CommitmentNumber -> ShowS # show :: CommitmentNumber -> String # showList :: [CommitmentNumber] -> ShowS # | |||||
| Eq CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: CommitmentNumber -> CommitmentNumber -> Bool # (/=) :: CommitmentNumber -> CommitmentNumber -> Bool # | |||||
| Ord CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: CommitmentNumber -> CommitmentNumber -> Ordering # (<) :: CommitmentNumber -> CommitmentNumber -> Bool # (<=) :: CommitmentNumber -> CommitmentNumber -> Bool # (>) :: CommitmentNumber -> CommitmentNumber -> Bool # (>=) :: CommitmentNumber -> CommitmentNumber -> Bool # max :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber # min :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber # | |||||
| type Rep CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep CommitmentNumber = D1 ('MetaData "CommitmentNumber" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "CommitmentNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) | |||||
commitment_number :: Word64 -> Maybe CommitmentNumber Source #
Construct a CommitmentNumber. Fails at or above 2^48.
>>>commitment_number 42Just (CommitmentNumber 42)>>>commitment_number 281474976710656Nothing
un_commitment_number :: CommitmentNumber -> Word64 Source #
The value of a CommitmentNumber.
next_commitment_number :: CommitmentNumber -> Maybe CommitmentNumber Source #
The next commitment number. Fails past 2^48 - 1.
>>>commitment_number 0 >>= next_commitment_numberJust (CommitmentNumber 1)>>>commitment_number 281474976710655 >>= next_commitment_numberNothing
newtype ToSelfDelay Source #
The CSV delay (to_self_delay) on a commitment owner's outputs.
Constructors
| ToSelfDelay Word16 |
Instances
| NFData ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: ToSelfDelay -> () # | |||||
| Generic ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> ToSelfDelay -> ShowS # show :: ToSelfDelay -> String # showList :: [ToSelfDelay] -> ShowS # | |||||
| Eq ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: ToSelfDelay -> ToSelfDelay -> Ordering # (<) :: ToSelfDelay -> ToSelfDelay -> Bool # (<=) :: ToSelfDelay -> ToSelfDelay -> Bool # (>) :: ToSelfDelay -> ToSelfDelay -> Bool # (>=) :: ToSelfDelay -> ToSelfDelay -> Bool # max :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay # min :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay # | |||||
| type Rep ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep ToSelfDelay = D1 ('MetaData "ToSelfDelay" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "ToSelfDelay" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16))) | |||||
newtype CltvExpiry Source #
An HTLC's absolute CLTV expiry.
Constructors
| CltvExpiry Word32 |
Instances
| NFData CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: CltvExpiry -> () # | |||||
| Generic CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> CltvExpiry -> ShowS # show :: CltvExpiry -> String # showList :: [CltvExpiry] -> ShowS # | |||||
| Eq CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: CltvExpiry -> CltvExpiry -> Ordering # (<) :: CltvExpiry -> CltvExpiry -> Bool # (<=) :: CltvExpiry -> CltvExpiry -> Bool # (>) :: CltvExpiry -> CltvExpiry -> Bool # (>=) :: CltvExpiry -> CltvExpiry -> Bool # max :: CltvExpiry -> CltvExpiry -> CltvExpiry # min :: CltvExpiry -> CltvExpiry -> CltvExpiry # | |||||
| type Rep CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep CltvExpiry = D1 ('MetaData "CltvExpiry" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "CltvExpiry" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32))) | |||||
A dust_limit_satoshis threshold.
Instances
| NFData DustLimit Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Generic DustLimit Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show DustLimit Source # | |||||
| Eq DustLimit Source # | |||||
| Ord DustLimit Source # | |||||
| type Rep DustLimit Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
newtype FeeratePerKw Source #
A fee rate, in satoshis per 1000 weight units.
Constructors
| FeeratePerKw Word32 |
Instances
| NFData FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: FeeratePerKw -> () # | |||||
| Generic FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> FeeratePerKw -> ShowS # show :: FeeratePerKw -> String # showList :: [FeeratePerKw] -> ShowS # | |||||
| Eq FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: FeeratePerKw -> FeeratePerKw -> Ordering # (<) :: FeeratePerKw -> FeeratePerKw -> Bool # (<=) :: FeeratePerKw -> FeeratePerKw -> Bool # (>) :: FeeratePerKw -> FeeratePerKw -> Bool # (>=) :: FeeratePerKw -> FeeratePerKw -> Bool # max :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw # min :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw # | |||||
| type Rep FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep FeeratePerKw = D1 ('MetaData "FeeratePerKw" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "FeeratePerKw" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32))) | |||||
A transaction locktime.
Instances
| NFData Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Generic Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Locktime Source # | |||||
| Eq Locktime Source # | |||||
| Ord Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
A transaction input's sequence number.
Instances
| NFData Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Generic Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Sequence Source # | |||||
| Eq Sequence Source # | |||||
| Ord Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
Fees and trimming
commitment_fee :: FeeratePerKw -> CommitmentFormat -> Word64 -> Satoshi Source #
The base fee of a commitment transaction with a given number of untrimmed HTLC outputs:
feerate_per_kw * (724 + 172 * num_htlcs) / 1000
with a base weight of 1124 rather than 724 under Anchors.
>>>commitment_fee (FeeratePerKw 5000) StaticRemotekey 2Satoshi 5340
htlc_timeout_fee :: FeeratePerKw -> CommitmentFormat -> Satoshi Source #
The fee of an HTLC-timeout transaction: feerate_per_kw * 663 /
1000, or zero under Anchors.
>>>htlc_timeout_fee (FeeratePerKw 5000) StaticRemotekeySatoshi 3315
htlc_success_fee :: FeeratePerKw -> CommitmentFormat -> Satoshi Source #
The fee of an HTLC-success transaction: feerate_per_kw * 703 /
1000, or zero under Anchors.
>>>htlc_success_fee (FeeratePerKw 5000) StaticRemotekeySatoshi 3515
htlc_trim_threshold :: DustLimit -> FeeratePerKw -> CommitmentFormat -> HTLCDirection -> Satoshi Source #
The amount below which an HTLC in a given direction is trimmed: the dust limit plus the fee of its HTLC transaction.
>>>let Just d = fmap DustLimit (BOLT1.satoshi 546)>>>htlc_trim_threshold d (FeeratePerKw 5000) StaticRemotekey HTLCOfferedSatoshi 3861
is_trimmed :: DustLimit -> FeeratePerKw -> CommitmentFormat -> HTLC -> Bool Source #
Whether an HTLC is trimmed from a commitment transaction: whether
its amount, rounded down to whole satoshis, is below
htlc_trim_threshold.
anchor_output_value :: Satoshi Source #
The value of each anchor output (330 satoshis).
HTLC transactions
data HTLCContext Source #
The parameters of an HTLC-success or HTLC-timeout transaction, spending an HTLC output of the owner's commitment transaction.
Constructors
| HTLCContext | |
Fields | |
Instances
| NFData HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: HTLCContext -> () # | |||||
| Generic HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> HTLCContext -> ShowS # show :: HTLCContext -> String # showList :: [HTLCContext] -> ShowS # | |||||
| Eq HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| type Rep HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep HTLCContext = D1 ('MetaData "HTLCContext" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "HTLCContext" 'PrefixI 'True) (((S1 ('MetaSel ('Just "hc_commitment_txid") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TxId) :*: S1 ('MetaSel ('Just "hc_output_index") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32)) :*: (S1 ('MetaSel ('Just "hc_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLC) :*: S1 ('MetaSel ('Just "hc_to_self_delay") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 ToSelfDelay))) :*: ((S1 ('MetaSel ('Just "hc_feerate") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 FeeratePerKw) :*: S1 ('MetaSel ('Just "hc_format") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CommitmentFormat)) :*: (S1 ('MetaSel ('Just "hc_revocation_pubkey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey) :*: S1 ('MetaSel ('Just "hc_local_delayed") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalDelayedPubkey))))) | |||||
An unsigned HTLC-success or HTLC-timeout transaction.
Constructors
| HTLCTx | |
Fields
| |
Instances
| NFData HTLCTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| Generic HTLCTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show HTLCTx Source # | |||||
| Eq HTLCTx Source # | |||||
| type Rep HTLCTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep HTLCTx = D1 ('MetaData "HTLCTx" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "HTLCTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "htx_version") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "htx_locktime") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Locktime) :*: S1 ('MetaSel ('Just "htx_input_outpoint") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 OutPoint))) :*: (S1 ('MetaSel ('Just "htx_input_sequence") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Sequence) :*: (S1 ('MetaSel ('Just "htx_output_value") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Just "htx_output_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))))) | |||||
build_htlc_tx :: HTLCContext -> Maybe HTLCTx Source #
Build the second-stage transaction for an HTLC output of the
owner's commitment transaction: HTLC-timeout (locktime
cltv_expiry) for an offered HTLC, and HTLC-success (locktime 0)
for a received one.
The output pays the HTLC amount, less the HTLC transaction fee
(zero under Anchors), to the to_local_script of the owner's
keys. Fails if the fee exceeds the amount (such an HTLC is always
trimmed).
Closing transactions
An unsigned closing transaction.
Constructors
| ClosingTx | |
Fields
| |
Instances
| NFData ClosingTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| Generic ClosingTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show ClosingTx Source # | |||||
| Eq ClosingTx Source # | |||||
| type Rep ClosingTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep ClosingTx = D1 ('MetaData "ClosingTx" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "ClosingTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cltx_version") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Just "cltx_locktime") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Locktime)) :*: (S1 ('MetaSel ('Just "cltx_input_outpoint") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 OutPoint) :*: (S1 ('MetaSel ('Just "cltx_input_sequence") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Sequence) :*: S1 ('MetaSel ('Just "cltx_outputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty ClosingOutput)))))) | |||||
data ClosingOutput Source #
A closing transaction output.
Constructors
| ClosingOutput | |
Fields
| |
Instances
| NFData ClosingOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: ClosingOutput -> () # | |||||
| Generic ClosingOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show ClosingOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> ClosingOutput -> ShowS # show :: ClosingOutput -> String # showList :: [ClosingOutput] -> ShowS # | |||||
| Eq ClosingOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: ClosingOutput -> ClosingOutput -> Bool # (/=) :: ClosingOutput -> ClosingOutput -> Bool # | |||||
| type Rep ClosingOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep ClosingOutput = D1 ('MetaData "ClosingOutput" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "ClosingOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "clo_value") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Just "clo_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))) | |||||
data ClosingContext Source #
The parameters of an option_simple_close closing transaction,
as given by a closing_complete message.
Constructors
| ClosingContext | |
Fields
| |
Instances
| NFData ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: ClosingContext -> () # | |||||
| Generic ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
Methods from :: ClosingContext -> Rep ClosingContext x # to :: Rep ClosingContext x -> ClosingContext # | |||||
| Show ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> ClosingContext -> ShowS # show :: ClosingContext -> String # showList :: [ClosingContext] -> ShowS # | |||||
| Eq ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: ClosingContext -> ClosingContext -> Bool # (/=) :: ClosingContext -> ClosingContext -> Bool # | |||||
| type Rep ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep ClosingContext = D1 ('MetaData "ClosingContext" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "ClosingContext" 'PrefixI 'True) (((S1 ('MetaSel ('Just "clc_funding_outpoint") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 OutPoint) :*: S1 ('MetaSel ('Just "clc_closer_msat") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi)) :*: (S1 ('MetaSel ('Just "clc_closee_msat") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi) :*: S1 ('MetaSel ('Just "clc_closer_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))) :*: ((S1 ('MetaSel ('Just "clc_closee_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script) :*: S1 ('MetaSel ('Just "clc_fee") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi)) :*: (S1 ('MetaSel ('Just "clc_locktime") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Locktime) :*: S1 ('MetaSel ('Just "clc_outputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ClosingOutputs))))) | |||||
data ClosingOutputs Source #
Which outputs an option_simple_close closing transaction has,
matching the signature fields of closing_complete.
Constructors
| CloserOutputOnly | |
| CloseeOutputOnly | |
| CloserAndCloseeOutputs |
Instances
| NFData ClosingOutputs Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: ClosingOutputs -> () # | |||||
| Generic ClosingOutputs Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
Methods from :: ClosingOutputs -> Rep ClosingOutputs x # to :: Rep ClosingOutputs x -> ClosingOutputs # | |||||
| Show ClosingOutputs Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> ClosingOutputs -> ShowS # show :: ClosingOutputs -> String # showList :: [ClosingOutputs] -> ShowS # | |||||
| Eq ClosingOutputs Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: ClosingOutputs -> ClosingOutputs -> Bool # (/=) :: ClosingOutputs -> ClosingOutputs -> Bool # | |||||
| type Rep ClosingOutputs Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep ClosingOutputs = D1 ('MetaData "ClosingOutputs" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "CloserOutputOnly" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CloseeOutputOnly" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CloserAndCloseeOutputs" 'PrefixI 'False) (U1 :: Type -> Type))) | |||||
build_closing_tx :: ClosingContext -> Maybe ClosingTx Source #
Build an option_simple_close closing transaction (BOLT #3's
"Closing Transaction"), for closing_complete and closing_sig.
The closer pays the fee: its output is its balance, rounded down
to whole satoshis, less the fee. An output whose scriptPubKey
starts with OP_RETURN has amount 0. Only the chosen outputs are
included, and none is trimmed. Fails if the fee exceeds the
closer's balance.
data LegacyClosingContext Source #
The parameters of a legacy closing transaction (for
closing_signed), from the point of view of the node producing
the signature (the "local" party).
Constructors
| LegacyClosingContext | |
Fields
| |
Instances
| NFData LegacyClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods rnf :: LegacyClosingContext -> () # | |||||
| Generic LegacyClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
Methods from :: LegacyClosingContext -> Rep LegacyClosingContext x # to :: Rep LegacyClosingContext x -> LegacyClosingContext # | |||||
| Show LegacyClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> LegacyClosingContext -> ShowS # show :: LegacyClosingContext -> String # showList :: [LegacyClosingContext] -> ShowS # | |||||
| Eq LegacyClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: LegacyClosingContext -> LegacyClosingContext -> Bool # (/=) :: LegacyClosingContext -> LegacyClosingContext -> Bool # | |||||
| type Rep LegacyClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep LegacyClosingContext = D1 ('MetaData "LegacyClosingContext" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "LegacyClosingContext" 'PrefixI 'True) (((S1 ('MetaSel ('Just "lcc_funding_outpoint") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 OutPoint) :*: S1 ('MetaSel ('Just "lcc_local_msat") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi)) :*: (S1 ('MetaSel ('Just "lcc_remote_msat") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi) :*: S1 ('MetaSel ('Just "lcc_local_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))) :*: ((S1 ('MetaSel ('Just "lcc_remote_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script) :*: S1 ('MetaSel ('Just "lcc_dust_limit") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 DustLimit)) :*: (S1 ('MetaSel ('Just "lcc_fee") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: (S1 ('MetaSel ('Just "lcc_is_funder") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "lcc_omit_local") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))))) | |||||
build_legacy_closing_tx :: LegacyClosingContext -> Maybe ClosingTx Source #
Build a legacy closing transaction (BOLT #3's "Legacy Closing
Transaction"), for closing_signed.
Balances are rounded down to whole satoshis and the fee is taken
from the funder's output. Outputs below the signer's dust limit
are removed, as is the signer's own output if lcc_omit_local is
set. Fails if the fee exceeds the funder's balance, or if no
output remains.
Dust thresholds
dust_p2pkh :: Satoshi Source #
Bitcoin Core's P2PKH dust threshold (546 satoshis).
dust_p2wpkh :: Satoshi Source #
Bitcoin Core's P2WPKH dust threshold (294 satoshis).
dust_p2wsh :: Satoshi Source #
Bitcoin Core's P2WSH dust threshold (330 satoshis).
Serialization
commitment_to_tx :: CommitmentTx -> Tx Source #
The unsigned commitment transaction as a ppad-tx Tx (with no
witnesses), e.g. for computing its txid or sighashes.
encode_commitment_tx :: CommitmentTx -> ByteString Source #
Serialize an unsigned commitment transaction, without witness
data. This is the form whose double-SHA256 is the txid; it is not
what segwit signatures commit to (see ppad-tx's
Bitcoin.Prim.Tx.Sighash). To broadcast, attach the witness to
commitment_to_tx and serialize with ppad-tx.
encode_htlc_tx :: HTLCTx -> ByteString Source #
Serialize an unsigned HTLC transaction, without witness data (cf.
encode_commitment_tx).
encode_closing_tx :: ClosingTx -> ByteString Source #
Serialize an unsigned closing transaction, without witness data
(cf. encode_commitment_tx).
Keys
Basepoints and per-commitment points
data Basepoints Source #
The four basepoints a party announces in open_channel or
accept_channel.
Constructors
| Basepoints | |
Instances
| NFData Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: Basepoints -> () # | |||||
| Generic Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> Basepoints -> ShowS # show :: Basepoints -> String # showList :: [Basepoints] -> ShowS # | |||||
| Eq Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Basepoints = D1 ('MetaData "Basepoints" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "Basepoints" 'PrefixI 'True) ((S1 ('MetaSel ('Just "bp_revocation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationBasepoint) :*: S1 ('MetaSel ('Just "bp_payment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PaymentBasepoint)) :*: (S1 ('MetaSel ('Just "bp_delayed_payment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DelayedPaymentBasepoint) :*: S1 ('MetaSel ('Just "bp_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HtlcBasepoint)))) | |||||
newtype RevocationBasepoint Source #
A revocation_basepoint.
Constructors
| RevocationBasepoint Point |
Instances
| NFData RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: RevocationBasepoint -> () # | |||||
| Generic RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: RevocationBasepoint -> Rep RevocationBasepoint x # to :: Rep RevocationBasepoint x -> RevocationBasepoint # | |||||
| Show RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RevocationBasepoint -> ShowS # show :: RevocationBasepoint -> String # showList :: [RevocationBasepoint] -> ShowS # | |||||
| Eq RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (/=) :: RevocationBasepoint -> RevocationBasepoint -> Bool # | |||||
| Ord RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RevocationBasepoint -> RevocationBasepoint -> Ordering # (<) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (<=) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (>) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (>=) :: RevocationBasepoint -> RevocationBasepoint -> Bool # max :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint # min :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint # | |||||
| type Rep RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RevocationBasepoint = D1 ('MetaData "RevocationBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "RevocationBasepoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype PaymentBasepoint Source #
A payment_basepoint.
Constructors
| PaymentBasepoint Point |
Instances
| NFData PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: PaymentBasepoint -> () # | |||||
| Generic PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: PaymentBasepoint -> Rep PaymentBasepoint x # to :: Rep PaymentBasepoint x -> PaymentBasepoint # | |||||
| Show PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> PaymentBasepoint -> ShowS # show :: PaymentBasepoint -> String # showList :: [PaymentBasepoint] -> ShowS # | |||||
| Eq PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (/=) :: PaymentBasepoint -> PaymentBasepoint -> Bool # | |||||
| Ord PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: PaymentBasepoint -> PaymentBasepoint -> Ordering # (<) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (<=) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (>) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (>=) :: PaymentBasepoint -> PaymentBasepoint -> Bool # max :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint # min :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint # | |||||
| type Rep PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep PaymentBasepoint = D1 ('MetaData "PaymentBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "PaymentBasepoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype DelayedPaymentBasepoint Source #
A delayed_payment_basepoint.
Constructors
| DelayedPaymentBasepoint Point |
Instances
| NFData DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: DelayedPaymentBasepoint -> () # | |||||
| Generic DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: DelayedPaymentBasepoint -> Rep DelayedPaymentBasepoint x # to :: Rep DelayedPaymentBasepoint x -> DelayedPaymentBasepoint # | |||||
| Show DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> DelayedPaymentBasepoint -> ShowS # show :: DelayedPaymentBasepoint -> String # showList :: [DelayedPaymentBasepoint] -> ShowS # | |||||
| Eq DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (/=) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # | |||||
| Ord DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Ordering # (<) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (<=) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (>) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (>=) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # max :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> DelayedPaymentBasepoint # min :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> DelayedPaymentBasepoint # | |||||
| type Rep DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep DelayedPaymentBasepoint = D1 ('MetaData "DelayedPaymentBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "DelayedPaymentBasepoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype HtlcBasepoint Source #
An htlc_basepoint.
Constructors
| HtlcBasepoint Point |
Instances
| NFData HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: HtlcBasepoint -> () # | |||||
| Generic HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> HtlcBasepoint -> ShowS # show :: HtlcBasepoint -> String # showList :: [HtlcBasepoint] -> ShowS # | |||||
| Eq HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (/=) :: HtlcBasepoint -> HtlcBasepoint -> Bool # | |||||
| Ord HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: HtlcBasepoint -> HtlcBasepoint -> Ordering # (<) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (<=) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (>) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (>=) :: HtlcBasepoint -> HtlcBasepoint -> Bool # max :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint # min :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint # | |||||
| type Rep HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep HtlcBasepoint = D1 ('MetaData "HtlcBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "HtlcBasepoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype PerCommitmentPoint Source #
A per-commitment point, from which a commitment's keys are derived.
Constructors
| PerCommitmentPoint Point |
Instances
| NFData PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: PerCommitmentPoint -> () # | |||||
| Generic PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: PerCommitmentPoint -> Rep PerCommitmentPoint x # to :: Rep PerCommitmentPoint x -> PerCommitmentPoint # | |||||
| Show PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> PerCommitmentPoint -> ShowS # show :: PerCommitmentPoint -> String # showList :: [PerCommitmentPoint] -> ShowS # | |||||
| Eq PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (/=) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # | |||||
| Ord PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: PerCommitmentPoint -> PerCommitmentPoint -> Ordering # (<) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (<=) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (>) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (>=) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # max :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint # min :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint # | |||||
| type Rep PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep PerCommitmentPoint = D1 ('MetaData "PerCommitmentPoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "PerCommitmentPoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
derive_per_commitment_point :: PerCommitmentSecret -> Maybe PerCommitmentPoint Source #
Derive the per-commitment point from a per-commitment secret:
per_commitment_point = per_commitment_secret * G
Fails if the secret is not a valid secp256k1 secret key.
>>>let Just s = BOLT1.per_commitment_secret (BS.pack [31, 30 .. 0])>>>let Just (PerCommitmentPoint p) = derive_per_commitment_point s>>>B16.encode (BOLT1.un_point p)"025f7117a78150fe2ef97db7cfc83bd57b2e2c0d0dd25eaf467a4a1c2a45ce1486"
derive_per_commitment_point' :: Context -> PerCommitmentSecret -> Maybe PerCommitmentPoint Source #
As derive_per_commitment_point, but uses a precomputed
Context to speed up the scalar multiplication.
Public keys
data CommitmentKeys Source #
The keys a commitment transaction's scripts use.
Constructors
| CommitmentKeys | |
Instances
| NFData CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys Methods rnf :: CommitmentKeys -> () # | |||||
| Generic CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys Associated Types
Methods from :: CommitmentKeys -> Rep CommitmentKeys x # to :: Rep CommitmentKeys x -> CommitmentKeys # | |||||
| Show CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys Methods showsPrec :: Int -> CommitmentKeys -> ShowS # show :: CommitmentKeys -> String # showList :: [CommitmentKeys] -> ShowS # | |||||
| Eq CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys Methods (==) :: CommitmentKeys -> CommitmentKeys -> Bool # (/=) :: CommitmentKeys -> CommitmentKeys -> Bool # | |||||
| type Rep CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys type Rep CommitmentKeys = D1 ('MetaData "CommitmentKeys" "Lightning.Protocol.BOLT3.Keys" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'False) (C1 ('MetaCons "CommitmentKeys" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ck_revocation_pubkey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey) :*: (S1 ('MetaSel ('Just "ck_local_delayed") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalDelayedPubkey) :*: S1 ('MetaSel ('Just "ck_local_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalHtlcPubkey))) :*: ((S1 ('MetaSel ('Just "ck_remote_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RemoteHtlcPubkey) :*: S1 ('MetaSel ('Just "ck_remote_payment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RemotePubkey)) :*: (S1 ('MetaSel ('Just "ck_local_funding") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FundingPubkey) :*: S1 ('MetaSel ('Just "ck_remote_funding") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FundingPubkey))))) | |||||
derive_commitment_keys Source #
Arguments
| :: Basepoints | the owner's basepoints |
| -> FundingPubkey | the owner's funding pubkey |
| -> Basepoints | the other party's basepoints |
| -> FundingPubkey | the other party's funding pubkey |
| -> PerCommitmentPoint | the owner's per-commitment point |
| -> Maybe CommitmentKeys |
Derive the keys for a commitment transaction from both parties' basepoints and funding pubkeys, and the commitment owner's per-commitment point.
The owner is the "local" party: its delayed and HTLC basepoints
give local_delayedpubkey and local_htlcpubkey, while the other
party's revocation and HTLC basepoints give revocationpubkey and
remote_htlcpubkey. As every supported CommitmentFormat uses
option_static_remotekey, remotepubkey is the other party's
payment_basepoint.
Fails if a basepoint it derives a key from, or the per-commitment point, is not on the curve.
derive_commitment_keys' :: Context -> Basepoints -> FundingPubkey -> Basepoints -> FundingPubkey -> PerCommitmentPoint -> Maybe CommitmentKeys Source #
As derive_commitment_keys, but uses a precomputed Context
to speed up the scalar multiplications.
newtype RevocationPubkey Source #
A commitment's revocationpubkey.
Constructors
| RevocationPubkey Point |
Instances
| NFData RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: RevocationPubkey -> () # | |||||
| Generic RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: RevocationPubkey -> Rep RevocationPubkey x # to :: Rep RevocationPubkey x -> RevocationPubkey # | |||||
| Show RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RevocationPubkey -> ShowS # show :: RevocationPubkey -> String # showList :: [RevocationPubkey] -> ShowS # | |||||
| Eq RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: RevocationPubkey -> RevocationPubkey -> Bool # (/=) :: RevocationPubkey -> RevocationPubkey -> Bool # | |||||
| Ord RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RevocationPubkey -> RevocationPubkey -> Ordering # (<) :: RevocationPubkey -> RevocationPubkey -> Bool # (<=) :: RevocationPubkey -> RevocationPubkey -> Bool # (>) :: RevocationPubkey -> RevocationPubkey -> Bool # (>=) :: RevocationPubkey -> RevocationPubkey -> Bool # max :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey # min :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey # | |||||
| type Rep RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RevocationPubkey = D1 ('MetaData "RevocationPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "RevocationPubkey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype LocalDelayedPubkey Source #
A commitment's local_delayedpubkey: the owner's key for its
delayed outputs.
Constructors
| LocalDelayedPubkey Point |
Instances
| NFData LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: LocalDelayedPubkey -> () # | |||||
| Generic LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: LocalDelayedPubkey -> Rep LocalDelayedPubkey x # to :: Rep LocalDelayedPubkey x -> LocalDelayedPubkey # | |||||
| Show LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> LocalDelayedPubkey -> ShowS # show :: LocalDelayedPubkey -> String # showList :: [LocalDelayedPubkey] -> ShowS # | |||||
| Eq LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (/=) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # | |||||
| Ord LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: LocalDelayedPubkey -> LocalDelayedPubkey -> Ordering # (<) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (<=) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (>) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (>=) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # max :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey # min :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey # | |||||
| type Rep LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep LocalDelayedPubkey = D1 ('MetaData "LocalDelayedPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "LocalDelayedPubkey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype LocalHtlcPubkey Source #
A commitment's local_htlcpubkey: the owner's HTLC key.
Constructors
| LocalHtlcPubkey Point |
Instances
| NFData LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: LocalHtlcPubkey -> () # | |||||
| Generic LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: LocalHtlcPubkey -> Rep LocalHtlcPubkey x # to :: Rep LocalHtlcPubkey x -> LocalHtlcPubkey # | |||||
| Show LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> LocalHtlcPubkey -> ShowS # show :: LocalHtlcPubkey -> String # showList :: [LocalHtlcPubkey] -> ShowS # | |||||
| Eq LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (/=) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # | |||||
| Ord LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: LocalHtlcPubkey -> LocalHtlcPubkey -> Ordering # (<) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (<=) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (>) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (>=) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # max :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey # min :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey # | |||||
| type Rep LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep LocalHtlcPubkey = D1 ('MetaData "LocalHtlcPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "LocalHtlcPubkey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype RemoteHtlcPubkey Source #
A commitment's remote_htlcpubkey: the other party's HTLC key.
Constructors
| RemoteHtlcPubkey Point |
Instances
| NFData RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: RemoteHtlcPubkey -> () # | |||||
| Generic RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: RemoteHtlcPubkey -> Rep RemoteHtlcPubkey x # to :: Rep RemoteHtlcPubkey x -> RemoteHtlcPubkey # | |||||
| Show RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RemoteHtlcPubkey -> ShowS # show :: RemoteHtlcPubkey -> String # showList :: [RemoteHtlcPubkey] -> ShowS # | |||||
| Eq RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (/=) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # | |||||
| Ord RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Ordering # (<) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (<=) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (>) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (>=) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # max :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey # min :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey # | |||||
| type Rep RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RemoteHtlcPubkey = D1 ('MetaData "RemoteHtlcPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "RemoteHtlcPubkey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype RemotePubkey Source #
A commitment's remotepubkey: the other party's
payment_basepoint, which its to_remote output pays.
Constructors
| RemotePubkey Point |
Instances
| NFData RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: RemotePubkey -> () # | |||||
| Generic RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RemotePubkey -> ShowS # show :: RemotePubkey -> String # showList :: [RemotePubkey] -> ShowS # | |||||
| Eq RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RemotePubkey -> RemotePubkey -> Ordering # (<) :: RemotePubkey -> RemotePubkey -> Bool # (<=) :: RemotePubkey -> RemotePubkey -> Bool # (>) :: RemotePubkey -> RemotePubkey -> Bool # (>=) :: RemotePubkey -> RemotePubkey -> Bool # max :: RemotePubkey -> RemotePubkey -> RemotePubkey # min :: RemotePubkey -> RemotePubkey -> RemotePubkey # | |||||
| type Rep RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RemotePubkey = D1 ('MetaData "RemotePubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "RemotePubkey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype FundingPubkey Source #
A funding_pubkey.
Constructors
| FundingPubkey Point |
Instances
| NFData FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: FundingPubkey -> () # | |||||
| Generic FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> FundingPubkey -> ShowS # show :: FundingPubkey -> String # showList :: [FundingPubkey] -> ShowS # | |||||
| Eq FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: FundingPubkey -> FundingPubkey -> Bool # (/=) :: FundingPubkey -> FundingPubkey -> Bool # | |||||
| Ord FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: FundingPubkey -> FundingPubkey -> Ordering # (<) :: FundingPubkey -> FundingPubkey -> Bool # (<=) :: FundingPubkey -> FundingPubkey -> Bool # (>) :: FundingPubkey -> FundingPubkey -> Bool # (>=) :: FundingPubkey -> FundingPubkey -> Bool # max :: FundingPubkey -> FundingPubkey -> FundingPubkey # min :: FundingPubkey -> FundingPubkey -> FundingPubkey # | |||||
| type Rep FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep FundingPubkey = D1 ('MetaData "FundingPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "FundingPubkey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
derive_pubkey :: Point -> PerCommitmentPoint -> Maybe Point Source #
Derive a per-commitment public key from a basepoint:
pubkey = basepoint + SHA256(per_commitment_point || basepoint) * G
This gives local_htlcpubkey, remote_htlcpubkey,
local_delayedpubkey and the like, depending on the basepoint;
derive_commitment_keys derives all of a commitment's keys at
once.
Fails if the basepoint is not on the curve.
>>>let Just s = BOLT1.per_commitment_secret (BS.pack [31, 30 .. 0])>>>let Just pcp = derive_per_commitment_point s>>>let Just b = BOLT1.per_commitment_secret (BS.pack [0 .. 31])>>>let Just (PerCommitmentPoint bp) = derive_per_commitment_point b>>>fmap (B16.encode . BOLT1.un_point) (derive_pubkey bp pcp)Just "0235f2dbfaa89b57ec7b055afe29849ef7ddfeb1cefdb9ebdc43f5494984db29e5"
derive_revocationpubkey :: RevocationBasepoint -> PerCommitmentPoint -> Maybe RevocationPubkey Source #
Derive a commitment's revocationpubkey from the revocation
basepoint of the party that will hold the revocation key, and the
commitment owner's per-commitment point:
revocationpubkey =
revocation_basepoint
* SHA256(revocation_basepoint || per_commitment_point)
+ per_commitment_point
* SHA256(per_commitment_point || revocation_basepoint)
Fails if either point is not on the curve.
>>>let Just s = BOLT1.per_commitment_secret (BS.pack [31, 30 .. 0])>>>let Just pcp = derive_per_commitment_point s>>>let Just b = BOLT1.per_commitment_secret (BS.pack [0 .. 31])>>>let Just (PerCommitmentPoint p) = derive_per_commitment_point b>>>let Just r = derive_revocationpubkey (RevocationBasepoint p) pcp>>>(\(RevocationPubkey k) -> B16.encode (BOLT1.un_point k)) r"02916e326636d19c33f13e8c0c3a03dd157f332f3e99c317c141dd865eb01f8ff0"
Private keys
seckey :: ByteString -> Maybe Seckey Source #
Construct a Seckey from 32 big-endian bytes. Fails unless the
bytes encode an integer in [1, n).
>>>fmap (BS.length . un_seckey) (seckey (BS.replicate 32 0x01))Just 32>>>seckey (BS.replicate 32 0x00)Nothing>>>seckey (BS.replicate 32 0xff)Nothing
derive_privkey :: Seckey -> PerCommitmentPoint -> Maybe Seckey Source #
Derive the private key for a per-commitment public key from its basepoint secret:
privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)
where basepoint = basepoint_secret * G. The result is the secret
key for .derive_pubkey basepoint per_commitment_point
The arithmetic on the secret is constant-time. Fails (with negligible probability) if the result is zero.
>>>let Just s = BOLT1.per_commitment_secret (BS.pack [31, 30 .. 0])>>>let Just pcp = derive_per_commitment_point s>>>let Just k = seckey (BS.pack [0 .. 31])>>>fmap (B16.encode . un_seckey) (derive_privkey k pcp)Just "cbced912d3b21bf196a766651e436aff192362621ce317704ea2f75d87e7be0f"
derive_revocationprivkey Source #
Arguments
| :: Seckey | revocation basepoint secret |
| -> PerCommitmentSecret | per-commitment secret |
| -> Maybe Seckey |
Derive a commitment's revocationprivkey from the revocation
basepoint secret and the commitment's (revealed) per-commitment
secret:
revocationprivkey =
revocation_basepoint_secret
* SHA256(revocation_basepoint || per_commitment_point)
+ per_commitment_secret
* SHA256(per_commitment_point || revocation_basepoint)
The result is the secret key for the derive_revocationpubkey
of the corresponding points.
The arithmetic on the secrets is constant-time. Fails if the per-commitment secret is not a valid secret key, or (with negligible probability) if the result is zero.
>>>let Just s = BOLT1.per_commitment_secret (BS.pack [31, 30 .. 0])>>>let Just k = seckey (BS.pack [0 .. 31])>>>fmap (B16.encode . un_seckey) (derive_revocationprivkey k s)Just "d09ffff62ddb2297ab000cc85bcb4283fdeb6aa052affbc9dddcf33b61078110"
Per-commitment secrets
seed :: ByteString -> Maybe Seed Source #
Construct a Seed from exactly 32 bytes.
>>>fmap (BS.length . un_seed) (seed (BS.replicate 32 0xff))Just 32>>>seed (BS.replicate 31 0xff)Nothing
data SecretIndex Source #
The 48-bit index I of a per-commitment secret. Secrets are used from index 2^48 - 1 downwards.
Instances
| NFData SecretIndex Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods rnf :: SecretIndex -> () # | |||||
| Generic SecretIndex Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show SecretIndex Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> SecretIndex -> ShowS # show :: SecretIndex -> String # showList :: [SecretIndex] -> ShowS # | |||||
| Eq SecretIndex Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord SecretIndex Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: SecretIndex -> SecretIndex -> Ordering # (<) :: SecretIndex -> SecretIndex -> Bool # (<=) :: SecretIndex -> SecretIndex -> Bool # (>) :: SecretIndex -> SecretIndex -> Bool # (>=) :: SecretIndex -> SecretIndex -> Bool # max :: SecretIndex -> SecretIndex -> SecretIndex # min :: SecretIndex -> SecretIndex -> SecretIndex # | |||||
| type Rep SecretIndex Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep SecretIndex = D1 ('MetaData "SecretIndex" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "SecretIndex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) | |||||
secret_index :: Word64 -> Maybe SecretIndex Source #
Construct a SecretIndex. Fails at or above 2^48.
>>>secret_index 281474976710655Just (SecretIndex 281474976710655)>>>secret_index 281474976710656Nothing
un_secret_index :: SecretIndex -> Word64 Source #
The value of a SecretIndex.
commitment_secret_index :: CommitmentNumber -> SecretIndex Source #
The index of the per-commitment secret for a commitment number: 2^48 - 1 - n.
>>>fmap commitment_secret_index (commitment_number 0)Just (SecretIndex 281474976710655)
generate_from_seed :: Seed -> SecretIndex -> PerCommitmentSecret Source #
Generate the per-commitment secret with a given index from a seed,
per BOLT #3's generate_from_seed.
>>>let Just s = seed (BS.replicate 32 0xff)>>>let Just i = secret_index 281474976710655>>>B16.encode (BOLT1.un_per_commitment_secret (generate_from_seed s i))"7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc"
Storage
data SecretStore Source #
Compact storage for the per-commitment secrets received from a peer, per BOLT #3's "Efficient Per-commitment Secret Storage".
Holds at most 49 secrets, from which every secret received so far
can be derived. This is secret material: its Show instance is
redacted, and it has no Eq instance.
Instances
| NFData SecretStore Source # | |
Defined in Lightning.Protocol.BOLT3.Keys Methods rnf :: SecretStore -> () # | |
| Show SecretStore Source # | |
Defined in Lightning.Protocol.BOLT3.Keys Methods showsPrec :: Int -> SecretStore -> ShowS # show :: SecretStore -> String # showList :: [SecretStore] -> ShowS # | |
empty_secret_store :: SecretStore Source #
The empty SecretStore.
insert_secret :: PerCommitmentSecret -> SecretIndex -> SecretStore -> Maybe SecretStore Source #
Add a newly received per-commitment secret to the store, per
BOLT #3's insert_secret.
Fails if a stored secret cannot be derived from the new one, i.e. if the secrets were not generated from the same seed (or were not received in order).
>>>let Just s = seed (BS.replicate 32 0xff)>>>let Just i = secret_index 281474976710655>>>let secret = generate_from_seed s i>>>let Just st = insert_secret secret i empty_secret_store>>>fmap (== secret) (derive_old_secret i st)Just True
derive_old_secret :: SecretIndex -> SecretStore -> Maybe PerCommitmentSecret Source #
Derive a previously received per-commitment secret from the store. Fails if the index has not been received.
secret_store :: [(SecretIndex, PerCommitmentSecret)] -> Maybe SecretStore Source #
Rebuild a SecretStore from its entries, e.g. as produced by
un_secret_store.
Fails if two entries share a bucket (i.e. their indices have the same number of trailing zeros), or if an entry contradicts another from which it can be derived.
un_secret_store :: SecretStore -> [(SecretIndex, PerCommitmentSecret)] Source #
The entries of a SecretStore, for persistence; see
secret_store.
Commitment number obscuring
obscured_commitment_number Source #
Arguments
| :: PaymentBasepoint | opener's payment_basepoint |
| -> PaymentBasepoint | accepter's payment_basepoint |
| -> CommitmentNumber | |
| -> Word64 |
Obscure a commitment number, by XOR with the lower 48 bits of
SHA256(payment_basepoint from open_channel
|| payment_basepoint from accept_channel)As XOR is an involution, applying this to an obscured number
recovers the commitment number. (build_commitment_tx obscures
the commitment number itself.)
>>>let pay h = fmap PaymentBasepoint (BOLT1.point =<< B16.decode h)>>>let o1 = "034f355bdcb7cc0af728ef3cceb9615d9068">>>let Just o = pay (o1 <> "4bb5b2ca5f859ab0f0b704075871aa")>>>let a1 = "032c0b7cf95324a07d05398b240174dc0c2b">>>let Just a = pay (a1 <> "e444d96b159aa6c7f7b1e668680991")>>>fmap (obscured_commitment_number o a) (commitment_number 42)Just 48035859142974
Scripts and witnesses
A serialized Bitcoin script.
Constructors
| Script ByteString |
Instances
| NFData Script Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Generic Script Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Script Source # | |||||
| Eq Script Source # | |||||
| Ord Script Source # | |||||
| type Rep Script Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Script = D1 ('MetaData "Script" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.1.1-xuvWUaIZwC11qDxWpk94k" 'True) (C1 ('MetaCons "Script" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
to_p2wsh :: Script -> Script Source #
The P2WSH scriptPubKey for a witness script:
0 <SHA256(script)>.
Funding output
funding_script :: FundingPubkey -> FundingPubkey -> Script Source #
The funding output's witness script:
2 <pubkey1> <pubkey2> 2 OP_CHECKMULTISIG
where pubkey1 is the lexicographically lesser of the two funding
pubkeys. The argument order doesn't matter.
funding_witness :: FundingPubkey -> ByteString -> FundingPubkey -> ByteString -> Witness Source #
The witness spending the funding output, given each party's funding pubkey and signature (DER-encoded, with sighash byte):
0 <signature_for_pubkey1> <signature_for_pubkey2> <script>
The signatures are ordered to match the pubkeys in
funding_script, so the argument order doesn't matter.
to_local output
to_local_script :: RevocationPubkey -> ToSelfDelay -> LocalDelayedPubkey -> Script Source #
The to_local output's witness script:
OP_IF
<revocationpubkey>
OP_ELSE
<to_self_delay> OP_CHECKSEQUENCEVERIFY OP_DROP
<local_delayedpubkey>
OP_ENDIF
OP_CHECKSIG
HTLC-success and HTLC-timeout transaction outputs use the same script.
to_local_witness_spend :: ByteString -> Script -> Witness Source #
The witness for the owner's delayed spend of a to_local (or
HTLC transaction) output, given its witness script:
<local_delayedsig> <> <script>
The spending input's nSequence must be to_self_delay.
to_local_witness_revoke :: ByteString -> Script -> Witness Source #
The witness for the revocation spend of a to_local (or HTLC
transaction) output, given its witness script:
<revocation_sig> 1 <script>
to_remote output
to_remote_witness_script :: RemotePubkey -> Script Source #
The to_remote output's witness script under Anchors:
<remotepubkey> OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY
(Under StaticRemotekey the output is P2WPKH, with no witness
script; see to_remote_script_pubkey.)
to_remote_script_pubkey :: RemotePubkey -> CommitmentFormat -> Script Source #
The to_remote output's scriptPubKey: P2WPKH to remotepubkey
under StaticRemotekey, and P2WSH of to_remote_witness_script
under Anchors.
to_remote_witness :: ByteString -> RemotePubkey -> CommitmentFormat -> Witness Source #
The witness spending a to_remote output: <remote_sig>
<remotepubkey> (P2WPKH) under StaticRemotekey, and
<remote_sig> <script> under Anchors, where the spending
input's nSequence must be 1.
Anchor outputs
anchor_script :: FundingPubkey -> Script Source #
An anchor output's witness script, for the funding pubkey of the party it belongs to:
<funding_pubkey> OP_CHECKSIG OP_IFDUP
OP_NOTIF
OP_16 OP_CHECKSEQUENCEVERIFY
OP_ENDIF
anchor_witness_owner :: ByteString -> FundingPubkey -> Witness Source #
The witness for an anchor's owner to spend it:
<sig> <script>.
anchor_witness_anyone :: FundingPubkey -> Witness Source #
The witness for anyone to sweep an anchor, 16 blocks after the
commitment transaction confirms: <> <script>.
Offered HTLC outputs
offered_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> CommitmentFormat -> Script Source #
An offered HTLC output's witness script:
OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
OP_IF
OP_CHECKSIG
OP_ELSE
<remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
OP_NOTIF
OP_DROP 2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG
OP_ELSE
OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
OP_CHECKSIG
OP_ENDIF
OP_ENDIF
Under Anchors, 1 OP_CHECKSEQUENCEVERIFY OP_DROP precedes the
final OP_ENDIF.
offered_htlc_witness_preimage :: ByteString -> PaymentPreimage -> Script -> Witness Source #
The witness for the remote party to claim an offered HTLC output with the payment preimage, given its witness script:
<remotehtlcsig> <payment_preimage> <script>
Under Anchors the spending input's nSequence must be 1.
offered_htlc_witness_revoke :: ByteString -> RevocationPubkey -> Script -> Witness Source #
The witness for the revocation spend of an offered HTLC output, given its witness script:
<revocation_sig> <revocationpubkey> <script>
Received HTLC outputs
received_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> CltvExpiry -> CommitmentFormat -> Script Source #
A received HTLC output's witness script:
OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
OP_IF
OP_CHECKSIG
OP_ELSE
<remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
OP_IF
OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG
OP_ELSE
OP_DROP <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP
OP_CHECKSIG
OP_ENDIF
OP_ENDIF
Under Anchors, 1 OP_CHECKSEQUENCEVERIFY OP_DROP precedes the
final OP_ENDIF.
received_htlc_witness_timeout :: ByteString -> Script -> Witness Source #
The witness for the remote party to time out a received HTLC output, given its witness script:
<remotehtlcsig> <> <script>
Under Anchors the spending input's nSequence must be 1.
received_htlc_witness_revoke :: ByteString -> RevocationPubkey -> Script -> Witness Source #
The witness for the revocation spend of a received HTLC output, given its witness script:
<revocation_sig> <revocationpubkey> <script>
HTLC transaction inputs
Arguments
| :: ByteString | remotehtlcsig |
| -> ByteString | localhtlcsig |
| -> PaymentPreimage | |
| -> Script | the received HTLC output's witness script |
| -> Witness |
The witness for an HTLC-success transaction's input, given both HTLC signatures, the payment preimage and the received HTLC output's witness script:
0 <remotehtlcsig> <localhtlcsig> <payment_preimage> <script>
See remote_htlc_sighash for the signatures' sighash types.
Arguments
| :: ByteString | remotehtlcsig |
| -> ByteString | localhtlcsig |
| -> Script | the offered HTLC output's witness script |
| -> Witness |
The witness for an HTLC-timeout transaction's input, given both HTLC signatures and the offered HTLC output's witness script:
0 <remotehtlcsig> <localhtlcsig> <> <script>
See remote_htlc_sighash for the signatures' sighash types.
remote_htlc_sighash :: CommitmentFormat -> SighashType Source #
The sighash type of remotehtlcsig: the signature on an
HTLC-success or HTLC-timeout transaction that the commitment's
non-owner sends in commitment_signed.
Under Anchors it is SIGHASH_SINGLE|SIGHASH_ANYONECANPAY, so
that the owner can add inputs and outputs to pay the (otherwise
zero) fee; under StaticRemotekey it is SIGHASH_ALL. The
owner's own signature, localhtlcsig, always uses SIGHASH_ALL.
>>>remote_htlc_sighash AnchorsSIGHASH_SINGLE_ANYONECANPAY