fix(pay): checksum Monero addresses (base58 + keccak)
All checks were successful
ci / test (pull_request) Successful in 3m16s
All checks were successful
ci / test (pull_request) Successful in 3m16s
Reject prefix+length junk so /pay, /tip, and profile save cannot sign or store garbage xmr_addr. Empty profile address stays allowed.
This commit is contained in:
parent
2b42864eba
commit
666b9d2e86
6 changed files with 99 additions and 16 deletions
|
|
@ -108,21 +108,33 @@ fn chat_is_not_profile() {
|
|||
assert!(profile::decode(b"hello wire").is_none());
|
||||
}
|
||||
|
||||
const MAINNET_STD: &str = "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge";
|
||||
|
||||
#[test]
|
||||
fn self_profile_roundtrip() {
|
||||
let (_dir, store) = store();
|
||||
store.set_self_profile("me", "a bio", "4abc").unwrap();
|
||||
store.set_self_profile("me", "a bio", MAINNET_STD).unwrap();
|
||||
let got = store.self_profile().unwrap();
|
||||
assert_eq!(got.display_name, "me");
|
||||
assert_eq!(got.bio, "a bio");
|
||||
assert_eq!(got.xmr_addr, "4abc");
|
||||
assert_eq!(got.xmr_addr, MAINNET_STD);
|
||||
assert!(got.updated_at > 0);
|
||||
store.set_self_profile("", "", "").unwrap();
|
||||
let empty = store.self_profile().unwrap();
|
||||
assert_eq!(empty.display_name, "");
|
||||
assert_eq!(empty.xmr_addr, "");
|
||||
assert!(empty.updated_at >= got.updated_at);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn self_profile_rejects_short_xmr_addr() {
|
||||
let (_dir, store) = store();
|
||||
assert!(store.set_self_profile("me", "a bio", "4abc").is_err());
|
||||
assert!(profile::validate("me", "a bio", "4abc").is_err());
|
||||
assert!(profile::validate("me", "a bio", "").is_ok());
|
||||
assert!(profile::validate("me", "a bio", MAINNET_STD).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slash_profile_who_and_wipe_still_parse() {
|
||||
assert_eq!(parse_cmd("/profile"), Some(SlashCmd::Profile));
|
||||
|
|
|
|||
Loading…
Reference in a new issue