-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from EyeOfPython/fix/create_wallet
Fix/create wallet
- Loading branch information
Showing
6 changed files
with
162 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
**/*.rs.bk | ||
**/*.rs.bk | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use qrcode::QrCode; | ||
use std::iter; | ||
use colored::*; | ||
|
||
pub fn display(data: &[u8]) { | ||
|
||
let code = match QrCode::new(data) { | ||
Ok(code) => code, | ||
Err(_) => { | ||
return; | ||
} | ||
}; | ||
|
||
let string = code.render() | ||
.light_color(' ') | ||
.dark_color('#') | ||
.build(); | ||
|
||
let mut empty_str: String; | ||
let mut line_buffer = String::new(); | ||
let mut lines = string.lines().into_iter(); | ||
|
||
while let Some(line_top) = lines.next() { | ||
let line_bottom = match lines.next() { | ||
Some(l) => l, | ||
None => { | ||
empty_str = iter::repeat(' ').take(line_top.len()).collect(); | ||
empty_str.as_str() | ||
} | ||
}; | ||
|
||
for (top, bottom) in line_top.chars().zip(line_bottom.chars()) { | ||
let block = match (top, bottom) { | ||
('#', '#') => '█', | ||
(' ', '#') => '▄', | ||
('#', ' ') => '▀', | ||
_ => ' ', | ||
}; | ||
line_buffer.push(block); | ||
} | ||
|
||
println!("{}", line_buffer.as_str().black().on_bright_white()); | ||
line_buffer.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.