fix: chat key validation
This commit is contained in:
parent
7c0dbb554a
commit
3d9a2957de
|
@ -147,3 +147,6 @@ QtObject:
|
||||||
|
|
||||||
proc getCompressedPk*(self: Utils, publicKey: string): string {.slot.} =
|
proc getCompressedPk*(self: Utils, publicKey: string): string {.slot.} =
|
||||||
procs_from_accounts.compressPk(publicKey)
|
procs_from_accounts.compressPk(publicKey)
|
||||||
|
|
||||||
|
proc isCompressedPubKey*(self: Utils, publicKey: string): bool {.slot.} =
|
||||||
|
conversion.isCompressedPubKey(publicKey)
|
||||||
|
|
|
@ -4,7 +4,7 @@ from web3 import Address, fromHex
|
||||||
const CompressedKeyChars* = {'0'..'9', 'A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
|
const CompressedKeyChars* = {'0'..'9', 'A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
|
||||||
|
|
||||||
proc isCompressedPubKey*(strPubKey: string): bool =
|
proc isCompressedPubKey*(strPubKey: string): bool =
|
||||||
return strPubKey.startsWith("z") and strPubKey.len == 49 and allCharsInSet(strPubKey, CompressedKeyChars)
|
return strPubKey.startsWith("zQ3") and allCharsInSet(strPubKey, CompressedKeyChars)
|
||||||
|
|
||||||
proc parseAddress*(strAddress: string): Address =
|
proc parseAddress*(strAddress: string): Address =
|
||||||
fromHex(Address, strAddress)
|
fromHex(Address, strAddress)
|
||||||
|
|
|
@ -17,7 +17,6 @@ import ../../../backend/utils as status_utils
|
||||||
export contacts_dto, status_update_dto, contact_details
|
export contacts_dto, status_update_dto, contact_details
|
||||||
|
|
||||||
const PK_LENGTH_0X_INCLUDED = 132
|
const PK_LENGTH_0X_INCLUDED = 132
|
||||||
const PK_LENGTH_COMPRESSED = 49
|
|
||||||
|
|
||||||
include async_tasks
|
include async_tasks
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ import shared 1.0
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
|
property var globalUtilsInst: globalUtils
|
||||||
|
|
||||||
function isHex(value) {
|
function isHex(value) {
|
||||||
return /^(-0x|0x)?[0-9a-fA-F]*$/i.test(value)
|
return /^(-0x|0x)?[0-9a-fA-F]*$/i.test(value)
|
||||||
}
|
}
|
||||||
|
@ -15,8 +17,7 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isChatKey(value) {
|
function isChatKey(value) {
|
||||||
return (startsWith0x(value) && isHex(value) && value.length === 132) ||
|
return (startsWith0x(value) && isHex(value) && value.length === 132) || globalUtilsInst.isCompressedPubKey(value)
|
||||||
/^z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{48}$/.test(value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidETHNamePrefix(value) {
|
function isValidETHNamePrefix(value) {
|
||||||
|
|
Loading…
Reference in New Issue