2020-06-22 15:51:15 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
function isHex(value) {
|
2020-06-22 17:26:47 +00:00
|
|
|
return /^(-0x|0x)?[0-9a-f]*$/i.test(value)
|
2020-06-22 15:51:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function startsWith0x(value) {
|
|
|
|
return value.startsWith('0x')
|
|
|
|
}
|
|
|
|
|
|
|
|
function isChatKey(value) {
|
|
|
|
return startsWith0x(value) && isHex(value) && value.length === 132
|
|
|
|
}
|
2020-06-22 17:26:47 +00:00
|
|
|
|
|
|
|
function isAddress(value) {
|
|
|
|
return startsWith0x(value) && isHex(value) && value.length === 42
|
|
|
|
}
|
|
|
|
|
|
|
|
function isPrivateKey(value) {
|
|
|
|
return isHex(value) && ((startsWith0x(value) && value.length === 66) ||
|
|
|
|
(!startsWith0x(value) && value.length === 64))
|
|
|
|
}
|
2020-06-22 17:57:06 +00:00
|
|
|
|
|
|
|
function isMnemonic(value) {
|
|
|
|
// Do we support other length than 12?
|
|
|
|
return value.split(/\s|,/).length === 12
|
|
|
|
}
|
2020-06-22 15:51:15 +00:00
|
|
|
}
|