Skip to content

Multi-Transaction Signing for SignTransaction#551

Open
mraveux wants to merge 5 commits intomasterfrom
matheo/multi-tx-sign
Open

Multi-Transaction Signing for SignTransaction#551
mraveux wants to merge 5 commits intomasterfrom
matheo/multi-tx-sign

Conversation

@mraveux
Copy link
Copy Markdown
Member

@mraveux mraveux commented Mar 29, 2026

Summary

  • Extends the SignTransaction request to accept multiple transactions (TransactionData[] or Uint8Array[]) that are signed with a single password entry, enabling batch operations like combined staking + transfer flows
  • Adds a dedicated multi-transaction UI with a scrollable list of transaction cards (identicon, address, value, fee), summary totals, and a shared confirm button
  • Maintains full backward compatibility — single transactions (inline fields or single-item arrays) continue to work exactly as before, returning a single SignTransactionResult; only multi-item arrays return SignTransactionResults

Changes

Client types (client/src/PublicRequest.ts)

  • New TransactionData type (TransactionInfo without keyPath, since keyPath lives at request level)
  • SignTransactionRequestStandard now accepts either inline TransactionData fields or a { transactions: TransactionData[] | Uint8Array[] } object
  • New SignTransactionResults array type; ResultType and ResultByCommand updated accordingly

Request parsing (SignTransactionApi.js)

  • Auto-detects three input formats: inline single-tx fields, TransactionData[], or Uint8Array[] (serialized, for staking transactions)
  • Validates non-empty arrays, no mixed formats, standard-layout-only for multi-tx
  • Handles postMessage Uint8Array → plain object conversion
  • Removed the staking-type rejection — staking transactions are now supported via serialized format

Internal types (Keyguard.d.ts)

  • Parsed for Standard now uses transactions: Nimiq.Transaction[] instead of transaction: Nimiq.Transaction
  • Parsed for Checkout and Cashlink updated with Transform to also map transactiontransactions

UI handler (SignTransaction.js, SignTransaction.css, index.html)

  • Constructor branches between _renderMultiTransactionView and _renderSingleTransactionView based on transactions.length
  • Multi-tx view: transaction count header, scrollable card list with identicons, total value + total fees summary
  • Transaction count text is reactive to language changes via I18n.observer
  • Signing supports mixed staking/non-staking batches: uses transaction.sign(keyPair) when any staking tx is present, manual SignatureProof.singleSig otherwise
  • CSS scoped under #confirm-transaction.multi — no impact on SignMultisigTransaction which shares the same stylesheet

Translations (en.json)

  • 4 new keys: sign-tx-heading-multi, sign-tx-multi-count, sign-tx-multi-total-fees, passwordbox-confirm-txs
  • Non-English translations still need to be added

Other

  • PasswordBox.js: added passwordbox-confirm-txs button template
  • RequestParser.js: minor adjustment for shared parseTransaction() usage
  • demos/SignTransaction.html: comprehensive demo with format selector and multi-tx controls

Testing

Use the demo page at demos/SignTransaction.html. It provides a format selector (inline / TransactionData / Uint8Array) and controls to adjust the number of transactions. Test single-tx mode to verify backward compatibility, then switch to multi-tx to verify the batch UI, totals, and array result format.

mraveux added 5 commits March 29, 2026 16:25
Add TransactionData type and extend SignTransactionRequestStandard to
accept either inline single-tx fields or a transactions array. Return
type now includes SignTransactionResults for multi-tx responses.
Support signing multiple transactions in a single request, with both
TransactionData[] and serialized Uint8Array[] formats. Staking
transactions are signed using KeyPair.derive + transaction.sign()
instead of manual SignatureProof construction.

Adds a multi-transaction UI with per-transaction cards, totals, and
a "Confirm transactions" button variant.
Add translation keys for multi-tx heading, transaction count, total
fees label, and "Confirm transactions".
Rework the demo page to support inline, single-array, and multi-array
request formats with configurable transaction count and amounts.
- Remove unused `parsedRequest.plain` assignment in SignTransactionApi
- Remove staking-specific field parsing (validatorAddress, validatorImageUrl,
  amount) that was not on any type and unused by the handler
- Fix Parsed type for Checkout/Cashlink to map `transaction` → `transactions`
  matching what the parser actually produces
- Make transaction count text reactive to language changes
- Remove unused `.tx-label` CSS rule
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.

1 participant