commit 9fe981110faec0b53206fcc8ef0496cb54ed848a
parent 19f6c064afa9b88faf67374fd8436ea4577dc327
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 18 Apr 2026 21:45:51 +0800
remove vestigial unTxId and txIdLen
Both duplicate ppad-tx functionality. Callers now pattern-match
on TxId directly and use the literal 32 for length.
Diffstat:
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/lib/Lightning/Protocol/BOLT2/Codec.hs b/lib/Lightning/Protocol/BOLT2/Codec.hs
@@ -194,7 +194,7 @@ decodeTxIdBytes
:: BS.ByteString -> Either DecodeError (TxId, BS.ByteString)
decodeTxIdBytes !bs = do
(raw, rest) <- maybe (Left DecodeInsufficientBytes) Right
- (decodeBytes txIdLen bs)
+ (decodeBytes 32 bs)
tid <- maybe (Left DecodeInvalidTxId) Right (mkTxId raw)
Right (tid, rest)
{-# INLINE decodeTxIdBytes #-}
@@ -497,7 +497,7 @@ decodeAcceptChannel !bs = do
encodeFundingCreated :: FundingCreated -> BS.ByteString
encodeFundingCreated !msg = mconcat
[ unChannelId (fundingCreatedTempChannelId msg)
- , unTxId (fundingCreatedFundingTxid msg)
+ , let (TxId bs) = fundingCreatedFundingTxid msg in bs
, encodeU16 (fundingCreatedFundingOutIdx msg)
, unSignature (fundingCreatedSignature msg)
]
@@ -1019,7 +1019,7 @@ encodeTxSignatures !msg = do
encodedWits <- traverse encodeWitnessE witnesses
Right $! mconcat $
[ unChannelId (txSignaturesChannelId msg)
- , unTxId (txSignaturesTxid msg)
+ , let (TxId bs) = txSignaturesTxid msg in bs
, encodeU16 numWit
] ++ encodedWits
diff --git a/lib/Lightning/Protocol/BOLT2/Types.hs b/lib/Lightning/Protocol/BOLT2/Types.hs
@@ -47,7 +47,6 @@ module Lightning.Protocol.BOLT2.Types (
-- * Transaction types
, TxId(..)
, mkTxId
- , unTxId
, OutPoint(..)
, ScriptPubKey
, scriptPubKey
@@ -75,7 +74,6 @@ module Lightning.Protocol.BOLT2.Types (
, channelIdLen
, signatureLen
, pointLen
- , txIdLen
, chainHashLen
, shortChannelIdLen
, paymentHashLen
@@ -108,11 +106,6 @@ pointLen :: Int
pointLen = 33
{-# INLINE pointLen #-}
--- | Length of a transaction ID in bytes (32).
-txIdLen :: Int
-txIdLen = 32
-{-# INLINE txIdLen #-}
-
-- | Length of a chain hash in bytes (32).
chainHashLen :: Int
chainHashLen = 32
@@ -324,11 +317,6 @@ unSecret (Secret bs) = bs
-- transaction types -----------------------------------------------------------
--- | Extract the underlying 'BS.ByteString' from a 'TxId'.
-unTxId :: TxId -> BS.ByteString
-unTxId (TxId bs) = bs
-{-# INLINE unTxId #-}
-
-- | A script pubkey (output script).
--
-- Variable length; used in shutdown messages, closing transactions, etc.