Skip to content

Conversation

@ladamesny
Copy link
Contributor

@ladamesny ladamesny commented Dec 12, 2025

Description

Improves the multisig workflow by eliminating the need for manual jq extraction of transaction CBOR hex. Adds an optional --out-file parameter to governed-map commands and enhances sign-tx to accept multiple input formats.

Changes

1. Added --out-file to governed-map commands

  • New optional parameter for insert, update, and remove commands
  • Automatically extracts and saves cborHex to the specified file during multisig flows
  • Prints success message to stderr when file is written
  • Returns explicit error if --out-file specified but cborHex unavailable

2. Enhanced sign-tx input handling

  • Now accepts three input formats:
    • Direct hex string (existing behavior)
    • Full transaction_to_sign JSON string
    • Path to JSON file containing transaction data
  • Added extract_cbor_hex() with deterministic parsing order (file → JSON → hex)
  • Improved help text to clarify accepted formats

3. Code quality improvements

  • Uses PathBuf instead of String for file paths (type safety)
  • Added clap::ValueHint::FilePath for better shell autocompletion
  • Better error messages and user feedback

Example Usage

# Save transaction CBOR to file
./partner-chains-node smart-contracts governed-map insert \
  --genesis-utxo <UTXO> \
  --ogmios-url ws://localhost:1337 \
  --payment-key-file key.skey \
  --key "my-key" \
  --value 0x1234 \
  --out-file tx.cbor

# Sign using the saved file directly
./partner-chains-node smart-contracts sign-tx \
  --transaction tx.cbor \
  --payment-key-file key.skey

Checklist

  • Commit sequence broadly makes sense and commits have useful messages.
  • The size limit of 400 LOC isn't needlessly exceeded
  • The PR refers to a JIRA ticket (if one exists)
  • New tests are added if needed and existing tests are updated.
  • New code is documented and existing documentation is updated.
  • Relevant logging and metrics added
  • Any changes are noted in the changelog.md for affected crate
  • Self-reviewed the diff

@ladamesny ladamesny force-pushed the enhancement/option-to-save-tx-cbor branch from af22be3 to 40a10b4 Compare December 15, 2025 21:19
@ladamesny ladamesny changed the title enhancement: add option to save transaction to be signed output to a … Improve multisig UX: Add --out-file parameter and enhance sign-tx Dec 15, 2025
@ladamesny ladamesny marked this pull request as ready for review December 15, 2025 21:46
@ladamesny ladamesny self-assigned this Dec 15, 2025
{
// Extract cborHex from the serialized transaction
let tx_json = serde_json::to_value(&tx_data.tx)?;
if let Some(cbor_hex) = tx_json.get("cborHex").and_then(|v| v.as_str()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have tx_data.tx that are bytes. Then you serialized it Cardano file JSON and then you take this field containing bytes of the transaction instead of using it directly.

You could just hex::encode(tx_data.tx), couldn't you?

// Try to extract cborHex from transaction_to_sign format
if let Some(cbor_hex) = json_value
.get("transaction_to_sign")
.and_then(|v| v.get("tx"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A this point I would parse MultiSigTransactionData instead of manually traversing its format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants