{"record":{"id":"801c27e3379dc706","repo":"diem/diem","slug":"signing-multi-agent-txn-failed","errorCode":null,"errorMessage":"Signing multi agent txn failed","messagePattern":"Signing multi agent txn failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/src/types.rs","lineNumber":87,"sourceCode":"            .iter()\n            .map(|signer| signer.address())\n            .collect();\n        let secondary_signer_privkeys = secondary_signers\n            .iter()\n            .map(|signer| signer.private_key())\n            .collect();\n        let raw_txn = builder\n            .sender(self.address())\n            .sequence_number(self.sequence_number())\n            .build();\n        *self.sequence_number_mut() += 1;\n        raw_txn\n            .sign_multi_agent(\n                self.private_key(),\n                secondary_signer_addresses,\n                secondary_signer_privkeys,\n            )\n            .expect(\"Signing multi agent txn failed\")\n            .into_inner()\n    }\n\n    pub fn address(&self) -> AccountAddress {\n        self.address\n    }\n\n    pub fn private_key(&self) -> &Ed25519PrivateKey {\n        self.key.private_key()\n    }\n\n    pub fn public_key(&self) -> &Ed25519PublicKey {\n        self.key.public_key()\n    }\n\n    pub fn authentication_key(&self) -> AuthenticationKey {\n        self.key.authentication_key()\n    }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/diem/diem/blob/fc4714a8ea273b6efe8b13dbce72ea60aad9a16c/sdk/src/types.rs#L69-L105","documentation":"LocalAccount::sign_multi_agent_with_transaction_builder unwraps RawTransaction::sign_multi_agent with a generic 'Signing multi agent txn failed' message. sign_multi_agent validates signer consistency (primary key matches sender, secondary keys match addresses); any mismatch makes it return an error, and this helper turns that into a panic.","triggerScenarios":"Calling sign_multi_agent_with_transaction_builder where the primary private key does not correspond to the raw transaction's sender, or a secondary private key does not correspond to its paired secondary address.","commonSituations":"Swapped address/key pairs in the secondary signer arrays; sender address derived from a different key than self; building multi-agent payloads with accounts loaded in the wrong order.","solutions":["Verify every (address, private_key) pair matches: derive the address from each private key and compare","Confirm the primary signer (self) is actually the transaction sender of the raw_txn","Check secondary_signer_addresses and secondary_signer_privkeys are the same length and in the same order","Use RawTransaction::sign_multi_agent directly for fallible handling instead of the expect-based helper"],"exampleFix":"// before\nlet signed = account.sign_multi_agent_with_transaction_builder(builder, secondary_addrs, secondary_keys);\n// after\nassert_eq!(account.address(), raw_txn.sender(), \"primary signer must be sender\");\nfor (a, k) in secondary_addrs.iter().zip(secondary_keys) {\n    assert_eq!(a, &diem_crypto::PrivateKey::public_key_for(k).into(), \"key/address mismatch\");\n}\nlet signed = account.sign_multi_agent_with_transaction_builder(builder, secondary_addrs, secondary_keys);","handlingStrategy":"validation","validationCode":"fn validate_signers(\n    sender: AccountAddress,\n    primary: &Ed25519PrivateKey,\n    secondary: &[(AccountAddress, Ed25519PrivateKey)],\n) -> bool {\n    if AccountAddress::from(Ed25519PublicKey::from(primary)) != sender {\n        return false;\n    }\n    secondary.iter().all(|(addr, key)| {\n        &AccountAddress::from(Ed25519PublicKey::from(key)) == addr\n    })\n}","typeGuard":null,"tryCatchPattern":"// prefer the fallible API over the expect-based helper\nlet signed = raw_txn\n    .sign_multi_agent(\n        account.private_key(),\n        secondary_addrs,\n        secondary_keys,\n    )\n    .map_err(|e| anyhow!(\"multi-agent signing failed: {}\", e))?\n    .into_inner();","preventionTips":["Derive each signer address from its private key rather than passing them as independent inputs","Keep secondary signer addresses and keys in a single paired structure to prevent ordering bugs","Assert the primary signer equals the raw transaction sender before signing"],"tags":["sdk","multi-agent","signing","panic"],"backgroundTag":"signer-key-address-mismatch","analyzedSha":"fc4714a8ea273b6efe8b13dbce72ea60aad9a16c","analyzedAt":"2026-09-04T21:07:05.890Z","contentChangedAt":"2026-09-04T21:07:05.890Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}