-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.js
More file actions
50 lines (44 loc) · 1.6 KB
/
template.js
File metadata and controls
50 lines (44 loc) · 1.6 KB
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
// Example template for WillowCoin (https://bitcointalk.org/index.php?topic=5234309.0)
// Data is from my mining pool at http://scpool.xyz
/**
* Returns a promise of a Number representing the coin's current difficulty
* @returns {Promise}
*/
function getDifficulty(){
// Usually I'd say use an api, don't scrape a pool
// But I own this pool so I am fine scraping it
return customFetch('http://profit.scpool.xyz/explor',false)
.then((data) => {
return data.split('id="DIFF WILLOW" data="')[1].split('"')[0];
});
}
/**
* Returns a promise of a Number representing the coin's current exchange rate to btc
* @returns {Promise}
*/
function getExchangeRate(){
// Willow currently only trades on erex, so getting data from there
return customFetch('http://profit.scpool.xyz/ticker',true)
.then((data) => {
let willowStats = data.filter((x) => {return x.pair == 'BTC_WILLOW'})[0];
return ((Number(willowStats.high24hr) + Number(willowStats.low24hr))/2).toFixed(9);
});
}
/**
* Returns a promise of a Number representing the coin's current block reward.
* NOTE: This will often be a very simple function that just returns a static value,
* but we have to account for coins with varying block reward
* @returns {Promise}
*/
async function getBlockReward(){
let blockReward = 120; // Static for WillowCoin
return blockReward;
}
let template = {
'coin' : 'Willow',
'symbol' : 'WILLOW',
'decimalPlaces' : 3,
'getBlockReward' : getBlockReward,
'getDifficulty' : getDifficulty,
'getExchangeRate' : getExchangeRate
};