-
Notifications
You must be signed in to change notification settings - Fork 6
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 #5 from Rigidity/redesign-wallet
Redesign wallet
- Loading branch information
Showing
22 changed files
with
1,746 additions
and
964 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,23 @@ | ||
/// Parses an address into a puzzle hash. | ||
pub fn parse_address(address: &str) -> [u8; 32] { | ||
if let Ok(puzzle_hash) = hex::decode(strip_prefix(address)) { | ||
puzzle_hash.try_into().expect("invalid puzzle hash") | ||
} else { | ||
let (_hrp, data, _variant) = bech32::decode(address).expect("invalid address"); | ||
let puzzle_hash = bech32::convert_bits(&data, 5, 8, false).expect("invalid address data"); | ||
puzzle_hash | ||
.try_into() | ||
.expect("invalid address puzzle hash encoding") | ||
} | ||
} | ||
|
||
/// Removes the `0x` prefix from a puzzle hash in hex format. | ||
fn strip_prefix(puzzle_hash: &str) -> &str { | ||
if let Some(puzzle_hash) = puzzle_hash.strip_prefix("0x") { | ||
puzzle_hash | ||
} else if let Some(puzzle_hash) = puzzle_hash.strip_prefix("0X") { | ||
puzzle_hash | ||
} else { | ||
puzzle_hash | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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.