bolt2

Lightning peer protocol, per BOLT #2 (docs.ppad.tech/bolt2).
git clone git://git.ppad.tech/bolt2.git
Log | Files | Refs | README | LICENSE

commit b5a418e2a368f1679308eae89e4d1de5c7b33756
parent f84719d71237c071037dd9430b2f48b58ef801a1
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat, 10 Oct 2026 19:15:54 +0400

Merge meta/tx-api: follow ppad-tx's API changes

ppad-tx 0.2.0 makes TxId abstract (mk_txid, un_txid) and moves each
input's witness into TxIn.

Diffstat:
Mbench/Fixtures.hs | 2+-
Mflake.lock | 8++++----
Mlib/Lightning/Protocol/BOLT2/Codec.hs | 10+++++-----
Mtest/Main.hs | 4++--
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bench/Fixtures.hs b/bench/Fixtures.hs @@ -49,7 +49,7 @@ fixtures = do pts <- traverse (\b -> BOLT1.point (BS.cons 0x02 (BS.replicate 32 b))) [0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77] sig <- BOLT1.signature (BS.replicate 64 0xa1) - txid <- Tx.mkTxId (BS.replicate 32 0x7e) + txid <- Tx.mk_txid (BS.replicate 32 0x7e) spk <- script_pubkey ("\x00\x14" <> BS.replicate 20 0x88) fund <- BOLT1.satoshi 1000000 dust <- BOLT1.satoshi 546 diff --git a/flake.lock b/flake.lock @@ -279,11 +279,11 @@ "ppad-sha256": "ppad-sha256" }, "locked": { - "lastModified": 1791643261, - "narHash": "sha256-Zng+Z6E1NnsDGTvL8MQuRiMaJlm4TPOfdLV2Jhe9u4g=", + "lastModified": 1791644539, + "narHash": "sha256-Ap1kEJmNrO+8bw6IWhnWiIKewRIad2MCjyPdGMUDxDs=", "ref": "master", - "rev": "25defad8bbaddc05c969872947968e2de35be3fe", - "revCount": 38, + "rev": "0f09078de350d0965f1039ac39b26f288530742b", + "revCount": 42, "type": "git", "url": "git://git.ppad.tech/tx.git" }, diff --git a/lib/Lightning/Protocol/BOLT2/Codec.hs b/lib/Lightning/Protocol/BOLT2/Codec.hs @@ -82,7 +82,7 @@ module Lightning.Protocol.BOLT2.Codec ( , decode_channel_reestablish ) where -import Bitcoin.Prim.Tx (TxId(..), mkTxId) +import Bitcoin.Prim.Tx (TxId, mk_txid, un_txid) import Control.DeepSeq (NFData) import qualified Data.ByteString as BS import qualified Data.ByteString.Unsafe as BU @@ -251,7 +251,7 @@ milli_satoshi = do {-# INLINE milli_satoshi #-} txid :: Parser TxId -txid = sized 32 mkTxId +txid = sized 32 mk_txid {-# INLINE txid #-} htlc_id :: Parser HtlcId @@ -338,7 +338,7 @@ tlv_fee_range v = do tlv_next_funding :: BS.ByteString -> Maybe NextFunding tlv_next_funding v | BS.length v == 33 = do - t <- mkTxId (BU.unsafeTake 32 v) + t <- mk_txid (BU.unsafeTake 32 v) pure (NextFunding t (BU.unsafeIndex v 32)) | otherwise = Nothing @@ -365,7 +365,7 @@ count_prefix xs {-# INLINE count_prefix #-} txid_bytes :: TxId -> BS.ByteString -txid_bytes (TxId b) = b +txid_bytes = un_txid {-# INLINE txid_bytes #-} word8 :: Word8 -> BS.ByteString @@ -1320,7 +1320,7 @@ decode_commitment_signed = parse $ do n <- u16 sigs <- count (fromIntegral n) signature s <- tlvs commitment_signed_known - fund <- record 1 mkTxId s + fund <- record 1 mk_txid s pure (CommitmentSigned cid sig sigs fund (unknown commitment_signed_known s)) -- revoke_and_ack, update_fee ------------------------------------------------- diff --git a/test/Main.hs b/test/Main.hs @@ -138,7 +138,7 @@ f_sig :: String -> Maybe BOLT1.Signature f_sig h = BOLT1.signature =<< hx h f_txid :: Maybe Tx.TxId -f_txid = Tx.mkTxId =<< hx txid_h +f_txid = Tx.mk_txid =<< hx txid_h f_secret :: Maybe BOLT1.PerCommitmentSecret f_secret = BOLT1.per_commitment_secret =<< hx secret_h @@ -996,7 +996,7 @@ gen_sig :: Gen BOLT1.Signature gen_sig = gen_bytes 64 `suchThatMap` BOLT1.signature gen_txid :: Gen Tx.TxId -gen_txid = gen_bytes 32 `suchThatMap` Tx.mkTxId +gen_txid = gen_bytes 32 `suchThatMap` Tx.mk_txid gen_secret :: Gen BOLT1.PerCommitmentSecret gen_secret = gen_bytes 32 `suchThatMap` BOLT1.per_commitment_secret