mkSpendOutputsOnlyTx should support reference scripts on key addresses

Open Beginner friendly
#6,522 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
haskell
Domain
cli, testing-qa

Research direction

Start in Testnet.Process.Cli.Transaction at mkSpendOutputsOnlyTx and inspect how computeTxOuts builds arguments for PubKeyAddress and ScriptAddress. Compare the two branches and run the relevant transaction helper tests. Done means an optional reference script is handled for both output address types without changing existing behavior.

Written by the indexing model from the issue text.

Description

Summary

mkSpendOutputsOnlyTx in Testnet.Process.Cli.Transaction currently only attaches reference scripts (--tx-out-reference-script-file) to ScriptAddress outputs. The PubKeyAddress branch ignores the Maybe (File ScriptJSON In) parameter entirely.

This means publishing a reference script at a regular payment key address requires building the transaction manually with execCli' instead of using the helper.

Expected behavior

Both PubKeyAddress and ScriptAddress outputs should support the optional reference script attachment.

Current code

computeTxOuts =
    concat <$> sequence
      [ case txOut of
          PubKeyAddress dstWallet ->
            -- reference script parameter is ignored here
            return ["--tx-out", T.unpack (paymentKeyInfoAddr dstWallet) <> "+" ++ show (unCoin amount)]
          ScriptAddress (File referenceScriptJSON) -> do
            ...
            return
              ( ["--tx-out", scriptAddress <> "+" ++ show (unCoin amount)]
                  <> maybe [] (\(File newRefScript) -> ["--tx-out-reference-script-file", newRefScript]) mNewRefScript
              )
      | (txOut, amount, mNewRefScript) <- txOutputs
      ]

Suggested fix

Add the --tx-out-reference-script-file handling to the PubKeyAddress branch as well.

Dominant language
Haskell
Stars
3.2k
Forks
755
Avg merge
2d 12h
Merged PRs (30d)
18

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntersectMBO/cardano-node

All issues in IntersectMBO/cardano-node

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.