From 953ffa6fec9f6317fc0894d92ccd8d03bcb3d06e Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 6 Feb 2024 20:12:24 +0400 Subject: [PATCH] Print qr code for signatures --- .../inputsig/arbitrary_message/mod.rs | 2 +- test/functional/wallet_sign_message.py | 2 +- wallet/wallet-cli-lib/src/commands/mod.rs | 20 +++++++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/common/src/chain/transaction/signature/inputsig/arbitrary_message/mod.rs b/common/src/chain/transaction/signature/inputsig/arbitrary_message/mod.rs index e6252ef9c0..0308cc66a7 100644 --- a/common/src/chain/transaction/signature/inputsig/arbitrary_message/mod.rs +++ b/common/src/chain/transaction/signature/inputsig/arbitrary_message/mod.rs @@ -49,7 +49,7 @@ pub enum SignArbitraryMessageError { Unsupported, } -#[derive(Debug, Eq, PartialEq)] +#[derive(Debug, Clone, Eq, PartialEq)] pub struct SignedArbitraryMessage { raw_signature: Vec, } diff --git a/test/functional/wallet_sign_message.py b/test/functional/wallet_sign_message.py index 402618c282..42351e81bb 100644 --- a/test/functional/wallet_sign_message.py +++ b/test/functional/wallet_sign_message.py @@ -67,7 +67,7 @@ async def async_test(self): else: output = await wallet.sign_challenge_plain(message, destination) assert_in("The generated hex encoded signature is", output) - signature = output.split('\n')[1] + signature = output.split('\n')[2] await wallet.close_wallet() diff --git a/wallet/wallet-cli-lib/src/commands/mod.rs b/wallet/wallet-cli-lib/src/commands/mod.rs index 170a711d5a..11365dfa26 100644 --- a/wallet/wallet-cli-lib/src/commands/mod.rs +++ b/wallet/wallet-cli-lib/src/commands/mod.rs @@ -1156,9 +1156,15 @@ where let result = self.wallet_rpc.sign_challenge(selected_account, challenge, address).await?; + let qr_code = utils::qrcode::qrcode_from_str(result.clone().to_hex()) + .map_err(WalletCliError::QrCodeEncoding)?; + Ok(ConsoleCommand::Print(format!( - "The generated hex encoded signature is\n{}", - result.to_hex() + "The generated hex encoded signature is\n\n{} + \n\n\ + The following qr code also contains the signature for easy transport:\n{}", + result.to_hex(), + qr_code.encode_to_console_string_with_defaults(1) ))) } @@ -1172,9 +1178,15 @@ where .sign_challenge(selected_account, challenge.into_bytes(), address) .await?; + let qr_code = utils::qrcode::qrcode_from_str(result.clone().to_hex()) + .map_err(WalletCliError::QrCodeEncoding)?; + Ok(ConsoleCommand::Print(format!( - "The generated hex encoded signature is\n{}", - result.to_hex() + "The generated hex encoded signature is\n\n{} + \n\n\ + The following qr code also contains the signature for easy transport:\n{}", + result.to_hex(), + qr_code.encode_to_console_string_with_defaults(1) ))) }