diff --git a/cli-output/src/cli_output.rs b/cli-output/src/cli_output.rs index 4ba5c22123..dd50572dc5 100644 --- a/cli-output/src/cli_output.rs +++ b/cli-output/src/cli_output.rs @@ -2450,6 +2450,10 @@ mod tests { fn try_sign_message(&self, _message: &[u8]) -> Result { Ok(Signature::new(&[1u8; 64])) } + + fn is_interactive(&self) -> bool { + false + } } let present: Box = Box::new(keypair_from_seed(&[2u8; 32]).unwrap()); diff --git a/remote-wallet/src/remote_keypair.rs b/remote-wallet/src/remote_keypair.rs index 28ccbe83c4..d37eefe242 100644 --- a/remote-wallet/src/remote_keypair.rs +++ b/remote-wallet/src/remote_keypair.rs @@ -53,6 +53,10 @@ impl Signer for RemoteKeypair { .map_err(|e| e.into()), } } + + fn is_interactive(&self) -> bool { + true + } } pub fn generate_remote_keypair( diff --git a/sdk/src/signer/keypair.rs b/sdk/src/signer/keypair.rs index aa6f463256..b32c348f93 100644 --- a/sdk/src/signer/keypair.rs +++ b/sdk/src/signer/keypair.rs @@ -80,6 +80,10 @@ impl Signer for Keypair { fn try_sign_message(&self, message: &[u8]) -> Result { Ok(self.sign_message(message)) } + + fn is_interactive(&self) -> bool { + false + } } impl PartialEq for Keypair diff --git a/sdk/src/signer/mod.rs b/sdk/src/signer/mod.rs index bf7dcc52e0..27a4d07066 100644 --- a/sdk/src/signer/mod.rs +++ b/sdk/src/signer/mod.rs @@ -68,6 +68,8 @@ pub trait Signer { } /// Fallibly produces an Ed25519 signature over the provided `message` bytes. fn try_sign_message(&self, message: &[u8]) -> Result; + /// Whether the impelmentation requires user interaction to sign + fn is_interactive(&self) -> bool; } impl From for Box diff --git a/sdk/src/signer/null_signer.rs b/sdk/src/signer/null_signer.rs index d5b5ccd38b..2e95085118 100644 --- a/sdk/src/signer/null_signer.rs +++ b/sdk/src/signer/null_signer.rs @@ -28,6 +28,10 @@ impl Signer for NullSigner { fn try_sign_message(&self, _message: &[u8]) -> Result { Ok(Signature::default()) } + + fn is_interactive(&self) -> bool { + false + } } impl PartialEq for NullSigner diff --git a/sdk/src/signer/presigner.rs b/sdk/src/signer/presigner.rs index 4b9c12c11a..a5f16fb6e1 100644 --- a/sdk/src/signer/presigner.rs +++ b/sdk/src/signer/presigner.rs @@ -46,6 +46,10 @@ impl Signer for Presigner { Err(PresignerError::VerificationFailure.into()) } } + + fn is_interactive(&self) -> bool { + false + } } impl PartialEq for Presigner diff --git a/sdk/src/signer/signers.rs b/sdk/src/signer/signers.rs index abc0772096..e4b07c8cd8 100644 --- a/sdk/src/signer/signers.rs +++ b/sdk/src/signer/signers.rs @@ -10,6 +10,7 @@ pub trait Signers { fn try_pubkeys(&self) -> Result, SignerError>; fn sign_message(&self, message: &[u8]) -> Vec; fn try_sign_message(&self, message: &[u8]) -> Result, SignerError>; + fn is_interactive(&self) -> bool; } macro_rules! default_keypairs_impl { @@ -39,6 +40,10 @@ macro_rules! default_keypairs_impl { } Ok(signatures) } + + fn is_interactive(&self) -> bool { + self.iter().any(|s| s.is_interactive()) + } }; } @@ -118,6 +123,9 @@ mod tests { fn try_sign_message(&self, _message: &[u8]) -> Result { Ok(Signature::default()) } + fn is_interactive(&self) -> bool { + false + } } struct Bar; @@ -128,6 +136,9 @@ mod tests { fn try_sign_message(&self, _message: &[u8]) -> Result { Ok(Signature::default()) } + fn is_interactive(&self) -> bool { + false + } } #[test]