-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (38 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const { default: Axios } = require("axios");
const zaddrRegex = /^zs[a-z0-9]{76}$/;
const taddrRegex = /^t1[AC-HJ-NP-Zac-hj-np-z02-9]{33}$/;
const axios = require("axios")
exports.isValidZaddr = function(zaddr) {
return zaddrRegex.test(zaddr)
}
exports.isValidTaddr = function(taddr) {
return taddrRegex.test(taddr)
}
exports.isValidAddress = function(address) {
return taddrRegex.test(address) || zaddrRegex.test(address)
}
exports.zatToZec = function(i) {
return +(i / 100000000).toFixed(8)
}
exports.zecToZat = function(f) {
return f * 100000000
}
exports.price = async function(currency = "usd") {
try {
res = await axios.get("https://api.coingecko.com/api/v3/coins/zcash")
return +res.data.market_data.current_price[currency.toLowerCase()]
} catch {
console.log("Error accessing price info")
}
// Should this return a string or a float?
}
// the three above functions are untested
// TODO:
// sendmany generator
// Lite wallet CLI send generator
// Burner address generator
// Memo splitter
// Price query
// Block info grabber
// Zatoshi to ZEC
// ZEC to Zatoshi