Skip to content

Commit

Permalink
Print qr code for signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
TheQuantumPhysicist committed Feb 6, 2024
1 parent cc994b4 commit 953ffa6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub enum SignArbitraryMessageError {
Unsupported,
}

#[derive(Debug, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct SignedArbitraryMessage {
raw_signature: Vec<u8>,
}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/wallet_sign_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
20 changes: 16 additions & 4 deletions wallet/wallet-cli-lib/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)))
}

Expand All @@ -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)
)))
}

Expand Down

0 comments on commit 953ffa6

Please sign in to comment.