Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion mina-tx/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{
errors::MinaTxError,
signatures::Sig,
signatures::{Sig, TransactionSignature},
transactions::{
legacy_tx::LegacyTransaction,
network_id::NetworkIdEnvelope,
Expand Down Expand Up @@ -89,6 +89,13 @@ impl TransactionEnvelope {
pub fn from_str_network(s: &str, network_id: NetworkIdEnvelope) -> Result<Self, MinaTxError> {
let s = s.trim();

// Try parsing as a TransactionSignature first (output from a previous signing session).
// This enables chained multi-group signing where the output of one session is fed as
// input to the next. The inner payload already has the previous signature injected.
if let Ok(signed) = serde_json::from_str::<TransactionSignature>(s) {
return Ok(signed.payload);
}

// Try parsing as ZkApp transaction first, then Legacy.
// IMPORTANT: Do NOT silently swallow parse errors here. If both fail, the caller
// needs to see the actual serde errors to diagnose the problem — not a generic
Expand Down Expand Up @@ -360,6 +367,26 @@ mod tests {
);
}

/// A TransactionSignature (output from a previous FROST signing session) should be
/// parseable as input for a subsequent signing session, enabling chained multi-group
/// signing of the same transaction.
#[cfg(not(feature = "mesa-hardfork"))]
#[test]
fn test_parse_signed_transaction_as_input() {
let json = include_str!("../tests/data/deploy-v0.0.6-admin-signed.json");
let result = TransactionEnvelope::from_str_network(
json,
NetworkIdEnvelope::from(NetworkId::Testnet),
);
assert!(
result.is_ok(),
"Signed transaction should be parseable as input: {:?}",
result.unwrap_err()
);
let envelope = result.unwrap();
assert!(!envelope.is_legacy());
}

#[test]
fn test_from_str_network_invalid_json() {
let result = TransactionEnvelope::from_str_network(
Expand Down
Loading