commit 2918e786adc17000c5a31e8dbf9c9fbcead30aa6
parent b6e391b34782eb811aa4819cde71e1134fc8d2f0
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 10 Oct 2026 19:16:00 +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:
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/bench/Fixtures.hs b/bench/Fixtures.hs
@@ -104,7 +104,7 @@ build = do
txid <- hex
"8984484a580b825b9972d7adb15050b3ab624ccd731946b3eeddb92f4e7ef6be"
- let outpoint = BT.OutPoint (BT.TxId (BS.reverse txid)) 0
+ outpoint <- (\t -> BT.OutPoint t 0) <$> BT.mk_txid (BS.reverse txid)
cn <- commitment_number 42
dust <- DustLimit <$> BOLT1.satoshi 546
to_local <- BOLT1.milli_satoshi 6988000000
diff --git a/flake.lock b/flake.lock
@@ -529,11 +529,11 @@
]
},
"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/BOLT3/Tx.hs b/lib/Lightning/Protocol/BOLT3/Tx.hs
@@ -521,9 +521,8 @@ unsigned_tx
-> BT.Tx
unsigned_tx version (Locktime lt) prevout (Sequence sq) outs = BT.Tx
{ BT.tx_version = version
- , BT.tx_inputs = BT.TxIn prevout BS.empty sq :| []
+ , BT.tx_inputs = BT.TxIn prevout BS.empty sq (BT.Witness []) :| []
, BT.tx_outputs = outs
- , BT.tx_witnesses = []
, BT.tx_locktime = lt
}
diff --git a/test/Main.hs b/test/Main.hs
@@ -360,7 +360,7 @@ fundingTests = testGroup "Funding transaction (Appendix B)" [
(lpk, rpk) <- fundingPubkeys
tx <- hex b_funding_tx >>= decodeTx
txid <- hex b_funding_txid
- BT.txid tx @?= BT.TxId (BS.reverse txid)
+ BT.un_txid (BT.txid tx) @?= BS.reverse txid
case drop (fromIntegral b_funding_output) (NE.toList (BT.tx_outputs tx))
of
(BT.TxOut value spk : _) -> do
@@ -382,9 +382,9 @@ decodeTx = need "undecodable transaction" . BT.from_bytes
-- | The single input's witness stack of a spec transaction.
witnessOf :: BT.Tx -> IO [BS.ByteString]
-witnessOf tx = case BT.tx_witnesses tx of
- [BT.Witness items] -> pure items
- _ -> assertFailure "expected one witness"
+witnessOf tx = case NE.toList (BT.tx_inputs tx) of
+ [i] | BT.Witness items <- BT.txin_witness i -> pure items
+ _ -> assertFailure "expected one input"
-- | A test HTLC from the Appendix C parameters.
testHtlc :: Int -> IO HTLC
@@ -432,7 +432,8 @@ vectorKeys = do
vectorOutpoint :: IO BT.OutPoint
vectorOutpoint = do
txid <- hex c_funding_txid
- pure (BT.OutPoint (BT.TxId (BS.reverse txid)) c_funding_output_index)
+ t <- need "invalid txid" (BT.mk_txid (BS.reverse txid))
+ pure (BT.OutPoint t c_funding_output_index)
-- | The commitment context for a vector: local's commitment, with local
-- as the opener.