forked from Public/monero-gui
Generate proof from history view and made javascript file with tx related functions
This commit is contained in:
committed by
moneromooo-monero
parent
09935ba4b0
commit
70983136bc
57
js/TxUtils.js
Normal file
57
js/TxUtils.js
Normal file
@@ -0,0 +1,57 @@
|
||||
function destinationsToAmount(destinations){
|
||||
// Gets amount from destinations line
|
||||
// input: "20.000000000000: 9tLGyK277MnYrDc7Vzi6TB1pJvstFoviziFwsqQNFbwA9rvg5RxYVYjEezFKDjvDHgAzTELJhJHVx6JAaWZKeVqSUZkXeKk"
|
||||
// returns: 20.000000000000
|
||||
return destinations.split(" ")[0].split(":")[0];
|
||||
}
|
||||
|
||||
function destinationsToAddress(destinations){
|
||||
var address = destinations.split(" ")[1];
|
||||
if(address === undefined) return ""
|
||||
return address;
|
||||
}
|
||||
|
||||
function addressTruncate(address){
|
||||
return address.substring(0, 6) + "..." + address.substring(address.length-6);
|
||||
}
|
||||
|
||||
function check256(str, length) {
|
||||
if (str.length != length)
|
||||
return false;
|
||||
for (var i = 0; i < length; ++i) {
|
||||
if (str[i] >= '0' && str[i] <= '9')
|
||||
continue;
|
||||
if (str[i] >= 'a' && str[i] <= 'z')
|
||||
continue;
|
||||
if (str[i] >= 'A' && str[i] <= 'Z')
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkAddress(address, testnet) {
|
||||
return walletManager.addressValid(address, testnet)
|
||||
}
|
||||
|
||||
function checkTxID(txid) {
|
||||
return check256(txid, 64)
|
||||
}
|
||||
|
||||
function checkSignature(signature) {
|
||||
if (signature.indexOf("OutProofV") === 0) {
|
||||
if ((signature.length - 10) % 132 != 0)
|
||||
return false;
|
||||
return check256(signature, signature.length);
|
||||
} else if (signature.indexOf("InProofV") === 0) {
|
||||
if ((signature.length - 9) % 132 != 0)
|
||||
return false;
|
||||
return check256(signature, signature.length);
|
||||
} else if (signature.indexOf("SpendProofV") === 0) {
|
||||
if ((signature.length - 12) % 88 != 0)
|
||||
return false;
|
||||
return check256(signature, signature.length);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user