feat(5288): script-witness parity in Transaction.Ledger
Extend the ledger-native transaction builder
(`Cardano.Wallet.Shelley.Transaction.Ledger`) so it accepts every
script-witness shape currently consumed by the legacy
`Cardano.Wallet.Shelley.Transaction.mkUnsignedTx`:
* native-script spending witnesses (`Map TxIn (Script KeyHash)`),
* an optional staking script for withdrawals / certificates,
* mint/burn `ScriptSource` values (local script and reference
input), and
* an output-attached reference script.
A new record `ScriptWitnesses` carries the four fields through
`buildLedgerTx` and `buildLedgerTxRaw` with a defaultable
`noScriptWitnesses` value; the two production call sites in this
module (`mkTransaction`, `constructUnsignedTxLedger`) and the three
pre-existing test call sites in `ledgerMintPlumbingSpec'` pass
`noScriptWitnesses` and remain behaviourally unchanged. The new
helper `installScriptWitnesses` sets the matching ledger lenses:
`referenceInputsTxBodyL` from `Right (ReferenceInput …)` mint
sources, the first-output `referenceScriptTxOutL` from
`swReferenceScript`, and `witsTxL . scriptTxWitsL` from
`swNativeInputs` values, `swStakingScript`, and local mint scripts
deduplicated to one witness per token policy id to match the legacy
`TxMintValue` merge.
A new `describe "ledger script-witness parity"` block in
`TransactionLedgerSpec` proves byte-for-byte equality between the
legacy and new builders in the recent era (Conway) across six
enumerated scenarios (US1 acceptance criteria 1-6 from spec.md)
and one bounded QuickCheck property
(`prop_buildLedgerTx_matches_mkUnsignedTx_on_script_witnesses`,
`withMaxSuccess 100`) that mixes random selections, mint sources,
staking scripts, and output reference scripts. Each comparison
asserts both body-CBOR equality (`serialize (eraProtVerLow @Conway)
(tx ^. bodyTxL)`) and witness-set equality
(`tx ^. witsTxL . scriptTxWitsL`). The legacy body is lifted to a
ledger `Tx Conway` via `fromCardanoApiTx . Cardano.makeSignedTransaction []`.
Dijkstra remains `pendingWith "TODO: Dijkstra"` (per #5209).
Plutus scripts remain out of scope. `mkUnsignedTx` and
`mkUnsignedTransaction` are unchanged.
Spec: specs/008-script-witness-parity/{spec,plan,data-model,research,quickstart}.md
Tasks: T010, T011, T012, T013